{"id":16458028,"url":"https://github.com/adobe/reactor-sdk-javascript","last_synced_at":"2025-10-27T09:31:03.052Z","repository":{"id":47405133,"uuid":"175486472","full_name":"adobe/reactor-sdk-javascript","owner":"adobe","description":"JavaScript SDK for the Reactor API","archived":false,"fork":false,"pushed_at":"2024-04-08T12:49:39.000Z","size":783,"stargazers_count":12,"open_issues_count":2,"forks_count":10,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-01-16T22:11:36.346Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adobe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-13T19:33:02.000Z","updated_at":"2022-05-05T23:04:13.000Z","dependencies_parsed_at":"2024-06-21T04:17:03.479Z","dependency_job_id":"4a44fef0-b07f-4682-968b-d571e24f7656","html_url":"https://github.com/adobe/reactor-sdk-javascript","commit_stats":{"total_commits":103,"total_committers":11,"mean_commits":9.363636363636363,"dds":"0.44660194174757284","last_synced_commit":"685f1ad99983a3a633ada887b77fa49874c26323"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adobe%2Freactor-sdk-javascript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adobe%2Freactor-sdk-javascript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adobe%2Freactor-sdk-javascript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adobe%2Freactor-sdk-javascript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adobe","download_url":"https://codeload.github.com/adobe/reactor-sdk-javascript/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238471988,"owners_count":19478140,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T10:44:03.107Z","updated_at":"2025-10-27T09:30:57.682Z","avatar_url":"https://github.com/adobe.png","language":"JavaScript","funding_links":[],"categories":["API Development"],"sub_categories":["SDKs"],"readme":"# JavaScript Reactor SDK\n\n[![Travis badge](\nhttps://travis-ci.com/adobe/reactor-sdk-javascript.svg?branch=master)](\nhttps://travis-ci.com/adobe/reactor-sdk-javascript/settings)\n[![npm version](\nhttps://badge.fury.io/js/%40adobe%2Freactor-sdk.svg)](\nhttps://badge.fury.io/js/%40adobe%2Freactor-sdk)\n[![Greenkeeper badge](\nhttps://badges.greenkeeper.io/adobe/reactor-sdk-javascript.svg)](\nhttps://account.greenkeeper.io/account/adobe#repositories)\n\nA Library for accessing the Adobe Experience Platform\n[Reactor API][Reactor API doc].\n\nThis API is fairly low-level.  The Reactor methods are one-to-one with the\nRESTful API endpoints, and they provide very little help in constructing your\npayloads.  This is intended to meet the expectations of JavaScript developers,\nbut we welcome your feedback.\n\n## Installation\n\n### Using npm\n\nYou can use the Reactor SDK from npm with a bundler like\n[Webpack](https://webpack.github.io/), [Rollup](https://rollupjs.org), or\n[Parcel](https://parceljs.org/). If you use npm for client package management,\nyou can install the SDK with:\n\n```bash\nnpm install @adobe/reactor-sdk\n```\n\n### Using a CDN\n\nIf you'd prefer not to use npm to manage your client packages, reactor-sdk\nalso provides a UMD distribution in a `dist` folder which is hosted on a CDN:\n\n```html\n\u003cscript src=\"https://unpkg.com/@adobe/reactor-sdk/dist/reactor-sdk.min.js\"\u003e\u003c/script\u003e\n```\n\nThe Reactor constructor will be installed as `window.Reactor`, so typical usage\nwould go something like this:\n\n```html\n\u003cscript src=\"https://unpkg.com/@adobe/reactor-sdk/dist/reactor-sdk.min.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  const tok = 'Your Access Token';\n  const orgId = 'Your Org Id';\n  const url = 'https://reactor.adobe.io';\n  const reactor = new window.Reactor(tok, {\n    reactorUrl: url,\n    customHeaders: {'x-gw-ims-org-id': orgId}\n  });\n  const acme = await reactor.getCompany('CO0123456789012345678901');\n  ...\n\u003c/script\u003e\n```\n\n[How to retrieve your Access Token](#your-access-token).\n\n[How to retrieve your Org ID](#your-org-id).\n\n## Usage\n\nThe example below is a nodejs script that lists the ID's and names of all your\nCompany's properties.\n\nPut this text in a file named `list-properties.js`:\n\n```javascript\n#!/usr/bin/env node\nconst Reactor = require('@adobe/reactor-sdk').default;\n\n(async function() {\n  const accessToken = process.env['ACCESS_TOKEN'];\n  const orgId = process.env['ORG_ID'];\n  const reactorUrl = 'https://reactor.adobe.io';\n  const reactor = new Reactor(accessToken, { reactorUrl: reactorUrl, customHeaders: {'x-gw-ims-org-id': orgId} });\n  // Example API call: list Companies for the authenticated organization\n  const companyList = await reactor.listCompanies();\n  for (var company of companyList.data) {\n    console.log(`${company.id} ${company.attributes.name}`);\n    // Example API call: list Properties for the identified Company\n    const list = await reactor.listPropertiesForCompany(company.id);\n    for (var property of list.data) {\n      console.log(`- ${property.id} ${property.attributes.name}`);\n    }\n  }\n})();\n```\n\n**Note:** If you are provisioned for multiple orgs, you will need to specify your org ID under `customHeaders` as shown below.\n\nYou can optionally add other custom headers that will be sent with each request by also\nspecifying them in the `customHeaders` object.\n\n``` javascript\nconst reactor = new window.Reactor(\n  tok, {\n    reactorUrl: url,\n    customHeaders: {\n      'x-gw-ims-org-id': orgId,\n      'another-header-example': 42\n    }\n  }\n);\n```\n\nRun it...\n\n```bash\nexport ACCESS_TOKEN=... # see instructions below\nexport ORG_ID=... # see instructions belor\nchmod u+x ./list-properties.js\n./list-properties.js\n```\n\n...and you should get output similar to:\n\n```plain text\n\"COb711272b544e8359eab4492484893f77\" \"Fredigar and Bagginses\"\n\"- PR090c7b576f892bf7a7f5e783d0e9ab75\" \"Shire Real Estate Holdings, LLC\"\n\"- PR399e5b7dbcfc83db37051b43f5ac4d3b\" \"Mathom Recyclers, Ltd.\"\nsuccess\n```\n\nA browser implementation of this functionality would differ in two ways:\n\n1. it would use the pre-initialized `window.Reactor` rather than\n   `const Reactor = require('@adobe/reactor-sdk')`\n2. providing your access token needs a different approach, since `process.env`\n   is not available in browsers.\n   Note: you _don't_ want to inline the text of your access token, unless you\n   are sure no adversary will have access to your page.\n\n## The SDK and the API\n\nThe Adobe Experience Platform Reactor API is a RESTful\n[`{json:api}`](https://jsonapi.org/)-compliant service.\n\nEach Reactor API endpoint has a corresponding function in this library.  For example,\nthe [\"Fetch a Profile\"][FetchProfile doc] endpoint is accessed via the\n[`getProfile()`][FetchProfile impl] SDK function.\n\nSince the correspondence between API endpoints and SDK functions is one-to-one,\nthe [Reactor API documentation][ListCompanies doc] is the primary source of\ninformation.\n\n(In addition to the live API documentation, the code that builds that\ndocumentation is available under open source, at\n[`reactor-developer-docs`][Reactor API doc repo].  For example, the source code\nof the [\"Fetch a Profile\"][FetchProfile doc] documentation is at\n[profiles/fetch.md][FetchProfile doc src].)\n\n[Reactor API doc]: https://developer.adobelaunch.com/api/ 'The Adobe Experience Platform Reactor API'\n[Reactor API doc repo]: https://github.com/adobe/reactor-developer-docs 'Experience Platform Reactor API documentation repository'\n[FetchProfile doc]: https://developer.adobelaunch.com/api/reference/1.0/profiles/fetch/ 'Fetch a Profile'\n[FetchProfile impl]: https://github.com/adobe/reactor-sdk-javascript/blob/master/src/profiles.js#L13\n[FetchProfile doc src]: https://github.com/adobe/reactor-developer-docs/blob/master/api/reference/1.0/profiles/fetch.md 'Fetch a Profile'\n[ListCompanies doc]: https://developer.adobelaunch.com/api/reference/1.0/companies/list/ 'List Companies'\n\nEvery SDK function [has an integration test](test/integration)\nthat demonstrates its correctness. (Well, correct for at least *one* use).\nThese tests also provide you working examples for every library function.  [This\nisn't quite true yet.  We're almost there, but a few remain to be implemented.]\n\nFor a complete and self-contained example program, see\n[test.spec.js](./examples/test.spec.js). This is also included in\nthe integration tests, see [examples.test.js](./test/integration/examples.test.js). It's\na JavaScript implementation of the [ReactorPostman]( https://github.com/adobe/reactor-postman)\nquery set.\n\n## Developer Setup\n\nIf you want to contribute to development of this library,\n\n```bash\ngit clone git@github.com:adobe/reactor-sdk-javascript.git\ncd reactor-sdk-javascript\nnpm ci           # install dependencies and build Reactor SDK library\n```\n\nThe clean install generates three versions of the library:\n\n1. `./lib/node/*.js`, intended for use by nodejs projects\n2. `./lib/browser/*.js`, intended for use by bundlers in browser projects\n3. `./dist/reactor.min.js`, intended for loading directly into an HTML\n    page (i.e., for non-bundled browser use)\n\nWith the SDK built, you can run its nodejs unit tests:\n\n```bash\nnpm link \"$(pwd)\"           # make this SDK available to tests\nnpm run unit-tests          # run the tests in test/unit/**\n```\n\nThe integration tests need a current access token, a provisioned Company, and your provisioned Org ID.\nYou are expected to provide them to the tests via the environment variables\n`ACCESS_TOKEN`, `COMPANY_ID`, and `ORG_ID`.  Instructions for getting [your Access Token](#your-access-token),\n[your Company Id](#your-company-id), and [your Org ID](#your-org-id) are given below.\n\nThe in-browser integration tests require a local static-file web server, because\nloading their HTML using a `file://` URL is not effective: the browser\nrejects all the resulting Reactor requests because they violate CORS\nrestrictions.  The necessary bare-bones web server is provided with this\nproject, as `scripts/static-server.js`.\n\nOnce you've collected the necessary values for your environment variables, you\ncan run the integration tests:\n\n```bash\nexport ACCESS_TOKEN=\"your_reactor_access_token\"\nexport COMPANY_ID=\"your_reactor_test_company_id\" # \"CO\" followed by 32 hex digits\nexport ORG_ID=\"your_org_id\" # 24 characters followed by \"@AdobeOrg\"\nNODE_TLS_REJECT_UNAUTHORIZED=0 scripts/static-server.js --dir ./tmp.tests/\n```\n\nSwitch to another terminal window, since you want that server to keep running.\n\n```bash\nnpm run integration-tests   # run the tests in test/integration/**\n# The library and bundled integration tests are not currently functioning,\n# but the node ones are. Getting them all running is in the backlog. - CR\n```\n\n[Update] As of 24 August 2021, current versions of Google Chrome _still_ won't\nallow the files to be loaded, even with the static server. Apparently,\n`localhost:5000` and `localhost:9010` are too different, and trigger CORS\nblocking. On MacOS, I've been able to get the tests to work by shutting down\nChrome and relaunching with:\n\n* Bundled Library Test\n\n```bash\nopen -a \"Google Chrome\" ./tmp.tests/integration-bundled-sdk/integration-tests-bundled-sdk.html \\\n     --args --disable-web-security --user-data-dir=\"/tmp/chrome\"\n```\n\n* Non-bundled Library Test\n\n```bash\nopen -a \"Google Chrome\" ./tmp.tests/integration-library-sdk/integration-tests-library-sdk.html \\\n     --args --disable-web-security --user-data-dir=\"/tmp/chrome\"\n```\n\nWhile developing the Reactor SDK, these are handy for auto-building when you\nchange the source code:\n\n```bash\n# re-run {lint, prettier, build} when src/**/*.js changes\nnpm run src-watch\n\n# re-run {lint, prettier, build, and test} when {dist,test/unit}/**/*.js changes\nnpm run unit-watch\n\n# re-run {lint, prettier, build, and test} when {dist,test/integration}/**/*.js changes\nnpm run integration-watch\n\n# re-run {lint, prettier, build, and test} when {src,test}/**/*.js changes\nnpm run all-watch\n\n# Periodically, you'll want to remove the Properties created during integration tests\nscripts/delete-test-properties\n```\n\n## Determining Your Personal Information\n\n### Your Access Token\n\nHere we provide instructions on two ways that you can retrieve your Access Token for use with the `reactor-sdk` project.\n\n#### Programmatically via Adobe's [nodejs programmatic token](https://github.com/adobe/auth-token) project.\n\n```javascript\n#!/usr/bin/env node\n// The @adobe/auth-token project also supports import syntax natively.\n// here is a commonjs example.\nconst getAuthToken = (...args) =\u003e import('@adobe/auth-token').then(({ auth: adobeAuth }) =\u003e adobeAuth(...args));\nconst Reactor = require('@adobe/reactor-sdk').default;\n\n(async function() {\n  // @adobe/auth-token config object: https://github.com/adobe/auth-token?tab=readme-ov-file#config-object\n  const config = {\n    clientId: 'YOUR_CLIENT_ID',\n    clientSecret: \"YOUR_CLIENT_SECRET\",\n    scope: \"your,scopes,here\" // https://developer.adobe.com/developer-console/docs/guides/authentication/UserAuthentication/implementation/#oauth-20-scopes\n  };\n  const tokenResponse = await getAuthToken(config);\n  const accessToken = tokenResponse['access_token'];\n\n  const orgId = process.env['ORG_ID'];\n  const reactorUrl = 'https://reactor.adobe.io';\n  const reactor = new Reactor(accessToken, { reactorUrl: reactorUrl, customHeaders: {'x-gw-ims-org-id': orgId} });\n\n  // perform API calls here\n})();\n```\n\n#### Through the Adobe Tags user interface\n\n* Using Google Chrome, log in to `https://launch.adobe.com/companies`\n* Open the developer console\n* Change the JavaScript context from \"top\" to \"Main Content\" using the dropdown menu\n  ![Switch JavaScriptContext](./.readme-assets/switch-js-context.png)\n* Execute `copy(userData.imsAccessToken)`\n* The access token is now in your system clipboard. Paste it into an\n  environment variable definition:\n  * `export ACCESS_TOKEN='\u003cpaste\u003e'`\n\n### Your Company ID\n\n* Log in to `https://launch.adobe.com/companies`\n* While looking at your Properties page, the address bar will show a URL like\n  `https://launch.adobe.com/companies/CO81f8cb0aca3a4ab8927ee1798c0d4f8a/properties`.\n* Your Company ID is the 'CO' followed by 32 hexadecimal digits (i.e., from \"CO\"\n  up to the following slash). Copy that company ID to an environment variable:\n  * `export COMPANY_ID=CO81f8cb0aca3a4ab8927ee1798c0d4f8a`\n\n### Your Org ID\n\n* Log into `https://launch.adobe.com/companies`\n* Open the developer console\n* Change the JavaScript context from \"top\" to \"Main Content\" using the dropdown menu\n  ![Switch JavaScriptContext](./.readme-assets/switch-js-context.png)\n* Execute `copy(userData.profile.attributes.activeOrg)`\n* The Org ID is now in your system clipboard. Paste it into an environment variable definition:\n  * `export ORG_ID='\u003cpaste\u003e'`\n\n## Future Work\n\n* Implement integration tests for the handful of functions not yet covered.\n* Include a section here on library function naming conventions.\n* Describe how query parameters are passed in this SDK.\n\n## Contributing\n\nContributions are welcomed! Read the [Contributing Guide](https://github.com/adobe/reactor-sdk-javascript/blob/master/CONTRIBUTING.md)\nfor more information.\n\nBefore submitting your PR\n\n```bash\n# commit your changes\n$ git add .\n$ git commit -m 'your commit message'\n$ npm version {major|minor|patch}\n$ git push\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadobe%2Freactor-sdk-javascript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadobe%2Freactor-sdk-javascript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadobe%2Freactor-sdk-javascript/lists"}