taboola-backstage-sdk 0.2.1 → 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 +36 -20
- package/dist/index.cjs +129 -648
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +549 -830
- package/dist/index.d.ts +549 -830
- package/dist/index.js +129 -648
- 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,88 +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
|
-
* @param accountId - Account ID
|
|
523
|
-
* @param campaignId - Campaign ID
|
|
524
|
-
* @param updates - Fields to update
|
|
525
|
-
*
|
|
526
|
-
* @example
|
|
527
|
-
* ```typescript
|
|
528
|
-
* const campaign = await client.campaigns.update('my-account', '12345', {
|
|
529
|
-
* cpc: 0.75,
|
|
530
|
-
* daily_cap: 500,
|
|
531
|
-
* });
|
|
532
|
-
* ```
|
|
533
474
|
*/
|
|
534
475
|
async update(accountId, campaignId, updates) {
|
|
535
476
|
return this.http.post(`${accountId}/campaigns/${campaignId}`, updates);
|
|
536
477
|
}
|
|
537
478
|
/**
|
|
538
479
|
* Delete a campaign
|
|
539
|
-
*
|
|
540
|
-
* @param accountId - Account ID
|
|
541
|
-
* @param campaignId - Campaign ID
|
|
542
|
-
*
|
|
543
|
-
* @example
|
|
544
|
-
* ```typescript
|
|
545
|
-
* await client.campaigns.delete('my-account', '12345');
|
|
546
|
-
* ```
|
|
547
480
|
*/
|
|
548
481
|
async delete(accountId, campaignId) {
|
|
549
482
|
await this.http.delete(`${accountId}/campaigns/${campaignId}`);
|
|
@@ -551,122 +484,58 @@ var CampaignsAPI = class {
|
|
|
551
484
|
/**
|
|
552
485
|
* Duplicate a campaign
|
|
553
486
|
*
|
|
554
|
-
* Creates a copy of an existing campaign with a new name.
|
|
555
|
-
*
|
|
556
487
|
* @param accountId - Account ID
|
|
557
488
|
* @param campaignId - Campaign ID to duplicate
|
|
558
|
-
* @param
|
|
559
|
-
*
|
|
560
|
-
* @example
|
|
561
|
-
* ```typescript
|
|
562
|
-
* const newCampaign = await client.campaigns.duplicate(
|
|
563
|
-
* 'my-account',
|
|
564
|
-
* '12345',
|
|
565
|
-
* 'My Campaign - Copy'
|
|
566
|
-
* );
|
|
567
|
-
* ```
|
|
489
|
+
* @param request - Duplication request with optional name and settings
|
|
490
|
+
* @param destinationAccount - Optional destination account ID for cross-account duplication
|
|
568
491
|
*/
|
|
569
|
-
async duplicate(accountId, campaignId,
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
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);
|
|
573
500
|
}
|
|
574
501
|
/**
|
|
575
502
|
* Pause a campaign
|
|
576
|
-
*
|
|
577
|
-
* @param accountId - Account ID
|
|
578
|
-
* @param campaignId - Campaign ID
|
|
579
|
-
*
|
|
580
|
-
* @example
|
|
581
|
-
* ```typescript
|
|
582
|
-
* await client.campaigns.pause('my-account', '12345');
|
|
583
|
-
* ```
|
|
584
503
|
*/
|
|
585
504
|
async pause(accountId, campaignId) {
|
|
586
505
|
return this.update(accountId, campaignId, { is_active: false });
|
|
587
506
|
}
|
|
588
507
|
/**
|
|
589
508
|
* Unpause (resume) a campaign
|
|
590
|
-
*
|
|
591
|
-
* @param accountId - Account ID
|
|
592
|
-
* @param campaignId - Campaign ID
|
|
593
|
-
*
|
|
594
|
-
* @example
|
|
595
|
-
* ```typescript
|
|
596
|
-
* await client.campaigns.unpause('my-account', '12345');
|
|
597
|
-
* ```
|
|
598
509
|
*/
|
|
599
510
|
async unpause(accountId, campaignId) {
|
|
600
511
|
return this.update(accountId, campaignId, { is_active: true });
|
|
601
512
|
}
|
|
602
513
|
/**
|
|
603
514
|
* Bulk update multiple campaigns
|
|
604
|
-
*
|
|
605
|
-
* @param accountId - Account ID
|
|
606
|
-
* @param updates - Array of campaign updates
|
|
607
|
-
*
|
|
608
|
-
* @example
|
|
609
|
-
* ```typescript
|
|
610
|
-
* await client.campaigns.bulkUpdate('my-account', {
|
|
611
|
-
* campaigns: [
|
|
612
|
-
* { campaign_id: '12345', update: { is_active: false } },
|
|
613
|
-
* { campaign_id: '12346', update: { is_active: false } },
|
|
614
|
-
* ],
|
|
615
|
-
* });
|
|
616
|
-
* ```
|
|
617
515
|
*/
|
|
618
516
|
async bulkUpdate(accountId, updates) {
|
|
619
517
|
return this.http.put(`${accountId}/campaigns/bulk`, updates);
|
|
620
518
|
}
|
|
621
519
|
/**
|
|
622
|
-
* Patch a campaign
|
|
520
|
+
* Patch a campaign
|
|
623
521
|
*
|
|
624
522
|
* @param accountId - Account ID
|
|
625
523
|
* @param campaignId - Campaign ID
|
|
626
|
-
* @param
|
|
627
|
-
* @param patches - Patch operations
|
|
628
|
-
*
|
|
629
|
-
* @example
|
|
630
|
-
* ```typescript
|
|
631
|
-
* await client.campaigns.patch('my-account', '12345', 'publisher_targeting', [
|
|
632
|
-
* { op: 'ADD', path: '/value', value: ['pub-123'] },
|
|
633
|
-
* ]);
|
|
634
|
-
* ```
|
|
524
|
+
* @param patch - Patch operation
|
|
635
525
|
*/
|
|
636
|
-
async patch(accountId, campaignId,
|
|
637
|
-
return this.http.patch(`${accountId}/campaigns/${campaignId}
|
|
526
|
+
async patch(accountId, campaignId, patch) {
|
|
527
|
+
return this.http.patch(`${accountId}/campaigns/${campaignId}`, patch);
|
|
638
528
|
}
|
|
639
529
|
/**
|
|
640
530
|
* Get all campaigns across a network
|
|
641
531
|
*
|
|
642
532
|
* @param networkAccountId - Network account ID
|
|
643
|
-
*
|
|
644
|
-
* @example
|
|
645
|
-
* ```typescript
|
|
646
|
-
* const { results } = await client.campaigns.listNetwork('my-network');
|
|
647
|
-
* ```
|
|
648
533
|
*/
|
|
649
534
|
async listNetwork(networkAccountId) {
|
|
650
|
-
return this.http.get(
|
|
535
|
+
return this.http.get(`${networkAccountId}/campaigns/base`);
|
|
651
536
|
}
|
|
652
537
|
/**
|
|
653
538
|
* Estimate campaign reach
|
|
654
|
-
*
|
|
655
|
-
* Get estimated impressions, clicks, and reach for a campaign configuration.
|
|
656
|
-
*
|
|
657
|
-
* @param accountId - Account ID
|
|
658
|
-
* @param params - Targeting and budget parameters
|
|
659
|
-
*
|
|
660
|
-
* @example
|
|
661
|
-
* ```typescript
|
|
662
|
-
* const estimate = await client.campaigns.estimateReach('my-account', {
|
|
663
|
-
* country_targeting: ['US'],
|
|
664
|
-
* platform_targeting: ['DESK', 'PHON'],
|
|
665
|
-
* daily_cap: 100,
|
|
666
|
-
* cpc: 0.50,
|
|
667
|
-
* });
|
|
668
|
-
* console.log('Estimated clicks:', estimate.estimated_clicks);
|
|
669
|
-
* ```
|
|
670
539
|
*/
|
|
671
540
|
async estimateReach(accountId, params) {
|
|
672
541
|
return this.http.post(
|
|
@@ -676,17 +545,6 @@ var CampaignsAPI = class {
|
|
|
676
545
|
}
|
|
677
546
|
/**
|
|
678
547
|
* Get publisher targeting whitelist for a campaign
|
|
679
|
-
*
|
|
680
|
-
* Returns the list of publishers that are whitelisted for this campaign.
|
|
681
|
-
*
|
|
682
|
-
* @param accountId - Account ID
|
|
683
|
-
* @param campaignId - Campaign ID
|
|
684
|
-
*
|
|
685
|
-
* @example
|
|
686
|
-
* ```typescript
|
|
687
|
-
* const whitelist = await client.campaigns.getTargetingWhitelist('my-account', '12345');
|
|
688
|
-
* console.log('Whitelisted publishers:', whitelist.value);
|
|
689
|
-
* ```
|
|
690
548
|
*/
|
|
691
549
|
async getTargetingWhitelist(accountId, campaignId) {
|
|
692
550
|
return this.http.get(
|
|
@@ -750,42 +608,70 @@ var ItemsAPI = class {
|
|
|
750
608
|
return this.http.get(`${accountId}/campaigns/${campaignId}/items/${itemId}`);
|
|
751
609
|
}
|
|
752
610
|
/**
|
|
753
|
-
* 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.
|
|
754
619
|
*
|
|
755
620
|
* @param accountId - Account ID
|
|
756
621
|
* @param campaignId - Campaign ID
|
|
757
|
-
* @param item - Item data
|
|
622
|
+
* @param item - Item data (only `url` is accepted)
|
|
758
623
|
*
|
|
759
624
|
* @example
|
|
760
625
|
* ```typescript
|
|
761
626
|
* const item = await client.items.create('my-account', '12345', {
|
|
762
627
|
* url: 'https://example.com/landing-page',
|
|
763
|
-
* title: 'Check Out Our Amazing Product!',
|
|
764
|
-
* thumbnail_url: 'https://example.com/image.jpg',
|
|
765
|
-
* description: 'Learn more about our product',
|
|
766
|
-
* cta: { cta_type: 'LEARN_MORE' },
|
|
767
628
|
* });
|
|
768
|
-
*
|
|
629
|
+
* // Item starts in CRAWLING state - poll until status changes
|
|
630
|
+
* console.log('Created item:', item.id, item.status); // CRAWLING
|
|
769
631
|
* ```
|
|
770
632
|
*/
|
|
771
633
|
async create(accountId, campaignId, item) {
|
|
772
634
|
return this.http.post(`${accountId}/campaigns/${campaignId}/items/`, item);
|
|
773
635
|
}
|
|
774
636
|
/**
|
|
775
|
-
* Update an existing item
|
|
637
|
+
* Update an existing item (static or motion ad)
|
|
638
|
+
*
|
|
639
|
+
* Submit only the fields you want to update. Fields that are omitted or null
|
|
640
|
+
* will remain unchanged. The endpoint automatically detects the item type.
|
|
641
|
+
*
|
|
642
|
+
* Note: While status is CRAWLING, the Item is in a read-only state - no fields can be modified.
|
|
776
643
|
*
|
|
777
644
|
* @param accountId - Account ID
|
|
778
645
|
* @param campaignId - Campaign ID
|
|
779
646
|
* @param itemId - Item ID
|
|
780
|
-
* @param updates - Fields to update
|
|
647
|
+
* @param updates - Fields to update (partial)
|
|
781
648
|
*
|
|
782
|
-
* @example
|
|
649
|
+
* @example Update a static item
|
|
783
650
|
* ```typescript
|
|
784
651
|
* const item = await client.items.update('my-account', '12345', '67890', {
|
|
785
652
|
* title: 'Updated Title!',
|
|
786
653
|
* is_active: true,
|
|
787
654
|
* });
|
|
788
655
|
* ```
|
|
656
|
+
*
|
|
657
|
+
* @example Update a motion ad
|
|
658
|
+
* ```typescript
|
|
659
|
+
* const item = await client.items.update('my-account', '12345', '67890', {
|
|
660
|
+
* title: 'Updated Motion Ad Title',
|
|
661
|
+
* description: 'New description',
|
|
662
|
+
* performance_video_data: {
|
|
663
|
+
* video_url: 'https://example.com/video.mp4',
|
|
664
|
+
* fallback_url: 'https://example.com/fallback.jpg',
|
|
665
|
+
* },
|
|
666
|
+
* });
|
|
667
|
+
* ```
|
|
668
|
+
*
|
|
669
|
+
* @example Pause an item (alternatively, use pause() method)
|
|
670
|
+
* ```typescript
|
|
671
|
+
* const item = await client.items.update('my-account', '12345', '67890', {
|
|
672
|
+
* is_active: false,
|
|
673
|
+
* });
|
|
674
|
+
* ```
|
|
789
675
|
*/
|
|
790
676
|
async update(accountId, campaignId, itemId, updates) {
|
|
791
677
|
return this.http.post(
|
|
@@ -839,11 +725,13 @@ var ItemsAPI = class {
|
|
|
839
725
|
return this.update(accountId, campaignId, itemId, { is_active: true });
|
|
840
726
|
}
|
|
841
727
|
/**
|
|
842
|
-
* 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.
|
|
843
731
|
*
|
|
844
732
|
* @param accountId - Account ID
|
|
845
733
|
* @param campaignId - Campaign ID
|
|
846
|
-
* @param
|
|
734
|
+
* @param request - Bulk create request with items array
|
|
847
735
|
*
|
|
848
736
|
* @example
|
|
849
737
|
* ```typescript
|
|
@@ -865,14 +753,31 @@ var ItemsAPI = class {
|
|
|
865
753
|
/**
|
|
866
754
|
* Bulk create items across multiple campaigns
|
|
867
755
|
*
|
|
756
|
+
* Unified endpoint that supports both static ads and motion ads.
|
|
757
|
+
*
|
|
868
758
|
* @param accountId - Account ID
|
|
869
759
|
* @param items - Array of items with campaign IDs
|
|
870
760
|
*
|
|
871
|
-
* @example
|
|
761
|
+
* @example Static ads
|
|
872
762
|
* ```typescript
|
|
873
763
|
* await client.items.bulkCreateAcrossCampaigns('my-account', [
|
|
874
|
-
* { campaign_id: '12345', url: '
|
|
875
|
-
* { 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
|
+
* },
|
|
876
781
|
* ]);
|
|
877
782
|
* ```
|
|
878
783
|
*/
|
|
@@ -976,15 +881,11 @@ var DictionaryAPI = class {
|
|
|
976
881
|
* Get list of all supported countries
|
|
977
882
|
*/
|
|
978
883
|
async getCountries() {
|
|
979
|
-
const response = await this.http.get(
|
|
980
|
-
"resources/countries"
|
|
981
|
-
);
|
|
884
|
+
const response = await this.http.get("resources/countries");
|
|
982
885
|
return response.results;
|
|
983
886
|
}
|
|
984
887
|
/**
|
|
985
888
|
* Get regions/states within a country
|
|
986
|
-
*
|
|
987
|
-
* @param countryCode - Country code (e.g., 'US', 'GB')
|
|
988
889
|
*/
|
|
989
890
|
async getRegions(countryCode) {
|
|
990
891
|
const response = await this.http.get(
|
|
@@ -994,9 +895,6 @@ var DictionaryAPI = class {
|
|
|
994
895
|
}
|
|
995
896
|
/**
|
|
996
897
|
* Get DMAs (Designated Market Areas) for a country
|
|
997
|
-
* Note: Only available for US
|
|
998
|
-
*
|
|
999
|
-
* @param countryCode - Country code (typically 'US')
|
|
1000
898
|
*/
|
|
1001
899
|
async getDMAs(countryCode) {
|
|
1002
900
|
const response = await this.http.get(
|
|
@@ -1006,9 +904,6 @@ var DictionaryAPI = class {
|
|
|
1006
904
|
}
|
|
1007
905
|
/**
|
|
1008
906
|
* Get postal codes for a country
|
|
1009
|
-
*
|
|
1010
|
-
* @param countryCode - Country code (e.g., 'US', 'GB')
|
|
1011
|
-
* @param params - Optional search and pagination parameters
|
|
1012
907
|
*/
|
|
1013
908
|
async getPostalCodes(countryCode, params) {
|
|
1014
909
|
const searchParams = new URLSearchParams();
|
|
@@ -1032,9 +927,7 @@ var DictionaryAPI = class {
|
|
|
1032
927
|
* Get list of supported platforms
|
|
1033
928
|
*/
|
|
1034
929
|
async getPlatforms() {
|
|
1035
|
-
const response = await this.http.get(
|
|
1036
|
-
"resources/platforms"
|
|
1037
|
-
);
|
|
930
|
+
const response = await this.http.get("resources/platforms");
|
|
1038
931
|
return response.results;
|
|
1039
932
|
}
|
|
1040
933
|
/**
|
|
@@ -1068,9 +961,7 @@ var DictionaryAPI = class {
|
|
|
1068
961
|
* Get list of supported browsers
|
|
1069
962
|
*/
|
|
1070
963
|
async getBrowsers() {
|
|
1071
|
-
const response = await this.http.get(
|
|
1072
|
-
"resources/browsers"
|
|
1073
|
-
);
|
|
964
|
+
const response = await this.http.get("resources/browsers");
|
|
1074
965
|
return response.results;
|
|
1075
966
|
}
|
|
1076
967
|
// ===== Enums =====
|
|
@@ -1090,9 +981,7 @@ var DictionaryAPI = class {
|
|
|
1090
981
|
* Get days of week for activity scheduling
|
|
1091
982
|
*/
|
|
1092
983
|
async getDaysOfWeek() {
|
|
1093
|
-
const response = await this.http.get(
|
|
1094
|
-
"resources/days-of-week"
|
|
1095
|
-
);
|
|
984
|
+
const response = await this.http.get("resources/days-of-week");
|
|
1096
985
|
return response.results;
|
|
1097
986
|
}
|
|
1098
987
|
// ===== Possible Values =====
|
|
@@ -1127,9 +1016,7 @@ var DictionaryAPI = class {
|
|
|
1127
1016
|
* Get minimum CPC values per country/platform
|
|
1128
1017
|
*/
|
|
1129
1018
|
async getMinimumCPCs() {
|
|
1130
|
-
const response = await this.http.get(
|
|
1131
|
-
"resources/minimum-cpc"
|
|
1132
|
-
);
|
|
1019
|
+
const response = await this.http.get("resources/minimum-cpc");
|
|
1133
1020
|
return response.results;
|
|
1134
1021
|
}
|
|
1135
1022
|
// ===== Image Library =====
|
|
@@ -1144,8 +1031,6 @@ var DictionaryAPI = class {
|
|
|
1144
1031
|
}
|
|
1145
1032
|
/**
|
|
1146
1033
|
* Get image taxonomies for categorizing images
|
|
1147
|
-
*
|
|
1148
|
-
* @param accountId - Account ID
|
|
1149
1034
|
*/
|
|
1150
1035
|
async getImageTaxonomies(accountId) {
|
|
1151
1036
|
const response = await this.http.get(
|
|
@@ -1156,58 +1041,46 @@ var DictionaryAPI = class {
|
|
|
1156
1041
|
// ===== Audience Targeting =====
|
|
1157
1042
|
/**
|
|
1158
1043
|
* Get marketplace audience segments available for targeting
|
|
1159
|
-
*
|
|
1160
|
-
* @param accountId - Account ID
|
|
1161
1044
|
*/
|
|
1162
1045
|
async getMarketplaceAudiences(accountId) {
|
|
1163
1046
|
const response = await this.http.get(
|
|
1164
|
-
`${accountId}/dictionary/
|
|
1047
|
+
`${accountId}/dictionary/audience_segments`
|
|
1165
1048
|
);
|
|
1166
1049
|
return response.results;
|
|
1167
1050
|
}
|
|
1168
1051
|
/**
|
|
1169
1052
|
* Get marketplace audience segments for a specific country
|
|
1170
|
-
*
|
|
1171
|
-
* @param accountId - Account ID
|
|
1172
|
-
* @param countryCode - Country code (e.g., 'US', 'GB')
|
|
1173
1053
|
*/
|
|
1174
1054
|
async getMarketplaceAudiencesByCountry(accountId, countryCode) {
|
|
1175
1055
|
const response = await this.http.get(
|
|
1176
|
-
`${accountId}/dictionary/
|
|
1056
|
+
`${accountId}/dictionary/audience_segments/${countryCode}`
|
|
1177
1057
|
);
|
|
1178
1058
|
return response.results;
|
|
1179
1059
|
}
|
|
1180
1060
|
/**
|
|
1181
1061
|
* Get lookalike audiences available for targeting
|
|
1182
|
-
*
|
|
1183
|
-
* @param accountId - Account ID
|
|
1184
1062
|
*/
|
|
1185
1063
|
async getLookalikeAudiences(accountId) {
|
|
1186
1064
|
const response = await this.http.get(
|
|
1187
|
-
`${accountId}/dictionary/
|
|
1065
|
+
`${accountId}/dictionary/lookalike_audiences`
|
|
1188
1066
|
);
|
|
1189
1067
|
return response.results;
|
|
1190
1068
|
}
|
|
1191
1069
|
/**
|
|
1192
1070
|
* Get lookalike audiences for a specific country
|
|
1193
|
-
*
|
|
1194
|
-
* @param accountId - Account ID
|
|
1195
|
-
* @param countryCode - Country code (e.g., 'US', 'GB')
|
|
1196
1071
|
*/
|
|
1197
1072
|
async getLookalikeAudiencesByCountry(accountId, countryCode) {
|
|
1198
1073
|
const response = await this.http.get(
|
|
1199
|
-
`${accountId}/dictionary/
|
|
1074
|
+
`${accountId}/dictionary/lookalike_audiences/${countryCode}`
|
|
1200
1075
|
);
|
|
1201
1076
|
return response.results;
|
|
1202
1077
|
}
|
|
1203
1078
|
/**
|
|
1204
1079
|
* Get contextual segments available for targeting
|
|
1205
|
-
*
|
|
1206
|
-
* @param accountId - Account ID
|
|
1207
1080
|
*/
|
|
1208
1081
|
async getContextualSegments(accountId) {
|
|
1209
1082
|
const response = await this.http.get(
|
|
1210
|
-
`${accountId}/dictionary/
|
|
1083
|
+
`${accountId}/dictionary/contextual_segments`
|
|
1211
1084
|
);
|
|
1212
1085
|
return response.results;
|
|
1213
1086
|
}
|
|
@@ -1220,116 +1093,55 @@ var PublishersAPI = class {
|
|
|
1220
1093
|
}
|
|
1221
1094
|
/**
|
|
1222
1095
|
* List all available publishers for an account
|
|
1223
|
-
*
|
|
1224
|
-
* @param accountId - Account ID
|
|
1225
|
-
* @returns List of publishers with blocking status
|
|
1226
|
-
*
|
|
1227
|
-
* @example
|
|
1228
|
-
* ```typescript
|
|
1229
|
-
* const publishers = await client.publishers.list('my-account');
|
|
1230
|
-
* console.log(`Found ${publishers.length} publishers`);
|
|
1231
|
-
* ```
|
|
1232
1096
|
*/
|
|
1233
1097
|
async list(accountId) {
|
|
1234
|
-
const response = await this.http.get(
|
|
1235
|
-
`${accountId}/publishers`
|
|
1236
|
-
);
|
|
1098
|
+
const response = await this.http.get(`${accountId}/allowed-publishers`);
|
|
1237
1099
|
return response.results;
|
|
1238
1100
|
}
|
|
1239
1101
|
/**
|
|
1240
1102
|
* Get blocked publishers at the account level
|
|
1241
|
-
*
|
|
1242
|
-
* @param accountId - Account ID
|
|
1243
|
-
* @returns List of blocked publishers
|
|
1244
|
-
*
|
|
1245
|
-
* @example
|
|
1246
|
-
* ```typescript
|
|
1247
|
-
* const blocked = await client.publishers.getBlocked('my-account');
|
|
1248
|
-
* console.log(`${blocked.length} publishers blocked at account level`);
|
|
1249
|
-
* ```
|
|
1250
1103
|
*/
|
|
1251
1104
|
async getBlocked(accountId) {
|
|
1252
|
-
const response = await this.http.get(
|
|
1253
|
-
|
|
1254
|
-
);
|
|
1255
|
-
if (Array.isArray(response)) {
|
|
1256
|
-
return response;
|
|
1257
|
-
}
|
|
1258
|
-
return response.results ?? [];
|
|
1105
|
+
const response = await this.http.get(`${accountId}/block-publisher`);
|
|
1106
|
+
return response.sites;
|
|
1259
1107
|
}
|
|
1260
1108
|
/**
|
|
1261
1109
|
* Update blocked publishers at the account level
|
|
1262
1110
|
*
|
|
1263
1111
|
* This replaces the current list of blocked publishers with the
|
|
1264
|
-
* provided list.
|
|
1265
|
-
* list and append.
|
|
1266
|
-
*
|
|
1267
|
-
* @param accountId - Account ID
|
|
1268
|
-
* @param sites - Array of site names to block
|
|
1269
|
-
* @returns Updated list of blocked publishers
|
|
1270
|
-
*
|
|
1271
|
-
* @example
|
|
1272
|
-
* ```typescript
|
|
1273
|
-
* // Block specific publishers
|
|
1274
|
-
* await client.publishers.updateBlocked('my-account', {
|
|
1275
|
-
* sites: ['site1.com', 'site2.com']
|
|
1276
|
-
* });
|
|
1277
|
-
*
|
|
1278
|
-
* // Add to existing blocks
|
|
1279
|
-
* const current = await client.publishers.getBlocked('my-account');
|
|
1280
|
-
* const currentSites = current.map(p => p.site);
|
|
1281
|
-
* await client.publishers.updateBlocked('my-account', {
|
|
1282
|
-
* sites: [...currentSites, 'newsite.com']
|
|
1283
|
-
* });
|
|
1284
|
-
* ```
|
|
1112
|
+
* provided list.
|
|
1285
1113
|
*/
|
|
1286
1114
|
async updateBlocked(accountId, request) {
|
|
1287
1115
|
const response = await this.http.post(
|
|
1288
1116
|
`${accountId}/block-publisher`,
|
|
1289
1117
|
request
|
|
1290
1118
|
);
|
|
1291
|
-
return response.
|
|
1119
|
+
return response.sites;
|
|
1292
1120
|
}
|
|
1293
1121
|
/**
|
|
1294
1122
|
* Block a single publisher at the account level
|
|
1295
|
-
*
|
|
1296
|
-
* Convenience method that adds a publisher to the existing block list.
|
|
1297
|
-
*
|
|
1298
|
-
* @param accountId - Account ID
|
|
1299
|
-
* @param site - Site name to block
|
|
1300
|
-
* @returns Updated list of blocked publishers
|
|
1301
1123
|
*/
|
|
1302
1124
|
async blockPublisher(accountId, site) {
|
|
1303
1125
|
const current = await this.getBlocked(accountId);
|
|
1304
|
-
|
|
1305
|
-
if (currentSites.includes(site)) {
|
|
1126
|
+
if (current.includes(site)) {
|
|
1306
1127
|
return current;
|
|
1307
1128
|
}
|
|
1308
1129
|
return this.updateBlocked(accountId, {
|
|
1309
|
-
sites: [...
|
|
1130
|
+
sites: [...current, site]
|
|
1310
1131
|
});
|
|
1311
1132
|
}
|
|
1312
1133
|
/**
|
|
1313
1134
|
* Unblock a single publisher at the account level
|
|
1314
|
-
*
|
|
1315
|
-
* Convenience method that removes a publisher from the block list.
|
|
1316
|
-
*
|
|
1317
|
-
* @param accountId - Account ID
|
|
1318
|
-
* @param site - Site name to unblock
|
|
1319
|
-
* @returns Updated list of blocked publishers
|
|
1320
1135
|
*/
|
|
1321
1136
|
async unblockPublisher(accountId, site) {
|
|
1322
1137
|
const current = await this.getBlocked(accountId);
|
|
1323
|
-
const filteredSites = current.
|
|
1138
|
+
const filteredSites = current.filter((s) => s !== site);
|
|
1324
1139
|
return this.updateBlocked(accountId, {
|
|
1325
1140
|
sites: filteredSites
|
|
1326
1141
|
});
|
|
1327
1142
|
}
|
|
1328
1143
|
/**
|
|
1329
1144
|
* Clear all blocked publishers at the account level
|
|
1330
|
-
*
|
|
1331
|
-
* @param accountId - Account ID
|
|
1332
|
-
* @returns Empty list
|
|
1333
1145
|
*/
|
|
1334
1146
|
async clearBlocked(accountId) {
|
|
1335
1147
|
return this.updateBlocked(accountId, { sites: [] });
|
|
@@ -1344,17 +1156,6 @@ var TargetingAPI = class {
|
|
|
1344
1156
|
// ===== Postal Code Targeting =====
|
|
1345
1157
|
/**
|
|
1346
1158
|
* Get postal code targeting for a campaign
|
|
1347
|
-
*
|
|
1348
|
-
* @param accountId - Account ID
|
|
1349
|
-
* @param campaignId - Campaign ID
|
|
1350
|
-
* @returns Postal code targeting configuration
|
|
1351
|
-
*
|
|
1352
|
-
* @example
|
|
1353
|
-
* ```typescript
|
|
1354
|
-
* const targeting = await client.targeting.getPostalCodes('my-account', '12345');
|
|
1355
|
-
* console.log(`Targeting type: ${targeting.type}`);
|
|
1356
|
-
* console.log(`Postal codes: ${targeting.values.length}`);
|
|
1357
|
-
* ```
|
|
1358
1159
|
*/
|
|
1359
1160
|
async getPostalCodes(accountId, campaignId) {
|
|
1360
1161
|
return this.http.get(
|
|
@@ -1363,22 +1164,6 @@ var TargetingAPI = class {
|
|
|
1363
1164
|
}
|
|
1364
1165
|
/**
|
|
1365
1166
|
* Update postal code targeting for a campaign
|
|
1366
|
-
*
|
|
1367
|
-
* @param accountId - Account ID
|
|
1368
|
-
* @param campaignId - Campaign ID
|
|
1369
|
-
* @param targeting - Postal code targeting configuration
|
|
1370
|
-
* @returns Updated targeting configuration
|
|
1371
|
-
*
|
|
1372
|
-
* @example
|
|
1373
|
-
* ```typescript
|
|
1374
|
-
* await client.targeting.updatePostalCodes('my-account', '12345', {
|
|
1375
|
-
* type: 'INCLUDE',
|
|
1376
|
-
* values: [
|
|
1377
|
-
* { postal_code: '10001', country: 'US' },
|
|
1378
|
-
* { postal_code: '10002', country: 'US' },
|
|
1379
|
-
* ]
|
|
1380
|
-
* });
|
|
1381
|
-
* ```
|
|
1382
1167
|
*/
|
|
1383
1168
|
async updatePostalCodes(accountId, campaignId, targeting) {
|
|
1384
1169
|
return this.http.post(
|
|
@@ -1389,13 +1174,6 @@ var TargetingAPI = class {
|
|
|
1389
1174
|
// ===== Marketplace Audience Targeting =====
|
|
1390
1175
|
/**
|
|
1391
1176
|
* Get marketplace audience targeting for a campaign
|
|
1392
|
-
*
|
|
1393
|
-
* Marketplace audiences are third-party audience segments
|
|
1394
|
-
* available for targeting through Taboola's marketplace.
|
|
1395
|
-
*
|
|
1396
|
-
* @param accountId - Account ID
|
|
1397
|
-
* @param campaignId - Campaign ID
|
|
1398
|
-
* @returns Audience targeting configuration
|
|
1399
1177
|
*/
|
|
1400
1178
|
async getMarketplaceAudiences(accountId, campaignId) {
|
|
1401
1179
|
return this.http.get(
|
|
@@ -1404,22 +1182,6 @@ var TargetingAPI = class {
|
|
|
1404
1182
|
}
|
|
1405
1183
|
/**
|
|
1406
1184
|
* Update marketplace audience targeting for a campaign
|
|
1407
|
-
*
|
|
1408
|
-
* @param accountId - Account ID
|
|
1409
|
-
* @param campaignId - Campaign ID
|
|
1410
|
-
* @param targeting - Audience targeting configuration
|
|
1411
|
-
* @returns Updated targeting configuration
|
|
1412
|
-
*
|
|
1413
|
-
* @example
|
|
1414
|
-
* ```typescript
|
|
1415
|
-
* await client.targeting.updateMarketplaceAudiences('my-account', '12345', {
|
|
1416
|
-
* type: 'INCLUDE',
|
|
1417
|
-
* collection: [
|
|
1418
|
-
* { id: 'segment-1', name: null },
|
|
1419
|
-
* { id: 'segment-2', name: null },
|
|
1420
|
-
* ]
|
|
1421
|
-
* });
|
|
1422
|
-
* ```
|
|
1423
1185
|
*/
|
|
1424
1186
|
async updateMarketplaceAudiences(accountId, campaignId, targeting) {
|
|
1425
1187
|
return this.http.post(
|
|
@@ -1430,13 +1192,6 @@ var TargetingAPI = class {
|
|
|
1430
1192
|
// ===== Custom Audience Targeting =====
|
|
1431
1193
|
/**
|
|
1432
1194
|
* Get custom audience targeting for a campaign
|
|
1433
|
-
*
|
|
1434
|
-
* Custom audiences are audiences created from pixel data
|
|
1435
|
-
* or uploaded lists.
|
|
1436
|
-
*
|
|
1437
|
-
* @param accountId - Account ID
|
|
1438
|
-
* @param campaignId - Campaign ID
|
|
1439
|
-
* @returns Audience targeting configuration
|
|
1440
1195
|
*/
|
|
1441
1196
|
async getCustomAudiences(accountId, campaignId) {
|
|
1442
1197
|
return this.http.get(
|
|
@@ -1445,11 +1200,6 @@ var TargetingAPI = class {
|
|
|
1445
1200
|
}
|
|
1446
1201
|
/**
|
|
1447
1202
|
* Update custom audience targeting for a campaign
|
|
1448
|
-
*
|
|
1449
|
-
* @param accountId - Account ID
|
|
1450
|
-
* @param campaignId - Campaign ID
|
|
1451
|
-
* @param targeting - Audience targeting configuration
|
|
1452
|
-
* @returns Updated targeting configuration
|
|
1453
1203
|
*/
|
|
1454
1204
|
async updateCustomAudiences(accountId, campaignId, targeting) {
|
|
1455
1205
|
return this.http.post(
|
|
@@ -1460,13 +1210,6 @@ var TargetingAPI = class {
|
|
|
1460
1210
|
// ===== Lookalike Audience Targeting =====
|
|
1461
1211
|
/**
|
|
1462
1212
|
* Get lookalike audience targeting for a campaign
|
|
1463
|
-
*
|
|
1464
|
-
* Lookalike audiences are modeled after your existing
|
|
1465
|
-
* custom audiences to find similar users.
|
|
1466
|
-
*
|
|
1467
|
-
* @param accountId - Account ID
|
|
1468
|
-
* @param campaignId - Campaign ID
|
|
1469
|
-
* @returns Audience targeting configuration
|
|
1470
1213
|
*/
|
|
1471
1214
|
async getLookalikeAudiences(accountId, campaignId) {
|
|
1472
1215
|
return this.http.get(
|
|
@@ -1475,11 +1218,6 @@ var TargetingAPI = class {
|
|
|
1475
1218
|
}
|
|
1476
1219
|
/**
|
|
1477
1220
|
* Update lookalike audience targeting for a campaign
|
|
1478
|
-
*
|
|
1479
|
-
* @param accountId - Account ID
|
|
1480
|
-
* @param campaignId - Campaign ID
|
|
1481
|
-
* @param targeting - Audience targeting configuration
|
|
1482
|
-
* @returns Updated targeting configuration
|
|
1483
1221
|
*/
|
|
1484
1222
|
async updateLookalikeAudiences(accountId, campaignId, targeting) {
|
|
1485
1223
|
return this.http.post(
|
|
@@ -1490,13 +1228,6 @@ var TargetingAPI = class {
|
|
|
1490
1228
|
// ===== Contextual Targeting =====
|
|
1491
1229
|
/**
|
|
1492
1230
|
* Get contextual targeting for a campaign
|
|
1493
|
-
*
|
|
1494
|
-
* Contextual targeting allows you to target based on the
|
|
1495
|
-
* content of the pages where your ads appear.
|
|
1496
|
-
*
|
|
1497
|
-
* @param accountId - Account ID
|
|
1498
|
-
* @param campaignId - Campaign ID
|
|
1499
|
-
* @returns Contextual targeting configuration
|
|
1500
1231
|
*/
|
|
1501
1232
|
async getContextual(accountId, campaignId) {
|
|
1502
1233
|
return this.http.get(
|
|
@@ -1505,22 +1236,6 @@ var TargetingAPI = class {
|
|
|
1505
1236
|
}
|
|
1506
1237
|
/**
|
|
1507
1238
|
* Update contextual targeting for a campaign
|
|
1508
|
-
*
|
|
1509
|
-
* @param accountId - Account ID
|
|
1510
|
-
* @param campaignId - Campaign ID
|
|
1511
|
-
* @param targeting - Contextual targeting configuration
|
|
1512
|
-
* @returns Updated targeting configuration
|
|
1513
|
-
*
|
|
1514
|
-
* @example
|
|
1515
|
-
* ```typescript
|
|
1516
|
-
* await client.targeting.updateContextual('my-account', '12345', {
|
|
1517
|
-
* type: 'INCLUDE',
|
|
1518
|
-
* collection: [
|
|
1519
|
-
* { id: 'context-1', name: null },
|
|
1520
|
-
* { id: 'context-2', name: null },
|
|
1521
|
-
* ]
|
|
1522
|
-
* });
|
|
1523
|
-
* ```
|
|
1524
1239
|
*/
|
|
1525
1240
|
async updateContextual(accountId, campaignId, targeting) {
|
|
1526
1241
|
return this.http.post(
|
|
@@ -1531,12 +1246,6 @@ var TargetingAPI = class {
|
|
|
1531
1246
|
// ===== First Party Audience Targeting =====
|
|
1532
1247
|
/**
|
|
1533
1248
|
* Get first party audience targeting for a campaign
|
|
1534
|
-
*
|
|
1535
|
-
* First party audiences are your own uploaded audience data.
|
|
1536
|
-
*
|
|
1537
|
-
* @param accountId - Account ID
|
|
1538
|
-
* @param campaignId - Campaign ID
|
|
1539
|
-
* @returns First party audience targeting configuration
|
|
1540
1249
|
*/
|
|
1541
1250
|
async getFirstPartyAudiences(accountId, campaignId) {
|
|
1542
1251
|
return this.http.get(
|
|
@@ -1545,11 +1254,6 @@ var TargetingAPI = class {
|
|
|
1545
1254
|
}
|
|
1546
1255
|
/**
|
|
1547
1256
|
* Update first party audience targeting for a campaign
|
|
1548
|
-
*
|
|
1549
|
-
* @param accountId - Account ID
|
|
1550
|
-
* @param campaignId - Campaign ID
|
|
1551
|
-
* @param targeting - First party audience targeting configuration
|
|
1552
|
-
* @returns Updated targeting configuration
|
|
1553
1257
|
*/
|
|
1554
1258
|
async updateFirstPartyAudiences(accountId, campaignId, targeting) {
|
|
1555
1259
|
return this.http.post(
|
|
@@ -1560,19 +1264,6 @@ var TargetingAPI = class {
|
|
|
1560
1264
|
// ===== Marking Labels Targeting =====
|
|
1561
1265
|
/**
|
|
1562
1266
|
* Get marking labels (pixel retargeting) targeting for a campaign
|
|
1563
|
-
*
|
|
1564
|
-
* Marking labels allow you to target users based on pixel-tracked
|
|
1565
|
-
* behavior using custom labels.
|
|
1566
|
-
*
|
|
1567
|
-
* @param accountId - Account ID
|
|
1568
|
-
* @param campaignId - Campaign ID
|
|
1569
|
-
* @returns Marking labels targeting configuration
|
|
1570
|
-
*
|
|
1571
|
-
* @example
|
|
1572
|
-
* ```typescript
|
|
1573
|
-
* const targeting = await client.targeting.getMarkingLabels('my-account', '12345');
|
|
1574
|
-
* console.log('Labels:', targeting.collection);
|
|
1575
|
-
* ```
|
|
1576
1267
|
*/
|
|
1577
1268
|
async getMarkingLabels(accountId, campaignId) {
|
|
1578
1269
|
return this.http.get(
|
|
@@ -1581,19 +1272,6 @@ var TargetingAPI = class {
|
|
|
1581
1272
|
}
|
|
1582
1273
|
/**
|
|
1583
1274
|
* Update marking labels targeting for a campaign
|
|
1584
|
-
*
|
|
1585
|
-
* @param accountId - Account ID
|
|
1586
|
-
* @param campaignId - Campaign ID
|
|
1587
|
-
* @param targeting - Marking labels targeting configuration
|
|
1588
|
-
* @returns Updated targeting configuration
|
|
1589
|
-
*
|
|
1590
|
-
* @example
|
|
1591
|
-
* ```typescript
|
|
1592
|
-
* await client.targeting.updateMarkingLabels('my-account', '12345', {
|
|
1593
|
-
* type: 'EXISTS',
|
|
1594
|
-
* collection: ['label-1', 'label-2'],
|
|
1595
|
-
* });
|
|
1596
|
-
* ```
|
|
1597
1275
|
*/
|
|
1598
1276
|
async updateMarkingLabels(accountId, campaignId, targeting) {
|
|
1599
1277
|
return this.http.post(
|
|
@@ -1610,105 +1288,40 @@ var CombinedAudiencesAPI = class {
|
|
|
1610
1288
|
}
|
|
1611
1289
|
/**
|
|
1612
1290
|
* List available audiences for combining
|
|
1613
|
-
*
|
|
1614
|
-
* Returns all audiences that can be used in combined audience rules,
|
|
1615
|
-
* including custom, lookalike, marketplace, and first-party audiences.
|
|
1616
|
-
*
|
|
1617
|
-
* @param accountId - Account ID
|
|
1618
|
-
* @returns List of available audiences
|
|
1619
|
-
*
|
|
1620
|
-
* @example
|
|
1621
|
-
* ```typescript
|
|
1622
|
-
* const available = await client.combinedAudiences.listAvailable('my-account');
|
|
1623
|
-
* console.log(`${available.length} audiences available for combining`);
|
|
1624
|
-
* ```
|
|
1625
1291
|
*/
|
|
1626
1292
|
async listAvailable(accountId) {
|
|
1627
1293
|
const response = await this.http.get(
|
|
1628
|
-
`${accountId}/
|
|
1294
|
+
`${accountId}/combined_audiences/resources/audiences`
|
|
1629
1295
|
);
|
|
1630
1296
|
return response.results;
|
|
1631
1297
|
}
|
|
1632
1298
|
/**
|
|
1633
1299
|
* List all combined audiences
|
|
1634
|
-
*
|
|
1635
|
-
* @param accountId - Account ID
|
|
1636
|
-
* @returns List of combined audiences
|
|
1637
|
-
*
|
|
1638
|
-
* @example
|
|
1639
|
-
* ```typescript
|
|
1640
|
-
* const audiences = await client.combinedAudiences.list('my-account');
|
|
1641
|
-
* for (const audience of audiences) {
|
|
1642
|
-
* console.log(`${audience.name}: ${audience.status}`);
|
|
1643
|
-
* }
|
|
1644
|
-
* ```
|
|
1645
1300
|
*/
|
|
1646
1301
|
async list(accountId) {
|
|
1647
1302
|
const response = await this.http.get(
|
|
1648
|
-
`${accountId}/
|
|
1303
|
+
`${accountId}/combined_audiences`
|
|
1649
1304
|
);
|
|
1650
1305
|
return response.results;
|
|
1651
1306
|
}
|
|
1652
1307
|
/**
|
|
1653
1308
|
* Get a single combined audience
|
|
1654
|
-
*
|
|
1655
|
-
* @param accountId - Account ID
|
|
1656
|
-
* @param audienceId - Combined audience ID
|
|
1657
|
-
* @returns Combined audience details
|
|
1658
1309
|
*/
|
|
1659
1310
|
async get(accountId, audienceId) {
|
|
1660
|
-
return this.http.get(
|
|
1661
|
-
`${accountId}/combined-audiences/${audienceId}`
|
|
1662
|
-
);
|
|
1311
|
+
return this.http.get(`${accountId}/combined_audiences/${audienceId}`);
|
|
1663
1312
|
}
|
|
1664
1313
|
/**
|
|
1665
1314
|
* Create a combined audience
|
|
1666
|
-
*
|
|
1667
|
-
* @param accountId - Account ID
|
|
1668
|
-
* @param audience - Combined audience configuration
|
|
1669
|
-
* @returns Created combined audience
|
|
1670
|
-
*
|
|
1671
|
-
* @example
|
|
1672
|
-
* ```typescript
|
|
1673
|
-
* const audience = await client.combinedAudiences.create('my-account', {
|
|
1674
|
-
* name: 'High-Value Engaged Users',
|
|
1675
|
-
* description: 'Users who are both high-value and engaged',
|
|
1676
|
-
* include_rules: [
|
|
1677
|
-
* {
|
|
1678
|
-
* audience_type: 'CUSTOM_AUDIENCE',
|
|
1679
|
-
* audiences: [{ id: 'custom-1', name: null }]
|
|
1680
|
-
* },
|
|
1681
|
-
* {
|
|
1682
|
-
* audience_type: 'LOOKALIKE_AUDIENCE',
|
|
1683
|
-
* audiences: [{ id: 'lookalike-1', name: null }]
|
|
1684
|
-
* }
|
|
1685
|
-
* ],
|
|
1686
|
-
* exclude_rules: [
|
|
1687
|
-
* {
|
|
1688
|
-
* audience_type: 'CUSTOM_AUDIENCE',
|
|
1689
|
-
* audiences: [{ id: 'converters', name: null }]
|
|
1690
|
-
* }
|
|
1691
|
-
* ]
|
|
1692
|
-
* });
|
|
1693
|
-
* ```
|
|
1694
1315
|
*/
|
|
1695
1316
|
async create(accountId, audience) {
|
|
1696
|
-
return this.http.post(
|
|
1697
|
-
`${accountId}/combined-audiences`,
|
|
1698
|
-
audience
|
|
1699
|
-
);
|
|
1317
|
+
return this.http.post(`${accountId}/combined_audiences`, audience);
|
|
1700
1318
|
}
|
|
1701
1319
|
/**
|
|
1702
1320
|
* Update a combined audience
|
|
1703
|
-
*
|
|
1704
|
-
* @param accountId - Account ID
|
|
1705
|
-
* @param audienceId - Combined audience ID
|
|
1706
|
-
* @param updates - Fields to update
|
|
1707
|
-
* @returns Updated combined audience
|
|
1708
1321
|
*/
|
|
1709
1322
|
async update(accountId, audienceId, updates) {
|
|
1710
1323
|
return this.http.post(
|
|
1711
|
-
`${accountId}/
|
|
1324
|
+
`${accountId}/combined_audiences/${audienceId}`,
|
|
1712
1325
|
updates
|
|
1713
1326
|
);
|
|
1714
1327
|
}
|
|
@@ -1721,118 +1334,32 @@ var FirstPartyAudiencesAPI = class {
|
|
|
1721
1334
|
}
|
|
1722
1335
|
/**
|
|
1723
1336
|
* List all first party audiences
|
|
1724
|
-
*
|
|
1725
|
-
* @param accountId - Account ID
|
|
1726
|
-
* @returns List of first party audiences
|
|
1727
|
-
*
|
|
1728
|
-
* @example
|
|
1729
|
-
* ```typescript
|
|
1730
|
-
* const audiences = await client.firstPartyAudiences.list('my-account');
|
|
1731
|
-
* for (const audience of audiences) {
|
|
1732
|
-
* console.log(`${audience.name}: ${audience.status} (${audience.size} users)`);
|
|
1733
|
-
* }
|
|
1734
|
-
* ```
|
|
1735
1337
|
*/
|
|
1736
1338
|
async list(accountId) {
|
|
1737
1339
|
const response = await this.http.get(
|
|
1738
|
-
`${accountId}/
|
|
1340
|
+
`${accountId}/audience_onboarding/my_audiences`
|
|
1739
1341
|
);
|
|
1740
1342
|
return response.results;
|
|
1741
1343
|
}
|
|
1742
1344
|
/**
|
|
1743
1345
|
* Get a single first party audience
|
|
1744
|
-
*
|
|
1745
|
-
* @param accountId - Account ID
|
|
1746
|
-
* @param audienceId - Audience ID
|
|
1747
|
-
* @returns First party audience details
|
|
1748
1346
|
*/
|
|
1749
1347
|
async get(accountId, audienceId) {
|
|
1750
1348
|
return this.http.get(
|
|
1751
|
-
`${accountId}/
|
|
1349
|
+
`${accountId}/audience_onboarding/my_audiences/${audienceId}`
|
|
1752
1350
|
);
|
|
1753
1351
|
}
|
|
1754
1352
|
/**
|
|
1755
1353
|
* Create a first party audience
|
|
1756
|
-
*
|
|
1757
|
-
* After creation, use addUsers() to populate the audience with identifiers.
|
|
1758
|
-
*
|
|
1759
|
-
* @param accountId - Account ID
|
|
1760
|
-
* @param audience - Audience configuration
|
|
1761
|
-
* @returns Created audience
|
|
1762
|
-
*
|
|
1763
|
-
* @example
|
|
1764
|
-
* ```typescript
|
|
1765
|
-
* const audience = await client.firstPartyAudiences.create('my-account', {
|
|
1766
|
-
* name: 'High-Value Customers',
|
|
1767
|
-
* description: 'Customers with LTV > $1000',
|
|
1768
|
-
* source_type: 'CRM',
|
|
1769
|
-
* ttl_days: 90
|
|
1770
|
-
* });
|
|
1771
|
-
*
|
|
1772
|
-
* // Then add users
|
|
1773
|
-
* await client.firstPartyAudiences.addUsers('my-account', audience.id, {
|
|
1774
|
-
* add: [
|
|
1775
|
-
* { identifier_type: 'EMAIL_SHA256', identifier_value: 'sha256hash1' },
|
|
1776
|
-
* { identifier_type: 'EMAIL_SHA256', identifier_value: 'sha256hash2' },
|
|
1777
|
-
* ]
|
|
1778
|
-
* });
|
|
1779
|
-
* ```
|
|
1780
1354
|
*/
|
|
1781
1355
|
async create(accountId, audience) {
|
|
1782
|
-
return this.http.post(
|
|
1783
|
-
`${accountId}/audience-onboarding/first-party-audiences`,
|
|
1784
|
-
audience
|
|
1785
|
-
);
|
|
1356
|
+
return this.http.post(`${accountId}/audience_onboarding/create`, audience);
|
|
1786
1357
|
}
|
|
1787
1358
|
/**
|
|
1788
1359
|
* Add or remove users from a first party audience
|
|
1789
|
-
*
|
|
1790
|
-
* Users are identified by hashed identifiers (email, phone, device ID).
|
|
1791
|
-
* It's recommended to use SHA256 hashed values for privacy.
|
|
1792
|
-
*
|
|
1793
|
-
* @param accountId - Account ID
|
|
1794
|
-
* @param audienceId - Audience ID
|
|
1795
|
-
* @param request - Add/remove request with user identifiers
|
|
1796
|
-
* @returns Operation result with counts
|
|
1797
|
-
*
|
|
1798
|
-
* @example
|
|
1799
|
-
* ```typescript
|
|
1800
|
-
* // Add users
|
|
1801
|
-
* const result = await client.firstPartyAudiences.addUsers('my-account', 'audience-1', {
|
|
1802
|
-
* add: [
|
|
1803
|
-
* { identifier_type: 'EMAIL_SHA256', identifier_value: 'sha256hash1' },
|
|
1804
|
-
* { identifier_type: 'EMAIL_SHA256', identifier_value: 'sha256hash2' },
|
|
1805
|
-
* ]
|
|
1806
|
-
* });
|
|
1807
|
-
* console.log(`Added ${result.added_count} users`);
|
|
1808
|
-
*
|
|
1809
|
-
* // Remove users
|
|
1810
|
-
* const result2 = await client.firstPartyAudiences.addUsers('my-account', 'audience-1', {
|
|
1811
|
-
* remove: [
|
|
1812
|
-
* { identifier_type: 'EMAIL_SHA256', identifier_value: 'sha256hash3' },
|
|
1813
|
-
* ]
|
|
1814
|
-
* });
|
|
1815
|
-
* console.log(`Removed ${result2.removed_count} users`);
|
|
1816
|
-
* ```
|
|
1817
|
-
*/
|
|
1818
|
-
async addUsers(accountId, audienceId, request) {
|
|
1819
|
-
return this.http.post(
|
|
1820
|
-
`${accountId}/audience-onboarding/first-party-audiences/${audienceId}/add-remove`,
|
|
1821
|
-
request
|
|
1822
|
-
);
|
|
1823
|
-
}
|
|
1824
|
-
/**
|
|
1825
|
-
* Remove users from a first party audience
|
|
1826
|
-
*
|
|
1827
|
-
* Convenience method that wraps addUsers with only remove operations.
|
|
1828
|
-
*
|
|
1829
|
-
* @param accountId - Account ID
|
|
1830
|
-
* @param audienceId - Audience ID
|
|
1831
|
-
* @param request - Remove request with user identifiers
|
|
1832
|
-
* @returns Operation result with counts
|
|
1833
1360
|
*/
|
|
1834
|
-
async
|
|
1835
|
-
|
|
1361
|
+
async manageUsers(accountId, request) {
|
|
1362
|
+
await this.http.post(`${accountId}/audience_onboarding/my_audiences/users`, request);
|
|
1836
1363
|
}
|
|
1837
1364
|
};
|
|
1838
1365
|
|
|
@@ -1871,7 +1398,7 @@ var PixelAPI = class {
|
|
|
1871
1398
|
*/
|
|
1872
1399
|
async getConversionRule(accountId, ruleId) {
|
|
1873
1400
|
return this.http.get(
|
|
1874
|
-
`${accountId}/universal_pixel/conversion_rule/${ruleId}`
|
|
1401
|
+
`${accountId}/universal_pixel/conversion_rule/${String(ruleId)}`
|
|
1875
1402
|
);
|
|
1876
1403
|
}
|
|
1877
1404
|
/**
|
|
@@ -1901,23 +1428,17 @@ var PixelAPI = class {
|
|
|
1901
1428
|
* // URL-based conversion rule
|
|
1902
1429
|
* const rule = await client.pixel.createConversionRule('my-account', {
|
|
1903
1430
|
* display_name: 'Purchase Completed',
|
|
1904
|
-
* type: '
|
|
1905
|
-
* category: '
|
|
1906
|
-
*
|
|
1907
|
-
*
|
|
1908
|
-
*
|
|
1909
|
-
*
|
|
1910
|
-
*
|
|
1911
|
-
* }
|
|
1912
|
-
* ],
|
|
1913
|
-
* effect: {
|
|
1914
|
-
* type: 'DYNAMIC_VALUE',
|
|
1915
|
-
* value: null,
|
|
1916
|
-
* currency: 'USD',
|
|
1917
|
-
* 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: [],
|
|
1918
1438
|
* },
|
|
1919
|
-
*
|
|
1920
|
-
*
|
|
1439
|
+
* effects: [{ type: 'REVENUE', data: '15' }],
|
|
1440
|
+
* look_back_window: 30,
|
|
1441
|
+
* view_through_look_back_window: 1,
|
|
1921
1442
|
* });
|
|
1922
1443
|
*
|
|
1923
1444
|
* // Event-based conversion rule
|
|
@@ -1926,21 +1447,12 @@ var PixelAPI = class {
|
|
|
1926
1447
|
* type: 'EVENT_BASED',
|
|
1927
1448
|
* category: 'ADD_TO_CART',
|
|
1928
1449
|
* event_name: 'add_to_cart',
|
|
1929
|
-
*
|
|
1930
|
-
* effect: {
|
|
1931
|
-
* type: 'FIXED_VALUE',
|
|
1932
|
-
* value: 10,
|
|
1933
|
-
* currency: 'USD',
|
|
1934
|
-
* value_parameter: null
|
|
1935
|
-
* }
|
|
1450
|
+
* effects: [{ type: 'REVENUE', data: '10' }],
|
|
1936
1451
|
* });
|
|
1937
1452
|
* ```
|
|
1938
1453
|
*/
|
|
1939
1454
|
async createConversionRule(accountId, rule) {
|
|
1940
|
-
return this.http.post(
|
|
1941
|
-
`${accountId}/universal_pixel/conversion_rule`,
|
|
1942
|
-
rule
|
|
1943
|
-
);
|
|
1455
|
+
return this.http.post(`${accountId}/universal_pixel/conversion_rule`, rule);
|
|
1944
1456
|
}
|
|
1945
1457
|
/**
|
|
1946
1458
|
* Update a conversion rule
|
|
@@ -1952,7 +1464,7 @@ var PixelAPI = class {
|
|
|
1952
1464
|
*/
|
|
1953
1465
|
async updateConversionRule(accountId, ruleId, updates) {
|
|
1954
1466
|
return this.http.post(
|
|
1955
|
-
`${accountId}/universal_pixel/conversion_rule/${ruleId}`,
|
|
1467
|
+
`${accountId}/universal_pixel/conversion_rule/${String(ruleId)}`,
|
|
1956
1468
|
updates
|
|
1957
1469
|
);
|
|
1958
1470
|
}
|
|
@@ -2026,37 +1538,16 @@ var PixelAPI = class {
|
|
|
2026
1538
|
*
|
|
2027
1539
|
* @example
|
|
2028
1540
|
* ```typescript
|
|
2029
|
-
* // All visitors audience
|
|
2030
1541
|
* const allVisitors = await client.pixel.createCustomAudienceRule('my-account', {
|
|
2031
1542
|
* display_name: 'All Visitors - 30 Days',
|
|
2032
1543
|
* conditions: [],
|
|
2033
|
-
* ttl_days: 30
|
|
1544
|
+
* ttl_days: 30,
|
|
2034
1545
|
* });
|
|
2035
1546
|
*
|
|
2036
|
-
* // Product page visitors
|
|
2037
1547
|
* const productViewers = await client.pixel.createCustomAudienceRule('my-account', {
|
|
2038
1548
|
* display_name: 'Product Page Viewers',
|
|
2039
|
-
* conditions: [
|
|
2040
|
-
*
|
|
2041
|
-
* type: 'URL',
|
|
2042
|
-
* operator: 'CONTAINS',
|
|
2043
|
-
* value: '/products/'
|
|
2044
|
-
* }
|
|
2045
|
-
* ],
|
|
2046
|
-
* ttl_days: 14
|
|
2047
|
-
* });
|
|
2048
|
-
*
|
|
2049
|
-
* // Cart abandoners
|
|
2050
|
-
* const cartAbandoners = await client.pixel.createCustomAudienceRule('my-account', {
|
|
2051
|
-
* display_name: 'Cart Abandoners',
|
|
2052
|
-
* conditions: [
|
|
2053
|
-
* {
|
|
2054
|
-
* type: 'EVENT_NAME',
|
|
2055
|
-
* operator: 'EQUALS',
|
|
2056
|
-
* value: 'add_to_cart'
|
|
2057
|
-
* }
|
|
2058
|
-
* ],
|
|
2059
|
-
* ttl_days: 7
|
|
1549
|
+
* conditions: [{ type: 'URL', operator: 'CONTAINS', value: '/products/' }],
|
|
1550
|
+
* ttl_days: 14,
|
|
2060
1551
|
* });
|
|
2061
1552
|
* ```
|
|
2062
1553
|
*/
|
|
@@ -2353,9 +1844,7 @@ var SharedBudgetAPI = class {
|
|
|
2353
1844
|
* ```
|
|
2354
1845
|
*/
|
|
2355
1846
|
async get(accountId, sharedBudgetId) {
|
|
2356
|
-
return this.http.get(
|
|
2357
|
-
`${accountId}/shared-budget/${sharedBudgetId}`
|
|
2358
|
-
);
|
|
1847
|
+
return this.http.get(`${accountId}/shared-budget/${sharedBudgetId}`);
|
|
2359
1848
|
}
|
|
2360
1849
|
/**
|
|
2361
1850
|
* List all shared budgets (base/partial fields)
|
|
@@ -2373,9 +1862,7 @@ var SharedBudgetAPI = class {
|
|
|
2373
1862
|
* ```
|
|
2374
1863
|
*/
|
|
2375
1864
|
async listBase(accountId) {
|
|
2376
|
-
return this.http.get(
|
|
2377
|
-
`${accountId}/shared-budget/base`
|
|
2378
|
-
);
|
|
1865
|
+
return this.http.get(`${accountId}/shared-budget/base`);
|
|
2379
1866
|
}
|
|
2380
1867
|
/**
|
|
2381
1868
|
* Create a new shared budget
|
|
@@ -2396,10 +1883,7 @@ var SharedBudgetAPI = class {
|
|
|
2396
1883
|
* ```
|
|
2397
1884
|
*/
|
|
2398
1885
|
async create(accountId, budget) {
|
|
2399
|
-
return this.http.post(
|
|
2400
|
-
`${accountId}/shared-budget`,
|
|
2401
|
-
budget
|
|
2402
|
-
);
|
|
1886
|
+
return this.http.post(`${accountId}/shared-budget`, budget);
|
|
2403
1887
|
}
|
|
2404
1888
|
/**
|
|
2405
1889
|
* Update an existing shared budget
|
|
@@ -2417,10 +1901,7 @@ var SharedBudgetAPI = class {
|
|
|
2417
1901
|
* ```
|
|
2418
1902
|
*/
|
|
2419
1903
|
async update(accountId, sharedBudgetId, updates) {
|
|
2420
|
-
return this.http.put(
|
|
2421
|
-
`${accountId}/shared-budget/${sharedBudgetId}`,
|
|
2422
|
-
updates
|
|
2423
|
-
);
|
|
1904
|
+
return this.http.put(`${accountId}/shared-budget/${sharedBudgetId}`, updates);
|
|
2424
1905
|
}
|
|
2425
1906
|
};
|
|
2426
1907
|
|