taboola-backstage-sdk 0.3.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -50
- package/dist/index.cjs +108 -680
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +447 -908
- package/dist/index.d.ts +447 -908
- package/dist/index.js +108 -680
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.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,26 +608,30 @@ 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) {
|
|
799
|
-
return this.http.post(`${accountId}/campaigns/${campaignId}/items
|
|
634
|
+
return this.http.post(`${accountId}/campaigns/${campaignId}/items`, item);
|
|
800
635
|
}
|
|
801
636
|
/**
|
|
802
637
|
* Update an existing item (static or motion ad)
|
|
@@ -890,7 +725,9 @@ 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
|
|
@@ -898,32 +735,47 @@ var ItemsAPI = class {
|
|
|
898
735
|
*
|
|
899
736
|
* @example
|
|
900
737
|
* ```typescript
|
|
901
|
-
* const response = await client.items.bulkCreate('my-account', '12345',
|
|
902
|
-
*
|
|
903
|
-
*
|
|
904
|
-
*
|
|
905
|
-
* ],
|
|
906
|
-
* });
|
|
738
|
+
* const response = await client.items.bulkCreate('my-account', '12345', [
|
|
739
|
+
* { url: 'https://example.com/page1', title: 'Title 1', thumbnail_url: '...' },
|
|
740
|
+
* { url: 'https://example.com/page2', title: 'Title 2', thumbnail_url: '...' },
|
|
741
|
+
* ]);
|
|
907
742
|
* console.log('Created', response.results.length, 'items');
|
|
908
743
|
* ```
|
|
909
744
|
*/
|
|
910
|
-
async bulkCreate(accountId, campaignId,
|
|
745
|
+
async bulkCreate(accountId, campaignId, items) {
|
|
911
746
|
return this.http.post(
|
|
912
747
|
`${accountId}/campaigns/${campaignId}/items/mass`,
|
|
913
|
-
|
|
748
|
+
items
|
|
914
749
|
);
|
|
915
750
|
}
|
|
916
751
|
/**
|
|
917
752
|
* Bulk create items across multiple campaigns
|
|
918
753
|
*
|
|
754
|
+
* Unified endpoint that supports both static ads and motion ads.
|
|
755
|
+
*
|
|
919
756
|
* @param accountId - Account ID
|
|
920
757
|
* @param items - Array of items with campaign IDs
|
|
921
758
|
*
|
|
922
|
-
* @example
|
|
759
|
+
* @example Static ads
|
|
923
760
|
* ```typescript
|
|
924
761
|
* await client.items.bulkCreateAcrossCampaigns('my-account', [
|
|
925
|
-
* { campaign_id: '12345', url: '
|
|
926
|
-
* { campaign_id: '12346', url: '
|
|
762
|
+
* { campaign_id: '12345', url: 'https://example.com/1', title: 'Title 1' },
|
|
763
|
+
* { campaign_id: '12346', url: 'https://example.com/2', title: 'Title 2' },
|
|
764
|
+
* ]);
|
|
765
|
+
* ```
|
|
766
|
+
*
|
|
767
|
+
* @example Motion ads
|
|
768
|
+
* ```typescript
|
|
769
|
+
* await client.items.bulkCreateAcrossCampaigns('my-account', [
|
|
770
|
+
* {
|
|
771
|
+
* campaign_id: '12345',
|
|
772
|
+
* url: 'https://example.com/1',
|
|
773
|
+
* title: 'Motion Ad',
|
|
774
|
+
* performance_video_data: {
|
|
775
|
+
* video_url: 'https://example.com/video.mp4',
|
|
776
|
+
* fallback_url: 'https://example.com/fallback.jpg',
|
|
777
|
+
* },
|
|
778
|
+
* },
|
|
927
779
|
* ]);
|
|
928
780
|
* ```
|
|
929
781
|
*/
|
|
@@ -1027,15 +879,11 @@ var DictionaryAPI = class {
|
|
|
1027
879
|
* Get list of all supported countries
|
|
1028
880
|
*/
|
|
1029
881
|
async getCountries() {
|
|
1030
|
-
const response = await this.http.get(
|
|
1031
|
-
"resources/countries"
|
|
1032
|
-
);
|
|
882
|
+
const response = await this.http.get("resources/countries");
|
|
1033
883
|
return response.results;
|
|
1034
884
|
}
|
|
1035
885
|
/**
|
|
1036
886
|
* Get regions/states within a country
|
|
1037
|
-
*
|
|
1038
|
-
* @param countryCode - Country code (e.g., 'US', 'GB')
|
|
1039
887
|
*/
|
|
1040
888
|
async getRegions(countryCode) {
|
|
1041
889
|
const response = await this.http.get(
|
|
@@ -1045,9 +893,6 @@ var DictionaryAPI = class {
|
|
|
1045
893
|
}
|
|
1046
894
|
/**
|
|
1047
895
|
* Get DMAs (Designated Market Areas) for a country
|
|
1048
|
-
* Note: Only available for US
|
|
1049
|
-
*
|
|
1050
|
-
* @param countryCode - Country code (typically 'US')
|
|
1051
896
|
*/
|
|
1052
897
|
async getDMAs(countryCode) {
|
|
1053
898
|
const response = await this.http.get(
|
|
@@ -1057,9 +902,6 @@ var DictionaryAPI = class {
|
|
|
1057
902
|
}
|
|
1058
903
|
/**
|
|
1059
904
|
* 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
905
|
*/
|
|
1064
906
|
async getPostalCodes(countryCode, params) {
|
|
1065
907
|
const searchParams = new URLSearchParams();
|
|
@@ -1083,9 +925,7 @@ var DictionaryAPI = class {
|
|
|
1083
925
|
* Get list of supported platforms
|
|
1084
926
|
*/
|
|
1085
927
|
async getPlatforms() {
|
|
1086
|
-
const response = await this.http.get(
|
|
1087
|
-
"resources/platforms"
|
|
1088
|
-
);
|
|
928
|
+
const response = await this.http.get("resources/platforms");
|
|
1089
929
|
return response.results;
|
|
1090
930
|
}
|
|
1091
931
|
/**
|
|
@@ -1119,9 +959,7 @@ var DictionaryAPI = class {
|
|
|
1119
959
|
* Get list of supported browsers
|
|
1120
960
|
*/
|
|
1121
961
|
async getBrowsers() {
|
|
1122
|
-
const response = await this.http.get(
|
|
1123
|
-
"resources/browsers"
|
|
1124
|
-
);
|
|
962
|
+
const response = await this.http.get("resources/browsers");
|
|
1125
963
|
return response.results;
|
|
1126
964
|
}
|
|
1127
965
|
// ===== Enums =====
|
|
@@ -1141,9 +979,7 @@ var DictionaryAPI = class {
|
|
|
1141
979
|
* Get days of week for activity scheduling
|
|
1142
980
|
*/
|
|
1143
981
|
async getDaysOfWeek() {
|
|
1144
|
-
const response = await this.http.get(
|
|
1145
|
-
"resources/days-of-week"
|
|
1146
|
-
);
|
|
982
|
+
const response = await this.http.get("resources/days-of-week");
|
|
1147
983
|
return response.results;
|
|
1148
984
|
}
|
|
1149
985
|
// ===== Possible Values =====
|
|
@@ -1178,9 +1014,7 @@ var DictionaryAPI = class {
|
|
|
1178
1014
|
* Get minimum CPC values per country/platform
|
|
1179
1015
|
*/
|
|
1180
1016
|
async getMinimumCPCs() {
|
|
1181
|
-
const response = await this.http.get(
|
|
1182
|
-
"resources/minimum-cpc"
|
|
1183
|
-
);
|
|
1017
|
+
const response = await this.http.get("resources/minimum-cpc");
|
|
1184
1018
|
return response.results;
|
|
1185
1019
|
}
|
|
1186
1020
|
// ===== Image Library =====
|
|
@@ -1195,8 +1029,6 @@ var DictionaryAPI = class {
|
|
|
1195
1029
|
}
|
|
1196
1030
|
/**
|
|
1197
1031
|
* Get image taxonomies for categorizing images
|
|
1198
|
-
*
|
|
1199
|
-
* @param accountId - Account ID
|
|
1200
1032
|
*/
|
|
1201
1033
|
async getImageTaxonomies(accountId) {
|
|
1202
1034
|
const response = await this.http.get(
|
|
@@ -1207,58 +1039,46 @@ var DictionaryAPI = class {
|
|
|
1207
1039
|
// ===== Audience Targeting =====
|
|
1208
1040
|
/**
|
|
1209
1041
|
* Get marketplace audience segments available for targeting
|
|
1210
|
-
*
|
|
1211
|
-
* @param accountId - Account ID
|
|
1212
1042
|
*/
|
|
1213
1043
|
async getMarketplaceAudiences(accountId) {
|
|
1214
1044
|
const response = await this.http.get(
|
|
1215
|
-
`${accountId}/dictionary/
|
|
1045
|
+
`${accountId}/dictionary/audience_segments`
|
|
1216
1046
|
);
|
|
1217
1047
|
return response.results;
|
|
1218
1048
|
}
|
|
1219
1049
|
/**
|
|
1220
1050
|
* Get marketplace audience segments for a specific country
|
|
1221
|
-
*
|
|
1222
|
-
* @param accountId - Account ID
|
|
1223
|
-
* @param countryCode - Country code (e.g., 'US', 'GB')
|
|
1224
1051
|
*/
|
|
1225
1052
|
async getMarketplaceAudiencesByCountry(accountId, countryCode) {
|
|
1226
1053
|
const response = await this.http.get(
|
|
1227
|
-
`${accountId}/dictionary/
|
|
1054
|
+
`${accountId}/dictionary/audience_segments/${countryCode}`
|
|
1228
1055
|
);
|
|
1229
1056
|
return response.results;
|
|
1230
1057
|
}
|
|
1231
1058
|
/**
|
|
1232
1059
|
* Get lookalike audiences available for targeting
|
|
1233
|
-
*
|
|
1234
|
-
* @param accountId - Account ID
|
|
1235
1060
|
*/
|
|
1236
1061
|
async getLookalikeAudiences(accountId) {
|
|
1237
1062
|
const response = await this.http.get(
|
|
1238
|
-
`${accountId}/dictionary/
|
|
1063
|
+
`${accountId}/dictionary/lookalike_audiences`
|
|
1239
1064
|
);
|
|
1240
1065
|
return response.results;
|
|
1241
1066
|
}
|
|
1242
1067
|
/**
|
|
1243
1068
|
* Get lookalike audiences for a specific country
|
|
1244
|
-
*
|
|
1245
|
-
* @param accountId - Account ID
|
|
1246
|
-
* @param countryCode - Country code (e.g., 'US', 'GB')
|
|
1247
1069
|
*/
|
|
1248
1070
|
async getLookalikeAudiencesByCountry(accountId, countryCode) {
|
|
1249
1071
|
const response = await this.http.get(
|
|
1250
|
-
`${accountId}/dictionary/
|
|
1072
|
+
`${accountId}/dictionary/lookalike_audiences/${countryCode}`
|
|
1251
1073
|
);
|
|
1252
1074
|
return response.results;
|
|
1253
1075
|
}
|
|
1254
1076
|
/**
|
|
1255
1077
|
* Get contextual segments available for targeting
|
|
1256
|
-
*
|
|
1257
|
-
* @param accountId - Account ID
|
|
1258
1078
|
*/
|
|
1259
1079
|
async getContextualSegments(accountId) {
|
|
1260
1080
|
const response = await this.http.get(
|
|
1261
|
-
`${accountId}/dictionary/
|
|
1081
|
+
`${accountId}/dictionary/contextual_segments`
|
|
1262
1082
|
);
|
|
1263
1083
|
return response.results;
|
|
1264
1084
|
}
|
|
@@ -1271,116 +1091,55 @@ var PublishersAPI = class {
|
|
|
1271
1091
|
}
|
|
1272
1092
|
/**
|
|
1273
1093
|
* 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
1094
|
*/
|
|
1284
1095
|
async list(accountId) {
|
|
1285
|
-
const response = await this.http.get(
|
|
1286
|
-
`${accountId}/publishers`
|
|
1287
|
-
);
|
|
1096
|
+
const response = await this.http.get(`${accountId}/allowed-publishers`);
|
|
1288
1097
|
return response.results;
|
|
1289
1098
|
}
|
|
1290
1099
|
/**
|
|
1291
1100
|
* 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
1101
|
*/
|
|
1302
1102
|
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 ?? [];
|
|
1103
|
+
const response = await this.http.get(`${accountId}/block-publisher`);
|
|
1104
|
+
return response.sites;
|
|
1310
1105
|
}
|
|
1311
1106
|
/**
|
|
1312
1107
|
* Update blocked publishers at the account level
|
|
1313
1108
|
*
|
|
1314
1109
|
* 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
|
-
* ```
|
|
1110
|
+
* provided list.
|
|
1336
1111
|
*/
|
|
1337
1112
|
async updateBlocked(accountId, request) {
|
|
1338
1113
|
const response = await this.http.post(
|
|
1339
1114
|
`${accountId}/block-publisher`,
|
|
1340
1115
|
request
|
|
1341
1116
|
);
|
|
1342
|
-
return response.
|
|
1117
|
+
return response.sites;
|
|
1343
1118
|
}
|
|
1344
1119
|
/**
|
|
1345
1120
|
* 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
1121
|
*/
|
|
1353
1122
|
async blockPublisher(accountId, site) {
|
|
1354
1123
|
const current = await this.getBlocked(accountId);
|
|
1355
|
-
|
|
1356
|
-
if (currentSites.includes(site)) {
|
|
1124
|
+
if (current.includes(site)) {
|
|
1357
1125
|
return current;
|
|
1358
1126
|
}
|
|
1359
1127
|
return this.updateBlocked(accountId, {
|
|
1360
|
-
sites: [...
|
|
1128
|
+
sites: [...current, site]
|
|
1361
1129
|
});
|
|
1362
1130
|
}
|
|
1363
1131
|
/**
|
|
1364
1132
|
* 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
1133
|
*/
|
|
1372
1134
|
async unblockPublisher(accountId, site) {
|
|
1373
1135
|
const current = await this.getBlocked(accountId);
|
|
1374
|
-
const filteredSites = current.
|
|
1136
|
+
const filteredSites = current.filter((s) => s !== site);
|
|
1375
1137
|
return this.updateBlocked(accountId, {
|
|
1376
1138
|
sites: filteredSites
|
|
1377
1139
|
});
|
|
1378
1140
|
}
|
|
1379
1141
|
/**
|
|
1380
1142
|
* Clear all blocked publishers at the account level
|
|
1381
|
-
*
|
|
1382
|
-
* @param accountId - Account ID
|
|
1383
|
-
* @returns Empty list
|
|
1384
1143
|
*/
|
|
1385
1144
|
async clearBlocked(accountId) {
|
|
1386
1145
|
return this.updateBlocked(accountId, { sites: [] });
|
|
@@ -1395,17 +1154,6 @@ var TargetingAPI = class {
|
|
|
1395
1154
|
// ===== Postal Code Targeting =====
|
|
1396
1155
|
/**
|
|
1397
1156
|
* 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
1157
|
*/
|
|
1410
1158
|
async getPostalCodes(accountId, campaignId) {
|
|
1411
1159
|
return this.http.get(
|
|
@@ -1414,22 +1162,6 @@ var TargetingAPI = class {
|
|
|
1414
1162
|
}
|
|
1415
1163
|
/**
|
|
1416
1164
|
* 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
1165
|
*/
|
|
1434
1166
|
async updatePostalCodes(accountId, campaignId, targeting) {
|
|
1435
1167
|
return this.http.post(
|
|
@@ -1440,13 +1172,6 @@ var TargetingAPI = class {
|
|
|
1440
1172
|
// ===== Marketplace Audience Targeting =====
|
|
1441
1173
|
/**
|
|
1442
1174
|
* 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
1175
|
*/
|
|
1451
1176
|
async getMarketplaceAudiences(accountId, campaignId) {
|
|
1452
1177
|
return this.http.get(
|
|
@@ -1455,22 +1180,6 @@ var TargetingAPI = class {
|
|
|
1455
1180
|
}
|
|
1456
1181
|
/**
|
|
1457
1182
|
* 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
1183
|
*/
|
|
1475
1184
|
async updateMarketplaceAudiences(accountId, campaignId, targeting) {
|
|
1476
1185
|
return this.http.post(
|
|
@@ -1481,13 +1190,6 @@ var TargetingAPI = class {
|
|
|
1481
1190
|
// ===== Custom Audience Targeting =====
|
|
1482
1191
|
/**
|
|
1483
1192
|
* 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
1193
|
*/
|
|
1492
1194
|
async getCustomAudiences(accountId, campaignId) {
|
|
1493
1195
|
return this.http.get(
|
|
@@ -1496,11 +1198,6 @@ var TargetingAPI = class {
|
|
|
1496
1198
|
}
|
|
1497
1199
|
/**
|
|
1498
1200
|
* 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
1201
|
*/
|
|
1505
1202
|
async updateCustomAudiences(accountId, campaignId, targeting) {
|
|
1506
1203
|
return this.http.post(
|
|
@@ -1511,13 +1208,6 @@ var TargetingAPI = class {
|
|
|
1511
1208
|
// ===== Lookalike Audience Targeting =====
|
|
1512
1209
|
/**
|
|
1513
1210
|
* 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
1211
|
*/
|
|
1522
1212
|
async getLookalikeAudiences(accountId, campaignId) {
|
|
1523
1213
|
return this.http.get(
|
|
@@ -1526,11 +1216,6 @@ var TargetingAPI = class {
|
|
|
1526
1216
|
}
|
|
1527
1217
|
/**
|
|
1528
1218
|
* 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
1219
|
*/
|
|
1535
1220
|
async updateLookalikeAudiences(accountId, campaignId, targeting) {
|
|
1536
1221
|
return this.http.post(
|
|
@@ -1541,13 +1226,6 @@ var TargetingAPI = class {
|
|
|
1541
1226
|
// ===== Contextual Targeting =====
|
|
1542
1227
|
/**
|
|
1543
1228
|
* 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
1229
|
*/
|
|
1552
1230
|
async getContextual(accountId, campaignId) {
|
|
1553
1231
|
return this.http.get(
|
|
@@ -1556,22 +1234,6 @@ var TargetingAPI = class {
|
|
|
1556
1234
|
}
|
|
1557
1235
|
/**
|
|
1558
1236
|
* 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
1237
|
*/
|
|
1576
1238
|
async updateContextual(accountId, campaignId, targeting) {
|
|
1577
1239
|
return this.http.post(
|
|
@@ -1582,12 +1244,6 @@ var TargetingAPI = class {
|
|
|
1582
1244
|
// ===== First Party Audience Targeting =====
|
|
1583
1245
|
/**
|
|
1584
1246
|
* 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
1247
|
*/
|
|
1592
1248
|
async getFirstPartyAudiences(accountId, campaignId) {
|
|
1593
1249
|
return this.http.get(
|
|
@@ -1596,11 +1252,6 @@ var TargetingAPI = class {
|
|
|
1596
1252
|
}
|
|
1597
1253
|
/**
|
|
1598
1254
|
* 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
1255
|
*/
|
|
1605
1256
|
async updateFirstPartyAudiences(accountId, campaignId, targeting) {
|
|
1606
1257
|
return this.http.post(
|
|
@@ -1611,19 +1262,6 @@ var TargetingAPI = class {
|
|
|
1611
1262
|
// ===== Marking Labels Targeting =====
|
|
1612
1263
|
/**
|
|
1613
1264
|
* 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
1265
|
*/
|
|
1628
1266
|
async getMarkingLabels(accountId, campaignId) {
|
|
1629
1267
|
return this.http.get(
|
|
@@ -1632,19 +1270,6 @@ var TargetingAPI = class {
|
|
|
1632
1270
|
}
|
|
1633
1271
|
/**
|
|
1634
1272
|
* 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
1273
|
*/
|
|
1649
1274
|
async updateMarkingLabels(accountId, campaignId, targeting) {
|
|
1650
1275
|
return this.http.post(
|
|
@@ -1661,105 +1286,40 @@ var CombinedAudiencesAPI = class {
|
|
|
1661
1286
|
}
|
|
1662
1287
|
/**
|
|
1663
1288
|
* 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
1289
|
*/
|
|
1677
1290
|
async listAvailable(accountId) {
|
|
1678
1291
|
const response = await this.http.get(
|
|
1679
|
-
`${accountId}/
|
|
1292
|
+
`${accountId}/combined_audiences/resources/audiences`
|
|
1680
1293
|
);
|
|
1681
1294
|
return response.results;
|
|
1682
1295
|
}
|
|
1683
1296
|
/**
|
|
1684
1297
|
* 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
1298
|
*/
|
|
1697
1299
|
async list(accountId) {
|
|
1698
1300
|
const response = await this.http.get(
|
|
1699
|
-
`${accountId}/
|
|
1301
|
+
`${accountId}/combined_audiences`
|
|
1700
1302
|
);
|
|
1701
1303
|
return response.results;
|
|
1702
1304
|
}
|
|
1703
1305
|
/**
|
|
1704
1306
|
* Get a single combined audience
|
|
1705
|
-
*
|
|
1706
|
-
* @param accountId - Account ID
|
|
1707
|
-
* @param audienceId - Combined audience ID
|
|
1708
|
-
* @returns Combined audience details
|
|
1709
1307
|
*/
|
|
1710
1308
|
async get(accountId, audienceId) {
|
|
1711
|
-
return this.http.get(
|
|
1712
|
-
`${accountId}/combined-audiences/${audienceId}`
|
|
1713
|
-
);
|
|
1309
|
+
return this.http.get(`${accountId}/combined_audiences/${audienceId}`);
|
|
1714
1310
|
}
|
|
1715
1311
|
/**
|
|
1716
1312
|
* 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
1313
|
*/
|
|
1746
1314
|
async create(accountId, audience) {
|
|
1747
|
-
return this.http.post(
|
|
1748
|
-
`${accountId}/combined-audiences`,
|
|
1749
|
-
audience
|
|
1750
|
-
);
|
|
1315
|
+
return this.http.post(`${accountId}/combined_audiences`, audience);
|
|
1751
1316
|
}
|
|
1752
1317
|
/**
|
|
1753
1318
|
* 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
1319
|
*/
|
|
1760
1320
|
async update(accountId, audienceId, updates) {
|
|
1761
1321
|
return this.http.post(
|
|
1762
|
-
`${accountId}/
|
|
1322
|
+
`${accountId}/combined_audiences/${audienceId}`,
|
|
1763
1323
|
updates
|
|
1764
1324
|
);
|
|
1765
1325
|
}
|
|
@@ -1772,118 +1332,32 @@ var FirstPartyAudiencesAPI = class {
|
|
|
1772
1332
|
}
|
|
1773
1333
|
/**
|
|
1774
1334
|
* 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
1335
|
*/
|
|
1787
1336
|
async list(accountId) {
|
|
1788
1337
|
const response = await this.http.get(
|
|
1789
|
-
`${accountId}/
|
|
1338
|
+
`${accountId}/audience_onboarding/my_audiences`
|
|
1790
1339
|
);
|
|
1791
1340
|
return response.results;
|
|
1792
1341
|
}
|
|
1793
1342
|
/**
|
|
1794
1343
|
* Get a single first party audience
|
|
1795
|
-
*
|
|
1796
|
-
* @param accountId - Account ID
|
|
1797
|
-
* @param audienceId - Audience ID
|
|
1798
|
-
* @returns First party audience details
|
|
1799
1344
|
*/
|
|
1800
1345
|
async get(accountId, audienceId) {
|
|
1801
1346
|
return this.http.get(
|
|
1802
|
-
`${accountId}/
|
|
1347
|
+
`${accountId}/audience_onboarding/my_audiences/${audienceId}`
|
|
1803
1348
|
);
|
|
1804
1349
|
}
|
|
1805
1350
|
/**
|
|
1806
1351
|
* 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
1352
|
*/
|
|
1832
1353
|
async create(accountId, audience) {
|
|
1833
|
-
return this.http.post(
|
|
1834
|
-
`${accountId}/audience-onboarding/first-party-audiences`,
|
|
1835
|
-
audience
|
|
1836
|
-
);
|
|
1354
|
+
return this.http.post(`${accountId}/audience_onboarding/create`, audience);
|
|
1837
1355
|
}
|
|
1838
1356
|
/**
|
|
1839
1357
|
* 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
1358
|
*/
|
|
1885
|
-
async
|
|
1886
|
-
|
|
1359
|
+
async manageUsers(accountId, request) {
|
|
1360
|
+
await this.http.post(`${accountId}/audience_onboarding/my_audiences/users`, request);
|
|
1887
1361
|
}
|
|
1888
1362
|
};
|
|
1889
1363
|
|
|
@@ -1922,7 +1396,7 @@ var PixelAPI = class {
|
|
|
1922
1396
|
*/
|
|
1923
1397
|
async getConversionRule(accountId, ruleId) {
|
|
1924
1398
|
return this.http.get(
|
|
1925
|
-
`${accountId}/universal_pixel/conversion_rule/${ruleId}`
|
|
1399
|
+
`${accountId}/universal_pixel/conversion_rule/${String(ruleId)}`
|
|
1926
1400
|
);
|
|
1927
1401
|
}
|
|
1928
1402
|
/**
|
|
@@ -1952,23 +1426,17 @@ var PixelAPI = class {
|
|
|
1952
1426
|
* // URL-based conversion rule
|
|
1953
1427
|
* const rule = await client.pixel.createConversionRule('my-account', {
|
|
1954
1428
|
* 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'
|
|
1429
|
+
* type: 'BASIC',
|
|
1430
|
+
* category: 'MAKE_PURCHASE',
|
|
1431
|
+
* condition: {
|
|
1432
|
+
* property: 'URL',
|
|
1433
|
+
* predicate: 'CONTAINS',
|
|
1434
|
+
* value: '/thank-you',
|
|
1435
|
+
* children: [],
|
|
1969
1436
|
* },
|
|
1970
|
-
*
|
|
1971
|
-
*
|
|
1437
|
+
* effects: [{ type: 'REVENUE', data: '15' }],
|
|
1438
|
+
* look_back_window: 30,
|
|
1439
|
+
* view_through_look_back_window: 1,
|
|
1972
1440
|
* });
|
|
1973
1441
|
*
|
|
1974
1442
|
* // Event-based conversion rule
|
|
@@ -1977,21 +1445,12 @@ var PixelAPI = class {
|
|
|
1977
1445
|
* type: 'EVENT_BASED',
|
|
1978
1446
|
* category: 'ADD_TO_CART',
|
|
1979
1447
|
* event_name: 'add_to_cart',
|
|
1980
|
-
*
|
|
1981
|
-
* effect: {
|
|
1982
|
-
* type: 'FIXED_VALUE',
|
|
1983
|
-
* value: 10,
|
|
1984
|
-
* currency: 'USD',
|
|
1985
|
-
* value_parameter: null
|
|
1986
|
-
* }
|
|
1448
|
+
* effects: [{ type: 'REVENUE', data: '10' }],
|
|
1987
1449
|
* });
|
|
1988
1450
|
* ```
|
|
1989
1451
|
*/
|
|
1990
1452
|
async createConversionRule(accountId, rule) {
|
|
1991
|
-
return this.http.post(
|
|
1992
|
-
`${accountId}/universal_pixel/conversion_rule`,
|
|
1993
|
-
rule
|
|
1994
|
-
);
|
|
1453
|
+
return this.http.post(`${accountId}/universal_pixel/conversion_rule`, rule);
|
|
1995
1454
|
}
|
|
1996
1455
|
/**
|
|
1997
1456
|
* Update a conversion rule
|
|
@@ -2003,7 +1462,7 @@ var PixelAPI = class {
|
|
|
2003
1462
|
*/
|
|
2004
1463
|
async updateConversionRule(accountId, ruleId, updates) {
|
|
2005
1464
|
return this.http.post(
|
|
2006
|
-
`${accountId}/universal_pixel/conversion_rule/${ruleId}`,
|
|
1465
|
+
`${accountId}/universal_pixel/conversion_rule/${String(ruleId)}`,
|
|
2007
1466
|
updates
|
|
2008
1467
|
);
|
|
2009
1468
|
}
|
|
@@ -2077,37 +1536,16 @@ var PixelAPI = class {
|
|
|
2077
1536
|
*
|
|
2078
1537
|
* @example
|
|
2079
1538
|
* ```typescript
|
|
2080
|
-
* // All visitors audience
|
|
2081
1539
|
* const allVisitors = await client.pixel.createCustomAudienceRule('my-account', {
|
|
2082
1540
|
* display_name: 'All Visitors - 30 Days',
|
|
2083
1541
|
* conditions: [],
|
|
2084
|
-
* ttl_days: 30
|
|
1542
|
+
* ttl_days: 30,
|
|
2085
1543
|
* });
|
|
2086
1544
|
*
|
|
2087
|
-
* // Product page visitors
|
|
2088
1545
|
* const productViewers = await client.pixel.createCustomAudienceRule('my-account', {
|
|
2089
1546
|
* 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
|
|
1547
|
+
* conditions: [{ type: 'URL', operator: 'CONTAINS', value: '/products/' }],
|
|
1548
|
+
* ttl_days: 14,
|
|
2111
1549
|
* });
|
|
2112
1550
|
* ```
|
|
2113
1551
|
*/
|
|
@@ -2404,9 +1842,7 @@ var SharedBudgetAPI = class {
|
|
|
2404
1842
|
* ```
|
|
2405
1843
|
*/
|
|
2406
1844
|
async get(accountId, sharedBudgetId) {
|
|
2407
|
-
return this.http.get(
|
|
2408
|
-
`${accountId}/shared-budget/${sharedBudgetId}`
|
|
2409
|
-
);
|
|
1845
|
+
return this.http.get(`${accountId}/shared-budget/${sharedBudgetId}`);
|
|
2410
1846
|
}
|
|
2411
1847
|
/**
|
|
2412
1848
|
* List all shared budgets (base/partial fields)
|
|
@@ -2424,9 +1860,7 @@ var SharedBudgetAPI = class {
|
|
|
2424
1860
|
* ```
|
|
2425
1861
|
*/
|
|
2426
1862
|
async listBase(accountId) {
|
|
2427
|
-
return this.http.get(
|
|
2428
|
-
`${accountId}/shared-budget/base`
|
|
2429
|
-
);
|
|
1863
|
+
return this.http.get(`${accountId}/shared-budget/base`);
|
|
2430
1864
|
}
|
|
2431
1865
|
/**
|
|
2432
1866
|
* Create a new shared budget
|
|
@@ -2447,10 +1881,7 @@ var SharedBudgetAPI = class {
|
|
|
2447
1881
|
* ```
|
|
2448
1882
|
*/
|
|
2449
1883
|
async create(accountId, budget) {
|
|
2450
|
-
return this.http.post(
|
|
2451
|
-
`${accountId}/shared-budget`,
|
|
2452
|
-
budget
|
|
2453
|
-
);
|
|
1884
|
+
return this.http.post(`${accountId}/shared-budget`, budget);
|
|
2454
1885
|
}
|
|
2455
1886
|
/**
|
|
2456
1887
|
* Update an existing shared budget
|
|
@@ -2468,10 +1899,7 @@ var SharedBudgetAPI = class {
|
|
|
2468
1899
|
* ```
|
|
2469
1900
|
*/
|
|
2470
1901
|
async update(accountId, sharedBudgetId, updates) {
|
|
2471
|
-
return this.http.put(
|
|
2472
|
-
`${accountId}/shared-budget/${sharedBudgetId}`,
|
|
2473
|
-
updates
|
|
2474
|
-
);
|
|
1902
|
+
return this.http.put(`${accountId}/shared-budget/${sharedBudgetId}`, updates);
|
|
2475
1903
|
}
|
|
2476
1904
|
};
|
|
2477
1905
|
|