Integrate with the Volusion V1 API.
Use this package in your project by doing:
npm install @volusion/v1-api (not published on npm yet, for now just clone this repo)
// instantiate the client
const v1Client = require('@volusion/v1-api');
const v1 = new v1Client({
apiKey: "D29mVUp2nJABPdMNZDfAdzNAeHz9qLri", // replace with your key
baseUrl: "https://www.yourdomain.com"
});
// call an endpoint
const data = await v1.getCart();
// use the data
const item = data.data.items[0]; // for this sample, let's look at the first item in the cart
We recommend setting an environment variable in your project called V1_API_KEY
.
You probably already know how to do this using popular packages like dotenv or similar to manage environment variables. But if not, you can quickly set your environment variables locally by simply running the following command which sets the environment variable for the duration of your terminal session: export V1_API_KEY="yourkeyhere"
So just run that before you run npm start
or similar. You can check the value of your environment variable in that specific terminal session by doing echo "$V1_API_KEY"
.
// when you instantiate the client, get the key from an environment variable
const v1Client = require('@volusion/v1-api');
const v1 = new v1Client({
apiKey: process.env.V1_API_KEY, // 👈 best practice ✨
baseUrl: "https://www.yourdomain.com"
});
- more examples
Run tests
npm run test