taboola-backstage-sdk 0.3.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -50
- package/dist/index.cjs +108 -680
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +447 -908
- package/dist/index.d.ts +447 -908
- package/dist/index.js +108 -680
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -264,7 +264,9 @@ var HttpClient = class {
|
|
|
264
264
|
afterResponse: [
|
|
265
265
|
async (request, _options, response) => {
|
|
266
266
|
if (this.debug) {
|
|
267
|
-
console.log(
|
|
267
|
+
console.log(
|
|
268
|
+
`[Taboola SDK] ${request.method} ${String(response.status)} ${request.url}`
|
|
269
|
+
);
|
|
268
270
|
}
|
|
269
271
|
if (response.status === 401) {
|
|
270
272
|
try {
|
|
@@ -424,17 +426,6 @@ var CampaignsAPI = class {
|
|
|
424
426
|
}
|
|
425
427
|
/**
|
|
426
428
|
* List all campaigns for an account
|
|
427
|
-
*
|
|
428
|
-
* @param accountId - Account ID
|
|
429
|
-
* @param options - Pagination and filter options
|
|
430
|
-
*
|
|
431
|
-
* @example
|
|
432
|
-
* ```typescript
|
|
433
|
-
* const { results } = await client.campaigns.list('my-account');
|
|
434
|
-
* for (const campaign of results) {
|
|
435
|
-
* console.log(campaign.name, campaign.status);
|
|
436
|
-
* }
|
|
437
|
-
* ```
|
|
438
429
|
*/
|
|
439
430
|
async list(accountId, options = {}) {
|
|
440
431
|
const searchParams = new URLSearchParams();
|
|
@@ -456,115 +447,30 @@ var CampaignsAPI = class {
|
|
|
456
447
|
}
|
|
457
448
|
/**
|
|
458
449
|
* List all campaigns with base (partial) fields only
|
|
459
|
-
*
|
|
460
|
-
* Returns a lighter-weight response with fewer fields per campaign.
|
|
461
|
-
* Useful for listing/overview pages where full campaign data is not needed.
|
|
462
|
-
*
|
|
463
|
-
* @param accountId - Account ID
|
|
464
|
-
*
|
|
465
|
-
* @example
|
|
466
|
-
* ```typescript
|
|
467
|
-
* const { results } = await client.campaigns.listBase('my-account');
|
|
468
|
-
* for (const campaign of results) {
|
|
469
|
-
* console.log(campaign.name, campaign.status);
|
|
470
|
-
* }
|
|
471
|
-
* ```
|
|
472
450
|
*/
|
|
473
451
|
async listBase(accountId) {
|
|
474
452
|
return this.http.get(`${accountId}/campaigns/base`);
|
|
475
453
|
}
|
|
476
454
|
/**
|
|
477
455
|
* Get a single campaign by ID
|
|
478
|
-
*
|
|
479
|
-
* @param accountId - Account ID
|
|
480
|
-
* @param campaignId - Campaign ID
|
|
481
|
-
*
|
|
482
|
-
* @example
|
|
483
|
-
* ```typescript
|
|
484
|
-
* const campaign = await client.campaigns.get('my-account', '12345');
|
|
485
|
-
* console.log(campaign.name, campaign.cpc);
|
|
486
|
-
* ```
|
|
487
456
|
*/
|
|
488
457
|
async get(accountId, campaignId) {
|
|
489
458
|
return this.http.get(`${accountId}/campaigns/${campaignId}`);
|
|
490
459
|
}
|
|
491
460
|
/**
|
|
492
461
|
* Create a new campaign
|
|
493
|
-
*
|
|
494
|
-
* @param accountId - Account ID
|
|
495
|
-
* @param campaign - Campaign data
|
|
496
|
-
*
|
|
497
|
-
* @example
|
|
498
|
-
* ```typescript
|
|
499
|
-
* const campaign = await client.campaigns.create('my-account', {
|
|
500
|
-
* name: 'My New Campaign',
|
|
501
|
-
* branding_text: 'My Brand',
|
|
502
|
-
* cpc: 0.50,
|
|
503
|
-
* spending_limit: 1000,
|
|
504
|
-
* spending_limit_model: 'MONTHLY',
|
|
505
|
-
* marketing_objective: 'DRIVE_WEBSITE_TRAFFIC',
|
|
506
|
-
* });
|
|
507
|
-
* console.log('Created campaign:', campaign.id);
|
|
508
|
-
* ```
|
|
509
462
|
*/
|
|
510
463
|
async create(accountId, campaign) {
|
|
511
464
|
return this.http.post(`${accountId}/campaigns/`, campaign);
|
|
512
465
|
}
|
|
513
466
|
/**
|
|
514
467
|
* Update an existing campaign
|
|
515
|
-
*
|
|
516
|
-
* Submit only the fields you want to update. Fields that are omitted or null
|
|
517
|
-
* will remain unchanged.
|
|
518
|
-
*
|
|
519
|
-
* @param accountId - Account ID
|
|
520
|
-
* @param campaignId - Campaign ID
|
|
521
|
-
* @param updates - Fields to update (partial)
|
|
522
|
-
*
|
|
523
|
-
* @example Update a single field
|
|
524
|
-
* ```typescript
|
|
525
|
-
* const campaign = await client.campaigns.update('my-account', '12345', {
|
|
526
|
-
* name: 'DemoCampaign - Edited',
|
|
527
|
-
* });
|
|
528
|
-
* ```
|
|
529
|
-
*
|
|
530
|
-
* @example Update multiple fields including targeting
|
|
531
|
-
* ```typescript
|
|
532
|
-
* const campaign = await client.campaigns.update('my-account', '12345', {
|
|
533
|
-
* name: 'Demo Campaign - Edited Again',
|
|
534
|
-
* branding_text: 'New branding text',
|
|
535
|
-
* spending_limit: 10000,
|
|
536
|
-
* spending_limit_model: 'ENTIRE',
|
|
537
|
-
* country_targeting: {
|
|
538
|
-
* type: 'INCLUDE',
|
|
539
|
-
* value: ['AU', 'GB'],
|
|
540
|
-
* },
|
|
541
|
-
* platform_targeting: {
|
|
542
|
-
* type: 'INCLUDE',
|
|
543
|
-
* value: ['TBLT', 'PHON'],
|
|
544
|
-
* },
|
|
545
|
-
* });
|
|
546
|
-
* ```
|
|
547
|
-
*
|
|
548
|
-
* @example Pause a campaign (alternatively, use pause() method)
|
|
549
|
-
* ```typescript
|
|
550
|
-
* const campaign = await client.campaigns.update('my-account', '12345', {
|
|
551
|
-
* is_active: false,
|
|
552
|
-
* });
|
|
553
|
-
* ```
|
|
554
468
|
*/
|
|
555
469
|
async update(accountId, campaignId, updates) {
|
|
556
470
|
return this.http.post(`${accountId}/campaigns/${campaignId}`, updates);
|
|
557
471
|
}
|
|
558
472
|
/**
|
|
559
473
|
* Delete a campaign
|
|
560
|
-
*
|
|
561
|
-
* @param accountId - Account ID
|
|
562
|
-
* @param campaignId - Campaign ID
|
|
563
|
-
*
|
|
564
|
-
* @example
|
|
565
|
-
* ```typescript
|
|
566
|
-
* await client.campaigns.delete('my-account', '12345');
|
|
567
|
-
* ```
|
|
568
474
|
*/
|
|
569
475
|
async delete(accountId, campaignId) {
|
|
570
476
|
await this.http.delete(`${accountId}/campaigns/${campaignId}`);
|
|
@@ -572,122 +478,58 @@ var CampaignsAPI = class {
|
|
|
572
478
|
/**
|
|
573
479
|
* Duplicate a campaign
|
|
574
480
|
*
|
|
575
|
-
* Creates a copy of an existing campaign with a new name.
|
|
576
|
-
*
|
|
577
481
|
* @param accountId - Account ID
|
|
578
482
|
* @param campaignId - Campaign ID to duplicate
|
|
579
|
-
* @param
|
|
580
|
-
*
|
|
581
|
-
* @example
|
|
582
|
-
* ```typescript
|
|
583
|
-
* const newCampaign = await client.campaigns.duplicate(
|
|
584
|
-
* 'my-account',
|
|
585
|
-
* '12345',
|
|
586
|
-
* 'My Campaign - Copy'
|
|
587
|
-
* );
|
|
588
|
-
* ```
|
|
483
|
+
* @param request - Duplication request with optional name and settings
|
|
484
|
+
* @param destinationAccount - Optional destination account ID for cross-account duplication
|
|
589
485
|
*/
|
|
590
|
-
async duplicate(accountId, campaignId,
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
486
|
+
async duplicate(accountId, campaignId, request, destinationAccount) {
|
|
487
|
+
const searchParams = new URLSearchParams();
|
|
488
|
+
if (destinationAccount) {
|
|
489
|
+
searchParams.set("destination_account", destinationAccount);
|
|
490
|
+
}
|
|
491
|
+
const query = searchParams.toString();
|
|
492
|
+
const path = `${accountId}/campaigns/${campaignId}/duplicate${query ? `?${query}` : ""}`;
|
|
493
|
+
return this.http.post(path, request);
|
|
594
494
|
}
|
|
595
495
|
/**
|
|
596
496
|
* Pause a campaign
|
|
597
|
-
*
|
|
598
|
-
* @param accountId - Account ID
|
|
599
|
-
* @param campaignId - Campaign ID
|
|
600
|
-
*
|
|
601
|
-
* @example
|
|
602
|
-
* ```typescript
|
|
603
|
-
* await client.campaigns.pause('my-account', '12345');
|
|
604
|
-
* ```
|
|
605
497
|
*/
|
|
606
498
|
async pause(accountId, campaignId) {
|
|
607
499
|
return this.update(accountId, campaignId, { is_active: false });
|
|
608
500
|
}
|
|
609
501
|
/**
|
|
610
502
|
* Unpause (resume) a campaign
|
|
611
|
-
*
|
|
612
|
-
* @param accountId - Account ID
|
|
613
|
-
* @param campaignId - Campaign ID
|
|
614
|
-
*
|
|
615
|
-
* @example
|
|
616
|
-
* ```typescript
|
|
617
|
-
* await client.campaigns.unpause('my-account', '12345');
|
|
618
|
-
* ```
|
|
619
503
|
*/
|
|
620
504
|
async unpause(accountId, campaignId) {
|
|
621
505
|
return this.update(accountId, campaignId, { is_active: true });
|
|
622
506
|
}
|
|
623
507
|
/**
|
|
624
508
|
* Bulk update multiple campaigns
|
|
625
|
-
*
|
|
626
|
-
* @param accountId - Account ID
|
|
627
|
-
* @param updates - Array of campaign updates
|
|
628
|
-
*
|
|
629
|
-
* @example
|
|
630
|
-
* ```typescript
|
|
631
|
-
* await client.campaigns.bulkUpdate('my-account', {
|
|
632
|
-
* campaigns: [
|
|
633
|
-
* { campaign_id: '12345', update: { is_active: false } },
|
|
634
|
-
* { campaign_id: '12346', update: { is_active: false } },
|
|
635
|
-
* ],
|
|
636
|
-
* });
|
|
637
|
-
* ```
|
|
638
509
|
*/
|
|
639
510
|
async bulkUpdate(accountId, updates) {
|
|
640
511
|
return this.http.put(`${accountId}/campaigns/bulk`, updates);
|
|
641
512
|
}
|
|
642
513
|
/**
|
|
643
|
-
* Patch a campaign
|
|
514
|
+
* Patch a campaign
|
|
644
515
|
*
|
|
645
516
|
* @param accountId - Account ID
|
|
646
517
|
* @param campaignId - Campaign ID
|
|
647
|
-
* @param
|
|
648
|
-
* @param patches - Patch operations
|
|
649
|
-
*
|
|
650
|
-
* @example
|
|
651
|
-
* ```typescript
|
|
652
|
-
* await client.campaigns.patch('my-account', '12345', 'publisher_targeting', [
|
|
653
|
-
* { op: 'ADD', path: '/value', value: ['pub-123'] },
|
|
654
|
-
* ]);
|
|
655
|
-
* ```
|
|
518
|
+
* @param patch - Patch operation
|
|
656
519
|
*/
|
|
657
|
-
async patch(accountId, campaignId,
|
|
658
|
-
return this.http.patch(`${accountId}/campaigns/${campaignId}
|
|
520
|
+
async patch(accountId, campaignId, patch) {
|
|
521
|
+
return this.http.patch(`${accountId}/campaigns/${campaignId}`, patch);
|
|
659
522
|
}
|
|
660
523
|
/**
|
|
661
524
|
* Get all campaigns across a network
|
|
662
525
|
*
|
|
663
526
|
* @param networkAccountId - Network account ID
|
|
664
|
-
*
|
|
665
|
-
* @example
|
|
666
|
-
* ```typescript
|
|
667
|
-
* const { results } = await client.campaigns.listNetwork('my-network');
|
|
668
|
-
* ```
|
|
669
527
|
*/
|
|
670
528
|
async listNetwork(networkAccountId) {
|
|
671
|
-
return this.http.get(
|
|
529
|
+
return this.http.get(`${networkAccountId}/campaigns/base`);
|
|
672
530
|
}
|
|
673
531
|
/**
|
|
674
532
|
* Estimate campaign reach
|
|
675
|
-
*
|
|
676
|
-
* Get estimated impressions, clicks, and reach for a campaign configuration.
|
|
677
|
-
*
|
|
678
|
-
* @param accountId - Account ID
|
|
679
|
-
* @param params - Targeting and budget parameters
|
|
680
|
-
*
|
|
681
|
-
* @example
|
|
682
|
-
* ```typescript
|
|
683
|
-
* const estimate = await client.campaigns.estimateReach('my-account', {
|
|
684
|
-
* country_targeting: ['US'],
|
|
685
|
-
* platform_targeting: ['DESK', 'PHON'],
|
|
686
|
-
* daily_cap: 100,
|
|
687
|
-
* cpc: 0.50,
|
|
688
|
-
* });
|
|
689
|
-
* console.log('Estimated clicks:', estimate.estimated_clicks);
|
|
690
|
-
* ```
|
|
691
533
|
*/
|
|
692
534
|
async estimateReach(accountId, params) {
|
|
693
535
|
return this.http.post(
|
|
@@ -697,17 +539,6 @@ var CampaignsAPI = class {
|
|
|
697
539
|
}
|
|
698
540
|
/**
|
|
699
541
|
* Get publisher targeting whitelist for a campaign
|
|
700
|
-
*
|
|
701
|
-
* Returns the list of publishers that are whitelisted for this campaign.
|
|
702
|
-
*
|
|
703
|
-
* @param accountId - Account ID
|
|
704
|
-
* @param campaignId - Campaign ID
|
|
705
|
-
*
|
|
706
|
-
* @example
|
|
707
|
-
* ```typescript
|
|
708
|
-
* const whitelist = await client.campaigns.getTargetingWhitelist('my-account', '12345');
|
|
709
|
-
* console.log('Whitelisted publishers:', whitelist.value);
|
|
710
|
-
* ```
|
|
711
542
|
*/
|
|
712
543
|
async getTargetingWhitelist(accountId, campaignId) {
|
|
713
544
|
return this.http.get(
|
|
@@ -771,26 +602,30 @@ var ItemsAPI = class {
|
|
|
771
602
|
return this.http.get(`${accountId}/campaigns/${campaignId}/items/${itemId}`);
|
|
772
603
|
}
|
|
773
604
|
/**
|
|
774
|
-
* Create a new item (ad) in a campaign
|
|
605
|
+
* Create a new item (static ad) in a campaign
|
|
606
|
+
*
|
|
607
|
+
* Only the `url` field is accepted. The item is created with a status of CRAWLING
|
|
608
|
+
* (read-only). Poll until the status changes to RUNNING or NEED_TO_EDIT, then
|
|
609
|
+
* use `update()` to modify fields.
|
|
610
|
+
*
|
|
611
|
+
* For creating items with more fields upfront, or for motion ads,
|
|
612
|
+
* use `bulkCreateAcrossCampaigns()` instead.
|
|
775
613
|
*
|
|
776
614
|
* @param accountId - Account ID
|
|
777
615
|
* @param campaignId - Campaign ID
|
|
778
|
-
* @param item - Item data
|
|
616
|
+
* @param item - Item data (only `url` is accepted)
|
|
779
617
|
*
|
|
780
618
|
* @example
|
|
781
619
|
* ```typescript
|
|
782
620
|
* const item = await client.items.create('my-account', '12345', {
|
|
783
621
|
* url: 'https://example.com/landing-page',
|
|
784
|
-
* title: 'Check Out Our Amazing Product!',
|
|
785
|
-
* thumbnail_url: 'https://example.com/image.jpg',
|
|
786
|
-
* description: 'Learn more about our product',
|
|
787
|
-
* cta: { cta_type: 'LEARN_MORE' },
|
|
788
622
|
* });
|
|
789
|
-
*
|
|
623
|
+
* // Item starts in CRAWLING state - poll until status changes
|
|
624
|
+
* console.log('Created item:', item.id, item.status); // CRAWLING
|
|
790
625
|
* ```
|
|
791
626
|
*/
|
|
792
627
|
async create(accountId, campaignId, item) {
|
|
793
|
-
return this.http.post(`${accountId}/campaigns/${campaignId}/items
|
|
628
|
+
return this.http.post(`${accountId}/campaigns/${campaignId}/items`, item);
|
|
794
629
|
}
|
|
795
630
|
/**
|
|
796
631
|
* Update an existing item (static or motion ad)
|
|
@@ -884,7 +719,9 @@ var ItemsAPI = class {
|
|
|
884
719
|
return this.update(accountId, campaignId, itemId, { is_active: true });
|
|
885
720
|
}
|
|
886
721
|
/**
|
|
887
|
-
* Create multiple items at once (mass create)
|
|
722
|
+
* Create multiple items at once within a single campaign (mass create)
|
|
723
|
+
*
|
|
724
|
+
* Supports both static ads and motion ads via the bulk item data format.
|
|
888
725
|
*
|
|
889
726
|
* @param accountId - Account ID
|
|
890
727
|
* @param campaignId - Campaign ID
|
|
@@ -892,32 +729,47 @@ var ItemsAPI = class {
|
|
|
892
729
|
*
|
|
893
730
|
* @example
|
|
894
731
|
* ```typescript
|
|
895
|
-
* const response = await client.items.bulkCreate('my-account', '12345',
|
|
896
|
-
*
|
|
897
|
-
*
|
|
898
|
-
*
|
|
899
|
-
* ],
|
|
900
|
-
* });
|
|
732
|
+
* const response = await client.items.bulkCreate('my-account', '12345', [
|
|
733
|
+
* { url: 'https://example.com/page1', title: 'Title 1', thumbnail_url: '...' },
|
|
734
|
+
* { url: 'https://example.com/page2', title: 'Title 2', thumbnail_url: '...' },
|
|
735
|
+
* ]);
|
|
901
736
|
* console.log('Created', response.results.length, 'items');
|
|
902
737
|
* ```
|
|
903
738
|
*/
|
|
904
|
-
async bulkCreate(accountId, campaignId,
|
|
739
|
+
async bulkCreate(accountId, campaignId, items) {
|
|
905
740
|
return this.http.post(
|
|
906
741
|
`${accountId}/campaigns/${campaignId}/items/mass`,
|
|
907
|
-
|
|
742
|
+
items
|
|
908
743
|
);
|
|
909
744
|
}
|
|
910
745
|
/**
|
|
911
746
|
* Bulk create items across multiple campaigns
|
|
912
747
|
*
|
|
748
|
+
* Unified endpoint that supports both static ads and motion ads.
|
|
749
|
+
*
|
|
913
750
|
* @param accountId - Account ID
|
|
914
751
|
* @param items - Array of items with campaign IDs
|
|
915
752
|
*
|
|
916
|
-
* @example
|
|
753
|
+
* @example Static ads
|
|
917
754
|
* ```typescript
|
|
918
755
|
* await client.items.bulkCreateAcrossCampaigns('my-account', [
|
|
919
|
-
* { campaign_id: '12345', url: '
|
|
920
|
-
* { campaign_id: '12346', url: '
|
|
756
|
+
* { campaign_id: '12345', url: 'https://example.com/1', title: 'Title 1' },
|
|
757
|
+
* { campaign_id: '12346', url: 'https://example.com/2', title: 'Title 2' },
|
|
758
|
+
* ]);
|
|
759
|
+
* ```
|
|
760
|
+
*
|
|
761
|
+
* @example Motion ads
|
|
762
|
+
* ```typescript
|
|
763
|
+
* await client.items.bulkCreateAcrossCampaigns('my-account', [
|
|
764
|
+
* {
|
|
765
|
+
* campaign_id: '12345',
|
|
766
|
+
* url: 'https://example.com/1',
|
|
767
|
+
* title: 'Motion Ad',
|
|
768
|
+
* performance_video_data: {
|
|
769
|
+
* video_url: 'https://example.com/video.mp4',
|
|
770
|
+
* fallback_url: 'https://example.com/fallback.jpg',
|
|
771
|
+
* },
|
|
772
|
+
* },
|
|
921
773
|
* ]);
|
|
922
774
|
* ```
|
|
923
775
|
*/
|
|
@@ -1021,15 +873,11 @@ var DictionaryAPI = class {
|
|
|
1021
873
|
* Get list of all supported countries
|
|
1022
874
|
*/
|
|
1023
875
|
async getCountries() {
|
|
1024
|
-
const response = await this.http.get(
|
|
1025
|
-
"resources/countries"
|
|
1026
|
-
);
|
|
876
|
+
const response = await this.http.get("resources/countries");
|
|
1027
877
|
return response.results;
|
|
1028
878
|
}
|
|
1029
879
|
/**
|
|
1030
880
|
* Get regions/states within a country
|
|
1031
|
-
*
|
|
1032
|
-
* @param countryCode - Country code (e.g., 'US', 'GB')
|
|
1033
881
|
*/
|
|
1034
882
|
async getRegions(countryCode) {
|
|
1035
883
|
const response = await this.http.get(
|
|
@@ -1039,9 +887,6 @@ var DictionaryAPI = class {
|
|
|
1039
887
|
}
|
|
1040
888
|
/**
|
|
1041
889
|
* Get DMAs (Designated Market Areas) for a country
|
|
1042
|
-
* Note: Only available for US
|
|
1043
|
-
*
|
|
1044
|
-
* @param countryCode - Country code (typically 'US')
|
|
1045
890
|
*/
|
|
1046
891
|
async getDMAs(countryCode) {
|
|
1047
892
|
const response = await this.http.get(
|
|
@@ -1051,9 +896,6 @@ var DictionaryAPI = class {
|
|
|
1051
896
|
}
|
|
1052
897
|
/**
|
|
1053
898
|
* Get postal codes for a country
|
|
1054
|
-
*
|
|
1055
|
-
* @param countryCode - Country code (e.g., 'US', 'GB')
|
|
1056
|
-
* @param params - Optional search and pagination parameters
|
|
1057
899
|
*/
|
|
1058
900
|
async getPostalCodes(countryCode, params) {
|
|
1059
901
|
const searchParams = new URLSearchParams();
|
|
@@ -1077,9 +919,7 @@ var DictionaryAPI = class {
|
|
|
1077
919
|
* Get list of supported platforms
|
|
1078
920
|
*/
|
|
1079
921
|
async getPlatforms() {
|
|
1080
|
-
const response = await this.http.get(
|
|
1081
|
-
"resources/platforms"
|
|
1082
|
-
);
|
|
922
|
+
const response = await this.http.get("resources/platforms");
|
|
1083
923
|
return response.results;
|
|
1084
924
|
}
|
|
1085
925
|
/**
|
|
@@ -1113,9 +953,7 @@ var DictionaryAPI = class {
|
|
|
1113
953
|
* Get list of supported browsers
|
|
1114
954
|
*/
|
|
1115
955
|
async getBrowsers() {
|
|
1116
|
-
const response = await this.http.get(
|
|
1117
|
-
"resources/browsers"
|
|
1118
|
-
);
|
|
956
|
+
const response = await this.http.get("resources/browsers");
|
|
1119
957
|
return response.results;
|
|
1120
958
|
}
|
|
1121
959
|
// ===== Enums =====
|
|
@@ -1135,9 +973,7 @@ var DictionaryAPI = class {
|
|
|
1135
973
|
* Get days of week for activity scheduling
|
|
1136
974
|
*/
|
|
1137
975
|
async getDaysOfWeek() {
|
|
1138
|
-
const response = await this.http.get(
|
|
1139
|
-
"resources/days-of-week"
|
|
1140
|
-
);
|
|
976
|
+
const response = await this.http.get("resources/days-of-week");
|
|
1141
977
|
return response.results;
|
|
1142
978
|
}
|
|
1143
979
|
// ===== Possible Values =====
|
|
@@ -1172,9 +1008,7 @@ var DictionaryAPI = class {
|
|
|
1172
1008
|
* Get minimum CPC values per country/platform
|
|
1173
1009
|
*/
|
|
1174
1010
|
async getMinimumCPCs() {
|
|
1175
|
-
const response = await this.http.get(
|
|
1176
|
-
"resources/minimum-cpc"
|
|
1177
|
-
);
|
|
1011
|
+
const response = await this.http.get("resources/minimum-cpc");
|
|
1178
1012
|
return response.results;
|
|
1179
1013
|
}
|
|
1180
1014
|
// ===== Image Library =====
|
|
@@ -1189,8 +1023,6 @@ var DictionaryAPI = class {
|
|
|
1189
1023
|
}
|
|
1190
1024
|
/**
|
|
1191
1025
|
* Get image taxonomies for categorizing images
|
|
1192
|
-
*
|
|
1193
|
-
* @param accountId - Account ID
|
|
1194
1026
|
*/
|
|
1195
1027
|
async getImageTaxonomies(accountId) {
|
|
1196
1028
|
const response = await this.http.get(
|
|
@@ -1201,58 +1033,46 @@ var DictionaryAPI = class {
|
|
|
1201
1033
|
// ===== Audience Targeting =====
|
|
1202
1034
|
/**
|
|
1203
1035
|
* Get marketplace audience segments available for targeting
|
|
1204
|
-
*
|
|
1205
|
-
* @param accountId - Account ID
|
|
1206
1036
|
*/
|
|
1207
1037
|
async getMarketplaceAudiences(accountId) {
|
|
1208
1038
|
const response = await this.http.get(
|
|
1209
|
-
`${accountId}/dictionary/
|
|
1039
|
+
`${accountId}/dictionary/audience_segments`
|
|
1210
1040
|
);
|
|
1211
1041
|
return response.results;
|
|
1212
1042
|
}
|
|
1213
1043
|
/**
|
|
1214
1044
|
* Get marketplace audience segments for a specific country
|
|
1215
|
-
*
|
|
1216
|
-
* @param accountId - Account ID
|
|
1217
|
-
* @param countryCode - Country code (e.g., 'US', 'GB')
|
|
1218
1045
|
*/
|
|
1219
1046
|
async getMarketplaceAudiencesByCountry(accountId, countryCode) {
|
|
1220
1047
|
const response = await this.http.get(
|
|
1221
|
-
`${accountId}/dictionary/
|
|
1048
|
+
`${accountId}/dictionary/audience_segments/${countryCode}`
|
|
1222
1049
|
);
|
|
1223
1050
|
return response.results;
|
|
1224
1051
|
}
|
|
1225
1052
|
/**
|
|
1226
1053
|
* Get lookalike audiences available for targeting
|
|
1227
|
-
*
|
|
1228
|
-
* @param accountId - Account ID
|
|
1229
1054
|
*/
|
|
1230
1055
|
async getLookalikeAudiences(accountId) {
|
|
1231
1056
|
const response = await this.http.get(
|
|
1232
|
-
`${accountId}/dictionary/
|
|
1057
|
+
`${accountId}/dictionary/lookalike_audiences`
|
|
1233
1058
|
);
|
|
1234
1059
|
return response.results;
|
|
1235
1060
|
}
|
|
1236
1061
|
/**
|
|
1237
1062
|
* Get lookalike audiences for a specific country
|
|
1238
|
-
*
|
|
1239
|
-
* @param accountId - Account ID
|
|
1240
|
-
* @param countryCode - Country code (e.g., 'US', 'GB')
|
|
1241
1063
|
*/
|
|
1242
1064
|
async getLookalikeAudiencesByCountry(accountId, countryCode) {
|
|
1243
1065
|
const response = await this.http.get(
|
|
1244
|
-
`${accountId}/dictionary/
|
|
1066
|
+
`${accountId}/dictionary/lookalike_audiences/${countryCode}`
|
|
1245
1067
|
);
|
|
1246
1068
|
return response.results;
|
|
1247
1069
|
}
|
|
1248
1070
|
/**
|
|
1249
1071
|
* Get contextual segments available for targeting
|
|
1250
|
-
*
|
|
1251
|
-
* @param accountId - Account ID
|
|
1252
1072
|
*/
|
|
1253
1073
|
async getContextualSegments(accountId) {
|
|
1254
1074
|
const response = await this.http.get(
|
|
1255
|
-
`${accountId}/dictionary/
|
|
1075
|
+
`${accountId}/dictionary/contextual_segments`
|
|
1256
1076
|
);
|
|
1257
1077
|
return response.results;
|
|
1258
1078
|
}
|
|
@@ -1265,116 +1085,55 @@ var PublishersAPI = class {
|
|
|
1265
1085
|
}
|
|
1266
1086
|
/**
|
|
1267
1087
|
* List all available publishers for an account
|
|
1268
|
-
*
|
|
1269
|
-
* @param accountId - Account ID
|
|
1270
|
-
* @returns List of publishers with blocking status
|
|
1271
|
-
*
|
|
1272
|
-
* @example
|
|
1273
|
-
* ```typescript
|
|
1274
|
-
* const publishers = await client.publishers.list('my-account');
|
|
1275
|
-
* console.log(`Found ${publishers.length} publishers`);
|
|
1276
|
-
* ```
|
|
1277
1088
|
*/
|
|
1278
1089
|
async list(accountId) {
|
|
1279
|
-
const response = await this.http.get(
|
|
1280
|
-
`${accountId}/publishers`
|
|
1281
|
-
);
|
|
1090
|
+
const response = await this.http.get(`${accountId}/allowed-publishers`);
|
|
1282
1091
|
return response.results;
|
|
1283
1092
|
}
|
|
1284
1093
|
/**
|
|
1285
1094
|
* Get blocked publishers at the account level
|
|
1286
|
-
*
|
|
1287
|
-
* @param accountId - Account ID
|
|
1288
|
-
* @returns List of blocked publishers
|
|
1289
|
-
*
|
|
1290
|
-
* @example
|
|
1291
|
-
* ```typescript
|
|
1292
|
-
* const blocked = await client.publishers.getBlocked('my-account');
|
|
1293
|
-
* console.log(`${blocked.length} publishers blocked at account level`);
|
|
1294
|
-
* ```
|
|
1295
1095
|
*/
|
|
1296
1096
|
async getBlocked(accountId) {
|
|
1297
|
-
const response = await this.http.get(
|
|
1298
|
-
|
|
1299
|
-
);
|
|
1300
|
-
if (Array.isArray(response)) {
|
|
1301
|
-
return response;
|
|
1302
|
-
}
|
|
1303
|
-
return response.results ?? [];
|
|
1097
|
+
const response = await this.http.get(`${accountId}/block-publisher`);
|
|
1098
|
+
return response.sites;
|
|
1304
1099
|
}
|
|
1305
1100
|
/**
|
|
1306
1101
|
* Update blocked publishers at the account level
|
|
1307
1102
|
*
|
|
1308
1103
|
* This replaces the current list of blocked publishers with the
|
|
1309
|
-
* provided list.
|
|
1310
|
-
* list and append.
|
|
1311
|
-
*
|
|
1312
|
-
* @param accountId - Account ID
|
|
1313
|
-
* @param sites - Array of site names to block
|
|
1314
|
-
* @returns Updated list of blocked publishers
|
|
1315
|
-
*
|
|
1316
|
-
* @example
|
|
1317
|
-
* ```typescript
|
|
1318
|
-
* // Block specific publishers
|
|
1319
|
-
* await client.publishers.updateBlocked('my-account', {
|
|
1320
|
-
* sites: ['site1.com', 'site2.com']
|
|
1321
|
-
* });
|
|
1322
|
-
*
|
|
1323
|
-
* // Add to existing blocks
|
|
1324
|
-
* const current = await client.publishers.getBlocked('my-account');
|
|
1325
|
-
* const currentSites = current.map(p => p.site);
|
|
1326
|
-
* await client.publishers.updateBlocked('my-account', {
|
|
1327
|
-
* sites: [...currentSites, 'newsite.com']
|
|
1328
|
-
* });
|
|
1329
|
-
* ```
|
|
1104
|
+
* provided list.
|
|
1330
1105
|
*/
|
|
1331
1106
|
async updateBlocked(accountId, request) {
|
|
1332
1107
|
const response = await this.http.post(
|
|
1333
1108
|
`${accountId}/block-publisher`,
|
|
1334
1109
|
request
|
|
1335
1110
|
);
|
|
1336
|
-
return response.
|
|
1111
|
+
return response.sites;
|
|
1337
1112
|
}
|
|
1338
1113
|
/**
|
|
1339
1114
|
* Block a single publisher at the account level
|
|
1340
|
-
*
|
|
1341
|
-
* Convenience method that adds a publisher to the existing block list.
|
|
1342
|
-
*
|
|
1343
|
-
* @param accountId - Account ID
|
|
1344
|
-
* @param site - Site name to block
|
|
1345
|
-
* @returns Updated list of blocked publishers
|
|
1346
1115
|
*/
|
|
1347
1116
|
async blockPublisher(accountId, site) {
|
|
1348
1117
|
const current = await this.getBlocked(accountId);
|
|
1349
|
-
|
|
1350
|
-
if (currentSites.includes(site)) {
|
|
1118
|
+
if (current.includes(site)) {
|
|
1351
1119
|
return current;
|
|
1352
1120
|
}
|
|
1353
1121
|
return this.updateBlocked(accountId, {
|
|
1354
|
-
sites: [...
|
|
1122
|
+
sites: [...current, site]
|
|
1355
1123
|
});
|
|
1356
1124
|
}
|
|
1357
1125
|
/**
|
|
1358
1126
|
* Unblock a single publisher at the account level
|
|
1359
|
-
*
|
|
1360
|
-
* Convenience method that removes a publisher from the block list.
|
|
1361
|
-
*
|
|
1362
|
-
* @param accountId - Account ID
|
|
1363
|
-
* @param site - Site name to unblock
|
|
1364
|
-
* @returns Updated list of blocked publishers
|
|
1365
1127
|
*/
|
|
1366
1128
|
async unblockPublisher(accountId, site) {
|
|
1367
1129
|
const current = await this.getBlocked(accountId);
|
|
1368
|
-
const filteredSites = current.
|
|
1130
|
+
const filteredSites = current.filter((s) => s !== site);
|
|
1369
1131
|
return this.updateBlocked(accountId, {
|
|
1370
1132
|
sites: filteredSites
|
|
1371
1133
|
});
|
|
1372
1134
|
}
|
|
1373
1135
|
/**
|
|
1374
1136
|
* Clear all blocked publishers at the account level
|
|
1375
|
-
*
|
|
1376
|
-
* @param accountId - Account ID
|
|
1377
|
-
* @returns Empty list
|
|
1378
1137
|
*/
|
|
1379
1138
|
async clearBlocked(accountId) {
|
|
1380
1139
|
return this.updateBlocked(accountId, { sites: [] });
|
|
@@ -1389,17 +1148,6 @@ var TargetingAPI = class {
|
|
|
1389
1148
|
// ===== Postal Code Targeting =====
|
|
1390
1149
|
/**
|
|
1391
1150
|
* Get postal code targeting for a campaign
|
|
1392
|
-
*
|
|
1393
|
-
* @param accountId - Account ID
|
|
1394
|
-
* @param campaignId - Campaign ID
|
|
1395
|
-
* @returns Postal code targeting configuration
|
|
1396
|
-
*
|
|
1397
|
-
* @example
|
|
1398
|
-
* ```typescript
|
|
1399
|
-
* const targeting = await client.targeting.getPostalCodes('my-account', '12345');
|
|
1400
|
-
* console.log(`Targeting type: ${targeting.type}`);
|
|
1401
|
-
* console.log(`Postal codes: ${targeting.values.length}`);
|
|
1402
|
-
* ```
|
|
1403
1151
|
*/
|
|
1404
1152
|
async getPostalCodes(accountId, campaignId) {
|
|
1405
1153
|
return this.http.get(
|
|
@@ -1408,22 +1156,6 @@ var TargetingAPI = class {
|
|
|
1408
1156
|
}
|
|
1409
1157
|
/**
|
|
1410
1158
|
* Update postal code targeting for a campaign
|
|
1411
|
-
*
|
|
1412
|
-
* @param accountId - Account ID
|
|
1413
|
-
* @param campaignId - Campaign ID
|
|
1414
|
-
* @param targeting - Postal code targeting configuration
|
|
1415
|
-
* @returns Updated targeting configuration
|
|
1416
|
-
*
|
|
1417
|
-
* @example
|
|
1418
|
-
* ```typescript
|
|
1419
|
-
* await client.targeting.updatePostalCodes('my-account', '12345', {
|
|
1420
|
-
* type: 'INCLUDE',
|
|
1421
|
-
* values: [
|
|
1422
|
-
* { postal_code: '10001', country: 'US' },
|
|
1423
|
-
* { postal_code: '10002', country: 'US' },
|
|
1424
|
-
* ]
|
|
1425
|
-
* });
|
|
1426
|
-
* ```
|
|
1427
1159
|
*/
|
|
1428
1160
|
async updatePostalCodes(accountId, campaignId, targeting) {
|
|
1429
1161
|
return this.http.post(
|
|
@@ -1434,13 +1166,6 @@ var TargetingAPI = class {
|
|
|
1434
1166
|
// ===== Marketplace Audience Targeting =====
|
|
1435
1167
|
/**
|
|
1436
1168
|
* Get marketplace audience targeting for a campaign
|
|
1437
|
-
*
|
|
1438
|
-
* Marketplace audiences are third-party audience segments
|
|
1439
|
-
* available for targeting through Taboola's marketplace.
|
|
1440
|
-
*
|
|
1441
|
-
* @param accountId - Account ID
|
|
1442
|
-
* @param campaignId - Campaign ID
|
|
1443
|
-
* @returns Audience targeting configuration
|
|
1444
1169
|
*/
|
|
1445
1170
|
async getMarketplaceAudiences(accountId, campaignId) {
|
|
1446
1171
|
return this.http.get(
|
|
@@ -1449,22 +1174,6 @@ var TargetingAPI = class {
|
|
|
1449
1174
|
}
|
|
1450
1175
|
/**
|
|
1451
1176
|
* Update marketplace audience targeting for a campaign
|
|
1452
|
-
*
|
|
1453
|
-
* @param accountId - Account ID
|
|
1454
|
-
* @param campaignId - Campaign ID
|
|
1455
|
-
* @param targeting - Audience targeting configuration
|
|
1456
|
-
* @returns Updated targeting configuration
|
|
1457
|
-
*
|
|
1458
|
-
* @example
|
|
1459
|
-
* ```typescript
|
|
1460
|
-
* await client.targeting.updateMarketplaceAudiences('my-account', '12345', {
|
|
1461
|
-
* type: 'INCLUDE',
|
|
1462
|
-
* collection: [
|
|
1463
|
-
* { id: 'segment-1', name: null },
|
|
1464
|
-
* { id: 'segment-2', name: null },
|
|
1465
|
-
* ]
|
|
1466
|
-
* });
|
|
1467
|
-
* ```
|
|
1468
1177
|
*/
|
|
1469
1178
|
async updateMarketplaceAudiences(accountId, campaignId, targeting) {
|
|
1470
1179
|
return this.http.post(
|
|
@@ -1475,13 +1184,6 @@ var TargetingAPI = class {
|
|
|
1475
1184
|
// ===== Custom Audience Targeting =====
|
|
1476
1185
|
/**
|
|
1477
1186
|
* Get custom audience targeting for a campaign
|
|
1478
|
-
*
|
|
1479
|
-
* Custom audiences are audiences created from pixel data
|
|
1480
|
-
* or uploaded lists.
|
|
1481
|
-
*
|
|
1482
|
-
* @param accountId - Account ID
|
|
1483
|
-
* @param campaignId - Campaign ID
|
|
1484
|
-
* @returns Audience targeting configuration
|
|
1485
1187
|
*/
|
|
1486
1188
|
async getCustomAudiences(accountId, campaignId) {
|
|
1487
1189
|
return this.http.get(
|
|
@@ -1490,11 +1192,6 @@ var TargetingAPI = class {
|
|
|
1490
1192
|
}
|
|
1491
1193
|
/**
|
|
1492
1194
|
* Update custom audience targeting for a campaign
|
|
1493
|
-
*
|
|
1494
|
-
* @param accountId - Account ID
|
|
1495
|
-
* @param campaignId - Campaign ID
|
|
1496
|
-
* @param targeting - Audience targeting configuration
|
|
1497
|
-
* @returns Updated targeting configuration
|
|
1498
1195
|
*/
|
|
1499
1196
|
async updateCustomAudiences(accountId, campaignId, targeting) {
|
|
1500
1197
|
return this.http.post(
|
|
@@ -1505,13 +1202,6 @@ var TargetingAPI = class {
|
|
|
1505
1202
|
// ===== Lookalike Audience Targeting =====
|
|
1506
1203
|
/**
|
|
1507
1204
|
* Get lookalike audience targeting for a campaign
|
|
1508
|
-
*
|
|
1509
|
-
* Lookalike audiences are modeled after your existing
|
|
1510
|
-
* custom audiences to find similar users.
|
|
1511
|
-
*
|
|
1512
|
-
* @param accountId - Account ID
|
|
1513
|
-
* @param campaignId - Campaign ID
|
|
1514
|
-
* @returns Audience targeting configuration
|
|
1515
1205
|
*/
|
|
1516
1206
|
async getLookalikeAudiences(accountId, campaignId) {
|
|
1517
1207
|
return this.http.get(
|
|
@@ -1520,11 +1210,6 @@ var TargetingAPI = class {
|
|
|
1520
1210
|
}
|
|
1521
1211
|
/**
|
|
1522
1212
|
* Update lookalike audience targeting for a campaign
|
|
1523
|
-
*
|
|
1524
|
-
* @param accountId - Account ID
|
|
1525
|
-
* @param campaignId - Campaign ID
|
|
1526
|
-
* @param targeting - Audience targeting configuration
|
|
1527
|
-
* @returns Updated targeting configuration
|
|
1528
1213
|
*/
|
|
1529
1214
|
async updateLookalikeAudiences(accountId, campaignId, targeting) {
|
|
1530
1215
|
return this.http.post(
|
|
@@ -1535,13 +1220,6 @@ var TargetingAPI = class {
|
|
|
1535
1220
|
// ===== Contextual Targeting =====
|
|
1536
1221
|
/**
|
|
1537
1222
|
* Get contextual targeting for a campaign
|
|
1538
|
-
*
|
|
1539
|
-
* Contextual targeting allows you to target based on the
|
|
1540
|
-
* content of the pages where your ads appear.
|
|
1541
|
-
*
|
|
1542
|
-
* @param accountId - Account ID
|
|
1543
|
-
* @param campaignId - Campaign ID
|
|
1544
|
-
* @returns Contextual targeting configuration
|
|
1545
1223
|
*/
|
|
1546
1224
|
async getContextual(accountId, campaignId) {
|
|
1547
1225
|
return this.http.get(
|
|
@@ -1550,22 +1228,6 @@ var TargetingAPI = class {
|
|
|
1550
1228
|
}
|
|
1551
1229
|
/**
|
|
1552
1230
|
* Update contextual targeting for a campaign
|
|
1553
|
-
*
|
|
1554
|
-
* @param accountId - Account ID
|
|
1555
|
-
* @param campaignId - Campaign ID
|
|
1556
|
-
* @param targeting - Contextual targeting configuration
|
|
1557
|
-
* @returns Updated targeting configuration
|
|
1558
|
-
*
|
|
1559
|
-
* @example
|
|
1560
|
-
* ```typescript
|
|
1561
|
-
* await client.targeting.updateContextual('my-account', '12345', {
|
|
1562
|
-
* type: 'INCLUDE',
|
|
1563
|
-
* collection: [
|
|
1564
|
-
* { id: 'context-1', name: null },
|
|
1565
|
-
* { id: 'context-2', name: null },
|
|
1566
|
-
* ]
|
|
1567
|
-
* });
|
|
1568
|
-
* ```
|
|
1569
1231
|
*/
|
|
1570
1232
|
async updateContextual(accountId, campaignId, targeting) {
|
|
1571
1233
|
return this.http.post(
|
|
@@ -1576,12 +1238,6 @@ var TargetingAPI = class {
|
|
|
1576
1238
|
// ===== First Party Audience Targeting =====
|
|
1577
1239
|
/**
|
|
1578
1240
|
* Get first party audience targeting for a campaign
|
|
1579
|
-
*
|
|
1580
|
-
* First party audiences are your own uploaded audience data.
|
|
1581
|
-
*
|
|
1582
|
-
* @param accountId - Account ID
|
|
1583
|
-
* @param campaignId - Campaign ID
|
|
1584
|
-
* @returns First party audience targeting configuration
|
|
1585
1241
|
*/
|
|
1586
1242
|
async getFirstPartyAudiences(accountId, campaignId) {
|
|
1587
1243
|
return this.http.get(
|
|
@@ -1590,11 +1246,6 @@ var TargetingAPI = class {
|
|
|
1590
1246
|
}
|
|
1591
1247
|
/**
|
|
1592
1248
|
* Update first party audience targeting for a campaign
|
|
1593
|
-
*
|
|
1594
|
-
* @param accountId - Account ID
|
|
1595
|
-
* @param campaignId - Campaign ID
|
|
1596
|
-
* @param targeting - First party audience targeting configuration
|
|
1597
|
-
* @returns Updated targeting configuration
|
|
1598
1249
|
*/
|
|
1599
1250
|
async updateFirstPartyAudiences(accountId, campaignId, targeting) {
|
|
1600
1251
|
return this.http.post(
|
|
@@ -1605,19 +1256,6 @@ var TargetingAPI = class {
|
|
|
1605
1256
|
// ===== Marking Labels Targeting =====
|
|
1606
1257
|
/**
|
|
1607
1258
|
* Get marking labels (pixel retargeting) targeting for a campaign
|
|
1608
|
-
*
|
|
1609
|
-
* Marking labels allow you to target users based on pixel-tracked
|
|
1610
|
-
* behavior using custom labels.
|
|
1611
|
-
*
|
|
1612
|
-
* @param accountId - Account ID
|
|
1613
|
-
* @param campaignId - Campaign ID
|
|
1614
|
-
* @returns Marking labels targeting configuration
|
|
1615
|
-
*
|
|
1616
|
-
* @example
|
|
1617
|
-
* ```typescript
|
|
1618
|
-
* const targeting = await client.targeting.getMarkingLabels('my-account', '12345');
|
|
1619
|
-
* console.log('Labels:', targeting.collection);
|
|
1620
|
-
* ```
|
|
1621
1259
|
*/
|
|
1622
1260
|
async getMarkingLabels(accountId, campaignId) {
|
|
1623
1261
|
return this.http.get(
|
|
@@ -1626,19 +1264,6 @@ var TargetingAPI = class {
|
|
|
1626
1264
|
}
|
|
1627
1265
|
/**
|
|
1628
1266
|
* Update marking labels targeting for a campaign
|
|
1629
|
-
*
|
|
1630
|
-
* @param accountId - Account ID
|
|
1631
|
-
* @param campaignId - Campaign ID
|
|
1632
|
-
* @param targeting - Marking labels targeting configuration
|
|
1633
|
-
* @returns Updated targeting configuration
|
|
1634
|
-
*
|
|
1635
|
-
* @example
|
|
1636
|
-
* ```typescript
|
|
1637
|
-
* await client.targeting.updateMarkingLabels('my-account', '12345', {
|
|
1638
|
-
* type: 'EXISTS',
|
|
1639
|
-
* collection: ['label-1', 'label-2'],
|
|
1640
|
-
* });
|
|
1641
|
-
* ```
|
|
1642
1267
|
*/
|
|
1643
1268
|
async updateMarkingLabels(accountId, campaignId, targeting) {
|
|
1644
1269
|
return this.http.post(
|
|
@@ -1655,105 +1280,40 @@ var CombinedAudiencesAPI = class {
|
|
|
1655
1280
|
}
|
|
1656
1281
|
/**
|
|
1657
1282
|
* List available audiences for combining
|
|
1658
|
-
*
|
|
1659
|
-
* Returns all audiences that can be used in combined audience rules,
|
|
1660
|
-
* including custom, lookalike, marketplace, and first-party audiences.
|
|
1661
|
-
*
|
|
1662
|
-
* @param accountId - Account ID
|
|
1663
|
-
* @returns List of available audiences
|
|
1664
|
-
*
|
|
1665
|
-
* @example
|
|
1666
|
-
* ```typescript
|
|
1667
|
-
* const available = await client.combinedAudiences.listAvailable('my-account');
|
|
1668
|
-
* console.log(`${available.length} audiences available for combining`);
|
|
1669
|
-
* ```
|
|
1670
1283
|
*/
|
|
1671
1284
|
async listAvailable(accountId) {
|
|
1672
1285
|
const response = await this.http.get(
|
|
1673
|
-
`${accountId}/
|
|
1286
|
+
`${accountId}/combined_audiences/resources/audiences`
|
|
1674
1287
|
);
|
|
1675
1288
|
return response.results;
|
|
1676
1289
|
}
|
|
1677
1290
|
/**
|
|
1678
1291
|
* List all combined audiences
|
|
1679
|
-
*
|
|
1680
|
-
* @param accountId - Account ID
|
|
1681
|
-
* @returns List of combined audiences
|
|
1682
|
-
*
|
|
1683
|
-
* @example
|
|
1684
|
-
* ```typescript
|
|
1685
|
-
* const audiences = await client.combinedAudiences.list('my-account');
|
|
1686
|
-
* for (const audience of audiences) {
|
|
1687
|
-
* console.log(`${audience.name}: ${audience.status}`);
|
|
1688
|
-
* }
|
|
1689
|
-
* ```
|
|
1690
1292
|
*/
|
|
1691
1293
|
async list(accountId) {
|
|
1692
1294
|
const response = await this.http.get(
|
|
1693
|
-
`${accountId}/
|
|
1295
|
+
`${accountId}/combined_audiences`
|
|
1694
1296
|
);
|
|
1695
1297
|
return response.results;
|
|
1696
1298
|
}
|
|
1697
1299
|
/**
|
|
1698
1300
|
* Get a single combined audience
|
|
1699
|
-
*
|
|
1700
|
-
* @param accountId - Account ID
|
|
1701
|
-
* @param audienceId - Combined audience ID
|
|
1702
|
-
* @returns Combined audience details
|
|
1703
1301
|
*/
|
|
1704
1302
|
async get(accountId, audienceId) {
|
|
1705
|
-
return this.http.get(
|
|
1706
|
-
`${accountId}/combined-audiences/${audienceId}`
|
|
1707
|
-
);
|
|
1303
|
+
return this.http.get(`${accountId}/combined_audiences/${audienceId}`);
|
|
1708
1304
|
}
|
|
1709
1305
|
/**
|
|
1710
1306
|
* Create a combined audience
|
|
1711
|
-
*
|
|
1712
|
-
* @param accountId - Account ID
|
|
1713
|
-
* @param audience - Combined audience configuration
|
|
1714
|
-
* @returns Created combined audience
|
|
1715
|
-
*
|
|
1716
|
-
* @example
|
|
1717
|
-
* ```typescript
|
|
1718
|
-
* const audience = await client.combinedAudiences.create('my-account', {
|
|
1719
|
-
* name: 'High-Value Engaged Users',
|
|
1720
|
-
* description: 'Users who are both high-value and engaged',
|
|
1721
|
-
* include_rules: [
|
|
1722
|
-
* {
|
|
1723
|
-
* audience_type: 'CUSTOM_AUDIENCE',
|
|
1724
|
-
* audiences: [{ id: 'custom-1', name: null }]
|
|
1725
|
-
* },
|
|
1726
|
-
* {
|
|
1727
|
-
* audience_type: 'LOOKALIKE_AUDIENCE',
|
|
1728
|
-
* audiences: [{ id: 'lookalike-1', name: null }]
|
|
1729
|
-
* }
|
|
1730
|
-
* ],
|
|
1731
|
-
* exclude_rules: [
|
|
1732
|
-
* {
|
|
1733
|
-
* audience_type: 'CUSTOM_AUDIENCE',
|
|
1734
|
-
* audiences: [{ id: 'converters', name: null }]
|
|
1735
|
-
* }
|
|
1736
|
-
* ]
|
|
1737
|
-
* });
|
|
1738
|
-
* ```
|
|
1739
1307
|
*/
|
|
1740
1308
|
async create(accountId, audience) {
|
|
1741
|
-
return this.http.post(
|
|
1742
|
-
`${accountId}/combined-audiences`,
|
|
1743
|
-
audience
|
|
1744
|
-
);
|
|
1309
|
+
return this.http.post(`${accountId}/combined_audiences`, audience);
|
|
1745
1310
|
}
|
|
1746
1311
|
/**
|
|
1747
1312
|
* Update a combined audience
|
|
1748
|
-
*
|
|
1749
|
-
* @param accountId - Account ID
|
|
1750
|
-
* @param audienceId - Combined audience ID
|
|
1751
|
-
* @param updates - Fields to update
|
|
1752
|
-
* @returns Updated combined audience
|
|
1753
1313
|
*/
|
|
1754
1314
|
async update(accountId, audienceId, updates) {
|
|
1755
1315
|
return this.http.post(
|
|
1756
|
-
`${accountId}/
|
|
1316
|
+
`${accountId}/combined_audiences/${audienceId}`,
|
|
1757
1317
|
updates
|
|
1758
1318
|
);
|
|
1759
1319
|
}
|
|
@@ -1766,118 +1326,32 @@ var FirstPartyAudiencesAPI = class {
|
|
|
1766
1326
|
}
|
|
1767
1327
|
/**
|
|
1768
1328
|
* List all first party audiences
|
|
1769
|
-
*
|
|
1770
|
-
* @param accountId - Account ID
|
|
1771
|
-
* @returns List of first party audiences
|
|
1772
|
-
*
|
|
1773
|
-
* @example
|
|
1774
|
-
* ```typescript
|
|
1775
|
-
* const audiences = await client.firstPartyAudiences.list('my-account');
|
|
1776
|
-
* for (const audience of audiences) {
|
|
1777
|
-
* console.log(`${audience.name}: ${audience.status} (${audience.size} users)`);
|
|
1778
|
-
* }
|
|
1779
|
-
* ```
|
|
1780
1329
|
*/
|
|
1781
1330
|
async list(accountId) {
|
|
1782
1331
|
const response = await this.http.get(
|
|
1783
|
-
`${accountId}/
|
|
1332
|
+
`${accountId}/audience_onboarding/my_audiences`
|
|
1784
1333
|
);
|
|
1785
1334
|
return response.results;
|
|
1786
1335
|
}
|
|
1787
1336
|
/**
|
|
1788
1337
|
* Get a single first party audience
|
|
1789
|
-
*
|
|
1790
|
-
* @param accountId - Account ID
|
|
1791
|
-
* @param audienceId - Audience ID
|
|
1792
|
-
* @returns First party audience details
|
|
1793
1338
|
*/
|
|
1794
1339
|
async get(accountId, audienceId) {
|
|
1795
1340
|
return this.http.get(
|
|
1796
|
-
`${accountId}/
|
|
1341
|
+
`${accountId}/audience_onboarding/my_audiences/${audienceId}`
|
|
1797
1342
|
);
|
|
1798
1343
|
}
|
|
1799
1344
|
/**
|
|
1800
1345
|
* Create a first party audience
|
|
1801
|
-
*
|
|
1802
|
-
* After creation, use addUsers() to populate the audience with identifiers.
|
|
1803
|
-
*
|
|
1804
|
-
* @param accountId - Account ID
|
|
1805
|
-
* @param audience - Audience configuration
|
|
1806
|
-
* @returns Created audience
|
|
1807
|
-
*
|
|
1808
|
-
* @example
|
|
1809
|
-
* ```typescript
|
|
1810
|
-
* const audience = await client.firstPartyAudiences.create('my-account', {
|
|
1811
|
-
* name: 'High-Value Customers',
|
|
1812
|
-
* description: 'Customers with LTV > $1000',
|
|
1813
|
-
* source_type: 'CRM',
|
|
1814
|
-
* ttl_days: 90
|
|
1815
|
-
* });
|
|
1816
|
-
*
|
|
1817
|
-
* // Then add users
|
|
1818
|
-
* await client.firstPartyAudiences.addUsers('my-account', audience.id, {
|
|
1819
|
-
* add: [
|
|
1820
|
-
* { identifier_type: 'EMAIL_SHA256', identifier_value: 'sha256hash1' },
|
|
1821
|
-
* { identifier_type: 'EMAIL_SHA256', identifier_value: 'sha256hash2' },
|
|
1822
|
-
* ]
|
|
1823
|
-
* });
|
|
1824
|
-
* ```
|
|
1825
1346
|
*/
|
|
1826
1347
|
async create(accountId, audience) {
|
|
1827
|
-
return this.http.post(
|
|
1828
|
-
`${accountId}/audience-onboarding/first-party-audiences`,
|
|
1829
|
-
audience
|
|
1830
|
-
);
|
|
1348
|
+
return this.http.post(`${accountId}/audience_onboarding/create`, audience);
|
|
1831
1349
|
}
|
|
1832
1350
|
/**
|
|
1833
1351
|
* Add or remove users from a first party audience
|
|
1834
|
-
*
|
|
1835
|
-
* Users are identified by hashed identifiers (email, phone, device ID).
|
|
1836
|
-
* It's recommended to use SHA256 hashed values for privacy.
|
|
1837
|
-
*
|
|
1838
|
-
* @param accountId - Account ID
|
|
1839
|
-
* @param audienceId - Audience ID
|
|
1840
|
-
* @param request - Add/remove request with user identifiers
|
|
1841
|
-
* @returns Operation result with counts
|
|
1842
|
-
*
|
|
1843
|
-
* @example
|
|
1844
|
-
* ```typescript
|
|
1845
|
-
* // Add users
|
|
1846
|
-
* const result = await client.firstPartyAudiences.addUsers('my-account', 'audience-1', {
|
|
1847
|
-
* add: [
|
|
1848
|
-
* { identifier_type: 'EMAIL_SHA256', identifier_value: 'sha256hash1' },
|
|
1849
|
-
* { identifier_type: 'EMAIL_SHA256', identifier_value: 'sha256hash2' },
|
|
1850
|
-
* ]
|
|
1851
|
-
* });
|
|
1852
|
-
* console.log(`Added ${result.added_count} users`);
|
|
1853
|
-
*
|
|
1854
|
-
* // Remove users
|
|
1855
|
-
* const result2 = await client.firstPartyAudiences.addUsers('my-account', 'audience-1', {
|
|
1856
|
-
* remove: [
|
|
1857
|
-
* { identifier_type: 'EMAIL_SHA256', identifier_value: 'sha256hash3' },
|
|
1858
|
-
* ]
|
|
1859
|
-
* });
|
|
1860
|
-
* console.log(`Removed ${result2.removed_count} users`);
|
|
1861
|
-
* ```
|
|
1862
|
-
*/
|
|
1863
|
-
async addUsers(accountId, audienceId, request) {
|
|
1864
|
-
return this.http.post(
|
|
1865
|
-
`${accountId}/audience-onboarding/first-party-audiences/${audienceId}/add-remove`,
|
|
1866
|
-
request
|
|
1867
|
-
);
|
|
1868
|
-
}
|
|
1869
|
-
/**
|
|
1870
|
-
* Remove users from a first party audience
|
|
1871
|
-
*
|
|
1872
|
-
* Convenience method that wraps addUsers with only remove operations.
|
|
1873
|
-
*
|
|
1874
|
-
* @param accountId - Account ID
|
|
1875
|
-
* @param audienceId - Audience ID
|
|
1876
|
-
* @param request - Remove request with user identifiers
|
|
1877
|
-
* @returns Operation result with counts
|
|
1878
1352
|
*/
|
|
1879
|
-
async
|
|
1880
|
-
|
|
1353
|
+
async manageUsers(accountId, request) {
|
|
1354
|
+
await this.http.post(`${accountId}/audience_onboarding/my_audiences/users`, request);
|
|
1881
1355
|
}
|
|
1882
1356
|
};
|
|
1883
1357
|
|
|
@@ -1916,7 +1390,7 @@ var PixelAPI = class {
|
|
|
1916
1390
|
*/
|
|
1917
1391
|
async getConversionRule(accountId, ruleId) {
|
|
1918
1392
|
return this.http.get(
|
|
1919
|
-
`${accountId}/universal_pixel/conversion_rule/${ruleId}`
|
|
1393
|
+
`${accountId}/universal_pixel/conversion_rule/${String(ruleId)}`
|
|
1920
1394
|
);
|
|
1921
1395
|
}
|
|
1922
1396
|
/**
|
|
@@ -1946,23 +1420,17 @@ var PixelAPI = class {
|
|
|
1946
1420
|
* // URL-based conversion rule
|
|
1947
1421
|
* const rule = await client.pixel.createConversionRule('my-account', {
|
|
1948
1422
|
* display_name: 'Purchase Completed',
|
|
1949
|
-
* type: '
|
|
1950
|
-
* category: '
|
|
1951
|
-
*
|
|
1952
|
-
*
|
|
1953
|
-
*
|
|
1954
|
-
*
|
|
1955
|
-
*
|
|
1956
|
-
* }
|
|
1957
|
-
* ],
|
|
1958
|
-
* effect: {
|
|
1959
|
-
* type: 'DYNAMIC_VALUE',
|
|
1960
|
-
* value: null,
|
|
1961
|
-
* currency: 'USD',
|
|
1962
|
-
* value_parameter: 'order_total'
|
|
1423
|
+
* type: 'BASIC',
|
|
1424
|
+
* category: 'MAKE_PURCHASE',
|
|
1425
|
+
* condition: {
|
|
1426
|
+
* property: 'URL',
|
|
1427
|
+
* predicate: 'CONTAINS',
|
|
1428
|
+
* value: '/thank-you',
|
|
1429
|
+
* children: [],
|
|
1963
1430
|
* },
|
|
1964
|
-
*
|
|
1965
|
-
*
|
|
1431
|
+
* effects: [{ type: 'REVENUE', data: '15' }],
|
|
1432
|
+
* look_back_window: 30,
|
|
1433
|
+
* view_through_look_back_window: 1,
|
|
1966
1434
|
* });
|
|
1967
1435
|
*
|
|
1968
1436
|
* // Event-based conversion rule
|
|
@@ -1971,21 +1439,12 @@ var PixelAPI = class {
|
|
|
1971
1439
|
* type: 'EVENT_BASED',
|
|
1972
1440
|
* category: 'ADD_TO_CART',
|
|
1973
1441
|
* event_name: 'add_to_cart',
|
|
1974
|
-
*
|
|
1975
|
-
* effect: {
|
|
1976
|
-
* type: 'FIXED_VALUE',
|
|
1977
|
-
* value: 10,
|
|
1978
|
-
* currency: 'USD',
|
|
1979
|
-
* value_parameter: null
|
|
1980
|
-
* }
|
|
1442
|
+
* effects: [{ type: 'REVENUE', data: '10' }],
|
|
1981
1443
|
* });
|
|
1982
1444
|
* ```
|
|
1983
1445
|
*/
|
|
1984
1446
|
async createConversionRule(accountId, rule) {
|
|
1985
|
-
return this.http.post(
|
|
1986
|
-
`${accountId}/universal_pixel/conversion_rule`,
|
|
1987
|
-
rule
|
|
1988
|
-
);
|
|
1447
|
+
return this.http.post(`${accountId}/universal_pixel/conversion_rule`, rule);
|
|
1989
1448
|
}
|
|
1990
1449
|
/**
|
|
1991
1450
|
* Update a conversion rule
|
|
@@ -1997,7 +1456,7 @@ var PixelAPI = class {
|
|
|
1997
1456
|
*/
|
|
1998
1457
|
async updateConversionRule(accountId, ruleId, updates) {
|
|
1999
1458
|
return this.http.post(
|
|
2000
|
-
`${accountId}/universal_pixel/conversion_rule/${ruleId}`,
|
|
1459
|
+
`${accountId}/universal_pixel/conversion_rule/${String(ruleId)}`,
|
|
2001
1460
|
updates
|
|
2002
1461
|
);
|
|
2003
1462
|
}
|
|
@@ -2071,37 +1530,16 @@ var PixelAPI = class {
|
|
|
2071
1530
|
*
|
|
2072
1531
|
* @example
|
|
2073
1532
|
* ```typescript
|
|
2074
|
-
* // All visitors audience
|
|
2075
1533
|
* const allVisitors = await client.pixel.createCustomAudienceRule('my-account', {
|
|
2076
1534
|
* display_name: 'All Visitors - 30 Days',
|
|
2077
1535
|
* conditions: [],
|
|
2078
|
-
* ttl_days: 30
|
|
1536
|
+
* ttl_days: 30,
|
|
2079
1537
|
* });
|
|
2080
1538
|
*
|
|
2081
|
-
* // Product page visitors
|
|
2082
1539
|
* const productViewers = await client.pixel.createCustomAudienceRule('my-account', {
|
|
2083
1540
|
* display_name: 'Product Page Viewers',
|
|
2084
|
-
* conditions: [
|
|
2085
|
-
*
|
|
2086
|
-
* type: 'URL',
|
|
2087
|
-
* operator: 'CONTAINS',
|
|
2088
|
-
* value: '/products/'
|
|
2089
|
-
* }
|
|
2090
|
-
* ],
|
|
2091
|
-
* ttl_days: 14
|
|
2092
|
-
* });
|
|
2093
|
-
*
|
|
2094
|
-
* // Cart abandoners
|
|
2095
|
-
* const cartAbandoners = await client.pixel.createCustomAudienceRule('my-account', {
|
|
2096
|
-
* display_name: 'Cart Abandoners',
|
|
2097
|
-
* conditions: [
|
|
2098
|
-
* {
|
|
2099
|
-
* type: 'EVENT_NAME',
|
|
2100
|
-
* operator: 'EQUALS',
|
|
2101
|
-
* value: 'add_to_cart'
|
|
2102
|
-
* }
|
|
2103
|
-
* ],
|
|
2104
|
-
* ttl_days: 7
|
|
1541
|
+
* conditions: [{ type: 'URL', operator: 'CONTAINS', value: '/products/' }],
|
|
1542
|
+
* ttl_days: 14,
|
|
2105
1543
|
* });
|
|
2106
1544
|
* ```
|
|
2107
1545
|
*/
|
|
@@ -2398,9 +1836,7 @@ var SharedBudgetAPI = class {
|
|
|
2398
1836
|
* ```
|
|
2399
1837
|
*/
|
|
2400
1838
|
async get(accountId, sharedBudgetId) {
|
|
2401
|
-
return this.http.get(
|
|
2402
|
-
`${accountId}/shared-budget/${sharedBudgetId}`
|
|
2403
|
-
);
|
|
1839
|
+
return this.http.get(`${accountId}/shared-budget/${sharedBudgetId}`);
|
|
2404
1840
|
}
|
|
2405
1841
|
/**
|
|
2406
1842
|
* List all shared budgets (base/partial fields)
|
|
@@ -2418,9 +1854,7 @@ var SharedBudgetAPI = class {
|
|
|
2418
1854
|
* ```
|
|
2419
1855
|
*/
|
|
2420
1856
|
async listBase(accountId) {
|
|
2421
|
-
return this.http.get(
|
|
2422
|
-
`${accountId}/shared-budget/base`
|
|
2423
|
-
);
|
|
1857
|
+
return this.http.get(`${accountId}/shared-budget/base`);
|
|
2424
1858
|
}
|
|
2425
1859
|
/**
|
|
2426
1860
|
* Create a new shared budget
|
|
@@ -2441,10 +1875,7 @@ var SharedBudgetAPI = class {
|
|
|
2441
1875
|
* ```
|
|
2442
1876
|
*/
|
|
2443
1877
|
async create(accountId, budget) {
|
|
2444
|
-
return this.http.post(
|
|
2445
|
-
`${accountId}/shared-budget`,
|
|
2446
|
-
budget
|
|
2447
|
-
);
|
|
1878
|
+
return this.http.post(`${accountId}/shared-budget`, budget);
|
|
2448
1879
|
}
|
|
2449
1880
|
/**
|
|
2450
1881
|
* Update an existing shared budget
|
|
@@ -2462,10 +1893,7 @@ var SharedBudgetAPI = class {
|
|
|
2462
1893
|
* ```
|
|
2463
1894
|
*/
|
|
2464
1895
|
async update(accountId, sharedBudgetId, updates) {
|
|
2465
|
-
return this.http.put(
|
|
2466
|
-
`${accountId}/shared-budget/${sharedBudgetId}`,
|
|
2467
|
-
updates
|
|
2468
|
-
);
|
|
1896
|
+
return this.http.put(`${accountId}/shared-budget/${sharedBudgetId}`, updates);
|
|
2469
1897
|
}
|
|
2470
1898
|
};
|
|
2471
1899
|
|