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