A JavaScript wrapper for the Commerce7 API that works in both Node.js and browser environments.
npm install c7-api// Import the Node.js adapter first
import '@c7-api/adapters/node';
import { Commerce7 } from 'c7-api';
const client = new Commerce7({
tenantId: process.env.COMMERCE7_TENANT_ID,
clientId: process.env.COMMERCE7_CLIENT_ID,
clientSecret: process.env.COMMERCE7_CLIENT_SECRET,
debug: true, // Optional, enables debug logging
apiVersion: 'v1' // Optional, defaults to v1
});In Node.js environments, you can use environment variables:
COMMERCE7_TENANT_ID=your-tenant-id
COMMERCE7_CLIENT_ID=your-client-id
COMMERCE7_CLIENT_SECRET=your-client-secretThen initialize without passing config:
import '@c7-api/adapters/node';
import { Commerce7 } from 'c7-api';
const client = new Commerce7();Enable debug mode to see detailed logs of requests and responses:
const client = new Commerce7({
// ...other config
debug: true
});For more details about the Commerce7 API, please refer to the official documentation.
The API wrapper includes built-in error handling that will throw errors with detailed information about API failures. Errors will include the HTTP status code and the error message from the Commerce7 API.
To release a new version of the package:
- Update version in
package.json:
npm version patch # for bug fixes
npm version minor # for new features
npm version major # for breaking changes- Push changes and tags:
git push origin main --tags- Publish to npm:
npm publish --access public