Subscribe Pro JavaScript Client
This is our JavaScript client library for accessing the Subscribe Pro REST API. Our API documentation is available at https://docs.subscribepro.com/technical/rest-api/.
To learn more about Subscribe Pro you can visit us at https://www.subscribepro.com/.
Installation
This library is packaged as an NPM package. You can install with NPM through the standard method:
npm install @subscribepro/sdk
If you are using YARN you add this library to your package.json with:
yarn add @subscribepro/sdk
Usage
As this is packaged as a standard NPM typescript module the import should be familiar:
import { SubscribePro } from '@subscribepro/sdk';
SubscribePro.configure({
accessToken: 'ACCESS_TOKEN',
environmentKey: 'ENVIRONMENT_KEY'
})
The API is split in to two versions that reflect the SubscribePro API versioning. The V2 and V3 APIs have overlapping functionality, but there are capabilities that can only be found in one or the other. The definitive documentation can be found on the SubscribePro docs:
- V1 and V2 API Docs (With the exception of the vault endpoints which are both V1 and V2, all endpoints are V2)
- V3 API Docs
Example (Retrieve and Update a Product V3 API)
import { SubscribePro } from '@subscribepro/sdk';
SubscribePro.configure({
accessToken: 'ACCESS_TOKEN',
environmentKey: 'ENVIRONMENT_KEY'
})
let product = SubscribePro.V3.Products.findById({id: '12345'});
SubscribePro.V3.Products.update({id: product.id, data: {name: `${product.name} (2022)`}});
Example (Retrieve and Update a Product V2 API)
import { SubscribePro } from '@subscribepro/sdk';
SubscribePro.configure({
accessToken: 'ACCESS_TOKEN',
environmentKey: 'ENVIRONMENT_KEY'
})
let product = SubscribePro.V2.Products.getOne({id: '12345'});
SubscribePro.V2.Products.updateOne({id: product.id, data: {name: `${product.name} (2022)`}});