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