@adobe/aio-lib-target

中文文档
4.0.3发布于 2026/03/31CommonJS近 30 天下载 2.4万

Adobe Target SDK

原始使用文档
文档目录47 节
  1. Installing
  2. Target API Technical Requirements
  3. User-based OAuth Tokens and Role Requirements
  4. Usage
  5. Classes
  6. Functions
  7. TargetCoreAPI
  8. targetCoreAPI.init(tenant, apiKey, token) ⇒ TargetCoreAPI
  9. targetCoreAPI.getActivities([options]) ⇒ Promise.<Response>
  10. targetCoreAPI.createABActivity(body, [options]) ⇒ Promise.<…
  11. targetCoreAPI.createXTActivity(body, [options]) ⇒ Promise.<…
  12. targetCoreAPI.getABActivityById(id, [options]) ⇒ Promise.<R…
  13. targetCoreAPI.getXTActivityById(id, [options]) ⇒ Promise.<R…
  14. targetCoreAPI.updateABActivity(id, body, [options]) ⇒ Promi…
  15. targetCoreAPI.updateXTActivity(id, body, [options]) ⇒ Promi…
  16. targetCoreAPI.setActivityName(id, name, [options]) ⇒ Promis…
  17. targetCoreAPI.setActivityState(id, state, [options]) ⇒ Prom…
  18. targetCoreAPI.setActivityPriority(id, priority, [options]) …
  19. targetCoreAPI.setActivitySchedule(id, schedule, [options]) …
  20. targetCoreAPI.deleteABActivity(id, [options]) ⇒ Promise.<Re…
  21. targetCoreAPI.deleteXTActivity(id, [options]) ⇒ Promise.<Re…
  22. targetCoreAPI.getActivityChangeLog(id, [options]) ⇒ Promise…
  23. targetCoreAPI.getOffers([options]) ⇒ Promise.<Response>
  24. targetCoreAPI.getOfferById(id, [options]) ⇒ Promise.<Respon…
  25. targetCoreAPI.createOffer(body, [options]) ⇒ Promise.<Respo…
  26. targetCoreAPI.updateOffer(id, body, [options]) ⇒ Promise.<R…
  27. targetCoreAPI.deleteOffer(id, [options]) ⇒ Promise.<Respons…
  28. targetCoreAPI.getAudiences([options]) ⇒ Promise.<Response>
  29. targetCoreAPI.createAudience(body, [options]) ⇒ Promise.<Re…
  30. targetCoreAPI.getAudienceById(id, [options]) ⇒ Promise.<Res…
  31. targetCoreAPI.updateAudience(id, body, [options]) ⇒ Promise…
  32. targetCoreAPI.deleteAudience(id, [options]) ⇒ Promise.<Resp…
  33. targetCoreAPI.getProperties([options]) ⇒ Promise.<Response>
  34. targetCoreAPI.getPropertyById(id, [options]) ⇒ Promise.<Res…
  35. targetCoreAPI.getMBoxes([options]) ⇒ Promise.<Response>
  36. targetCoreAPI.getMBoxByName(name, [options]) ⇒ Promise.<Res…
  37. targetCoreAPI.getMBoxProfileAttributes([options]) ⇒ Promise…
  38. targetCoreAPI.getEnvironments([options]) ⇒ Promise.<Respons…
  39. targetCoreAPI.getABActivityPerformance(id, [options]) ⇒ Pro…
  40. targetCoreAPI.getXTActivityPerformance(id, [options]) ⇒ Pro…
  41. targetCoreAPI.getActivityPerformance(id, [options]) ⇒ Promi…
  42. targetCoreAPI.getOrdersReport(id, [options]) ⇒ Promise.<Res…
  43. targetCoreAPI.executeBatch(body) ⇒ Promise.<Response>
  44. init(tenant, apiKey, token) ⇒ Promise.<TargetCoreAPI>
  45. Debug Logs
  46. Contributing
  47. Licensing

Version Downloads/week Node.js CI License Codecov Coverage

I/O Adobe Target SDK

Node Javascript Core SDK wrapping Adobe Target APIs.

Installing

$ npm install

Target API Technical Requirements

The Adobe Target 1.0 APIs need to set an Accepts header for them to work properly. With version 2.x or greater of this SDK, we set the proper Accepts header for the calls as documented. Previous versions of this SDK may or may not work since for some Target API calls the Accepts header is not enforced consistently.

User-based OAuth Tokens and Role Requirements

For scenarios in which user-based OAuth tokens are used instead of a JWT technical account ones, the user may require specific roles/permissions to be assigned in Adobe Target in order to successfully perform API calls. Otherwise, the Adobe Target API calls performed by the API Client will result in 500 errors.

For more detailed information, please read the Adobe Target Enterprise user permissions documentation.

Usage

  1. Initialize the SDK
var sdk = require('@adobe/aio-lib-target')

async function sdkTest() {
  //initialize sdk
  const targetClient = await sdk.init('<tenant>', 'x-api-key', '<valid auth token>')
}

Init method returns an Instance of Class TargetCoreAPI

  1. Call methods using initialized sdk
var sdk = require('@adobe/aio-lib-target')

async function sdkTest() {
    //initialize sdk
    const targetClient = await sdk.init('<tenant>', 'x-api-key', '<valid auth token>')

    //get activities
    const activities = await targetClient.getActivities({limit:5, offset:0})
    console.log(util.inspect(activities));

    //get offers
    const offers = await targetClient.getOffers({limit:5, offset:0})
    console.log(util.inspect(offers));

     //get offer by id activity
     const offer = await targetClient.getOfferById(123)
     console.log(util.inspect(offer));
}

All Methods available under sdk are documented here

Classes

TargetCoreAPI

This class provides methods to call Adobe Target APIs. Before calling any method initialize the instance by calling init method on it with valid tenant, apiKey and auth token

Functions

init(tenant, apiKey, token) ⇒ Promise.<TargetCoreAPI>

Returns a Promise that resolves with a new TargetCoreAPI object.

TargetCoreAPI

This class provides methods to call Adobe Target APIs. Before calling any method initialize the instance by calling init method on it with valid tenant, apiKey and auth token

Kind: global class

targetCoreAPI.init(tenant, apiKey, token) ⇒ TargetCoreAPI

Initialize sdk.

Kind: instance method of TargetCoreAPI
Returns: TargetCoreAPI - a TargetCoreAPI instance

ParamTypeDescription
tenantstringAdobe Target tenant name
apiKeystringYour api key
tokenstringValid auth token

targetCoreAPI.getActivities([options]) ⇒ Promise.<Response>

List activities. Get a list of activities created in your Target account, with the ability to filter and sort by attributes.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDefaultDescription
[options]objectto control activity search
[options.limit]number2147483647Defines the number of items to return
[options.offset]number0Defines the first activity to return from the list of total activities. Used in conjunction with limit, you can provide pagination in your application for users to browse through a large set of activities.
[options.sortBy]stringDefines the sorting criteria on the returned items
[options.headers]objectheaders to pass to API call

targetCoreAPI.createABActivity(body, [options]) ⇒ Promise.<Response>

Create AB Activity. Creates a new AB activity with the specified contents and returns the created activity.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
bodyobjectActivity JSON.
[options]objectsdk options
[options.headers]objectheaders to pass to API call

targetCoreAPI.createXTActivity(body, [options]) ⇒ Promise.<Response>

Create XT Activity. Creates a new XT activity with the specified contents and returns the created activity.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
bodyobjectActivity JSON.
[options]objectsdk options
[options.headers]objectheaders to pass to API call

targetCoreAPI.getABActivityById(id, [options]) ⇒ Promise.<Response>

Get AB activity. Fetch the current definition of an AB activity if it is found as referenced by the id.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberActivity id.
[options]objectsdk options
[options.headers]objectheaders to pass to API call

targetCoreAPI.getXTActivityById(id, [options]) ⇒ Promise.<Response>

Get XT activity. Fetch the current definition of XT activity if it is found as referenced by the id.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberActivity id.
[options]objectsdk options
[options.headers]objectheaders to pass to API call

targetCoreAPI.updateABActivity(id, body, [options]) ⇒ Promise.<Response>

Update AB activity. Updates the AB activity definition with the contents as provided in the request. This can change the state and behaviour of an existing activity.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberActivity id.
bodyobjectactivity JSON
[options]objectsdk options
[options.headers]objectheaders to pass to API call

targetCoreAPI.updateXTActivity(id, body, [options]) ⇒ Promise.<Response>

Update XT activity. Update the current definition of XT activity if it is found as referenced by the id.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberActivity id.
bodyobjectactivity JSON
[options]objectsdk options
[options.headers]objectheaders to pass to API call

targetCoreAPI.setActivityName(id, name, [options]) ⇒ Promise.<Response>

Update activity name. Updates the name of the AB activity that is referenced by the supplied id.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberActivity id.
namestringNew Activity name.
[options]objectsdk options
[options.headers]objectheaders to pass to API call

targetCoreAPI.setActivityState(id, state, [options]) ⇒ Promise.<Response>

Update Activity state. Update state of an activity if it is found as referenced by the id.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberActivity id.
statestringNew Activity state.
[options]objectsdk options
[options.headers]objectheaders to pass to API call

targetCoreAPI.setActivityPriority(id, priority, [options]) ⇒ Promise.<Response>

Update Activity priority. Update priority of an activity if it is found as referenced by the id.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberActivity id.
prioritystringNew Activity priority.
[options]objectsdk options
[options.headers]objectheaders to pass to API call

targetCoreAPI.setActivitySchedule(id, schedule, [options]) ⇒ Promise.<Response>

Update Activity schedule. Update schedule of an activity if it is found as referenced by the id.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberActivity id.
schedulestringNew Activity schedule.
[options]objectsdk options
[options.headers]objectheaders to pass to API call

targetCoreAPI.deleteABActivity(id, [options]) ⇒ Promise.<Response>

Delete AB activity. Deletes the AB activity that is referenced by the id, if it is found.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberActivity id.
[options]objectsdk options
[options.headers]objectheaders to pass to API call

targetCoreAPI.deleteXTActivity(id, [options]) ⇒ Promise.<Response>

Delete XT activity. Delete the current definition of an XT activity if it is found as referenced by the id.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberActivity id.
[options]objectsdk options
[options.headers]objectheaders to pass to API call

targetCoreAPI.getActivityChangeLog(id, [options]) ⇒ Promise.<Response>

Get Activity changelog. Returns the changelog for a given activity id.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberActivity id.
[options]objectsdk options
[options.headers]objectheaders to pass to API call

targetCoreAPI.getOffers([options]) ⇒ Promise.<Response>

List Offers. Retrieve the list of previously-created content offers. The parameters passed through the query string are optional and are used to indicate the sorting and filtering options.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDefaultDescription
[options]objectto control offer search.
[options.limit]number2147483647Defines the number of items to return
[options.offset]number0Defines the first offers to return from the list of Offers. Used in conjunction with limit, you can provide pagination in your application for users to browse through a large set of offers.
[options.sortBy]stringDefines the sorting criteria on the returned items.
[options.headers]objectheaders to pass to API call

targetCoreAPI.getOfferById(id, [options]) ⇒ Promise.<Response>

Get Offer. Retrieves the contents of an offer given an offer id.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberOffer id.
[options]objectsdk options
[options.headers]objectheaders to pass to API call

targetCoreAPI.createOffer(body, [options]) ⇒ Promise.<Response>

Create Offer. Creates a new content offer as defined by the request data.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
bodyobjectOffer JSON.
[options]objectsdk options
[options.headers]objectheaders to pass to API call

targetCoreAPI.updateOffer(id, body, [options]) ⇒ Promise.<Response>

Update Offer. Updates the content offer referenced by the id.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberOffer id.
bodyobjectOffer JSON
[options]objectsdk options
[options.headers]objectheaders to pass to API call

targetCoreAPI.deleteOffer(id, [options]) ⇒ Promise.<Response>

Delete Offer. Deletes the content offer referenced by the provided id.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberOffer id.
[options]objectsdk options
[options.headers]objectheaders to pass to API call

targetCoreAPI.getAudiences([options]) ⇒ Promise.<Response>

List Audiences. List all available audiences with options to filter and sort by each available field.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDefaultDescription
[options]objectoptions to control audience search.
[options.limit]number2147483647Defines the number of items to return. Default value is 2147483647
[options.offset]number0Defines the first audience to return from the list of total offers. Used in conjunction with limit, you can provide pagination in your application for users to browse through a large set of offers.
[options.sortBy]stringDefines the sorting criteria on the returned items.
[options.headers]objectheaders to pass to API call

targetCoreAPI.createAudience(body, [options]) ⇒ Promise.<Response>

Create Audience. Create a new audience as specified by the contents of the request and return the newly-created audience definition.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
bodyobjectAudience JSON.
[options]objectsdk options
[options.headers]objectheaders to pass to API call

targetCoreAPI.getAudienceById(id, [options]) ⇒ Promise.<Response>

Get Audience. Get the audience definition specified by the provided id.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberAudience id.
[options]objectsdk options
[options.headers]objectheaders to pass to API call

targetCoreAPI.updateAudience(id, body, [options]) ⇒ Promise.<Response>

Update Audience. Update an audience with the new rules specified by the request data.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberAudience id.
bodyobjectaudience JSON
[options]objectsdk options
[options.headers]objectheaders to pass to API call

targetCoreAPI.deleteAudience(id, [options]) ⇒ Promise.<Response>

Delete Audience. Delete the audience referenced by the specified id.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberAudience id.
[options]objectsdk options
[options.headers]objectheaders to pass to API call

targetCoreAPI.getProperties([options]) ⇒ Promise.<Response>

List Properties. Get a list of properties.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
[options]objectsdk options
[options.headers]objectheaders to pass to API call

targetCoreAPI.getPropertyById(id, [options]) ⇒ Promise.<Response>

Get Property. Retrieve property by property Id..

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberProperty id.
[options]objectsdk options
[options.headers]objectheaders to pass to API call

targetCoreAPI.getMBoxes([options]) ⇒ Promise.<Response>

List MBoxes. List all available mboxes for a specific client with the options to filter and sort.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
[options]objectsdk options
[options.headers]objectheaders to pass to API call

targetCoreAPI.getMBoxByName(name, [options]) ⇒ Promise.<Response>

Get MBox by name. Get the list of mbox parameters.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
namestringMBox name.
[options]objectsdk options
[options.headers]objectheaders to pass to API call

targetCoreAPI.getMBoxProfileAttributes([options]) ⇒ Promise.<Response>

Get Profile Attributes. Retrieve the list of available profile attributes and mbox parameters of type profile.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
[options]objectsdk options
[options.headers]objectheaders to pass to API call

targetCoreAPI.getEnvironments([options]) ⇒ Promise.<Response>

Get Environments. List all available environments with the options to filter and sort. Use the Environments API to retrieve the environment IDs corresponding to the various host groups set for the client.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
[options]objectsdk options
[options.headers]objectheaders to pass to API call

targetCoreAPI.getABActivityPerformance(id, [options]) ⇒ Promise.<Response>

Get AB activity performance. Retrieve property by property Id.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberActivity id.
[options]objectsdk options
[options.headers]objectheaders to pass to API call

targetCoreAPI.getXTActivityPerformance(id, [options]) ⇒ Promise.<Response>

Get activity performance. Retrieve property by property Id.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberActivity id.
[options]objectsdk options
[options.headers]objectheaders to pass to API call

targetCoreAPI.getActivityPerformance(id, [options]) ⇒ Promise.<Response>

Get activity performance. Retrieve the performance report data for the Automated Personalization activity referenced by the provided id.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberActivity id.
[options]objectsdk options
[options.headers]objectheaders to pass to API call

targetCoreAPI.getOrdersReport(id, [options]) ⇒ Promise.<Response>

Get Orders report. Retrieve the orders/audit report data for an AB, XT or Autotmated Personalization Activity.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
idnumberActivity id.
[options]objectsdk options
[options.headers]objectheaders to pass to API call

targetCoreAPI.executeBatch(body) ⇒ Promise.<Response>

Execute Batch APIs. Multiple Admin APIs can be executed as a single batch request.

Kind: instance method of TargetCoreAPI
Returns: Promise.<Response> - a Promise resolving to a Response

ParamTypeDescription
bodyobjectjson to execute batch

init(tenant, apiKey, token) ⇒ Promise.<TargetCoreAPI>

Returns a Promise that resolves with a new TargetCoreAPI object.

Kind: global function
Returns: Promise.<TargetCoreAPI> - Promise resolving to a TargetCoreAPI instance

ParamTypeDescription
tenantstringtenant Adobe Target tenant name
apiKeystringapiKey Your api key
tokenstringValid auth token

Debug Logs

LOG_LEVEL=debug <your_call_here>

Contributing

Contributions are welcome! Read the Contributing Guide for more information.

Licensing

This project is licensed under the Apache V2 License. See LICENSE for more information.

版本与发布记录

@adobe/aio-lib-target 共发布 18 个版本,首次发布于 2019/10/14;过去 12 个月发布了 1 个版本。

版本发布日期距今
4.0.3latest2026/03/317 个月前
4.0.22025/09/041.2 年前
4.0.12024/02/122 年前
4.0.02024/01/112 年前
3.0.3-pre.2024-01-08.sha-ad091911next2024/01/082 年前
3.0.32023/09/083 年前

关于 @adobe/aio-lib-target 的常见问题

@adobe/aio-lib-target 是什么?

Adobe Target SDK

如何安装 @adobe/aio-lib-target?

在项目目录运行 npm install @adobe/aio-lib-target,或使用 pnpm add / yarn add / bun add。

@adobe/aio-lib-target 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/adobe__aio-lib-target 是否存在。

@adobe/aio-lib-target 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@adobe/aio-lib-target 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@adobe/aio-lib-target 可以商用吗?

@adobe/aio-lib-target 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@adobe/aio-lib-target 的下载量有多少?

根据 npm 官方下载统计,@adobe/aio-lib-target 在 2026/10/05 – 2026/11/03 这 30 天内被下载 24,390 次,日均约 813 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@adobe/aio-lib-target 还在维护吗?

最新版本 4.0.3 发布于 2026/03/31(7 个月前);至今共发布 18 个版本,其中过去 12 个月发布了 1 个;首次发布于 2019/10/14。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。