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