JavaScript SDK
You can consume our API using our official JavaScript SDK @vaporcms/client-sdk-js
. The library is TypeSafe and you can import the TypeScript types if
you use TypeScript in your project.
Installation
You'll need to authenticate your requests to access any of the endpoints in the VaporCMS API. In this guide, we'll look at how authentication works. Currently, VaporCMS uses authentication via OAuth2 Tokens..
Installation
npm install @vaporcms/client-sdk-js
Usage
To get started, create an API Key in the VaporCMS dashboard, then read about how to make requests for the resources you need to access using our HTTP APIs or JavaScript Client. You'll be also able to find the blogId at the same page.
Request
GET
/v0/:blogId/articlesimport { V0Client } from "@vaporcms/client-sdk-js";
const vaporCmsClient = new V0Client({
auth: process.env.VAPORCMS_API_KEY,
blogId: process.env.VAPORCMS_BLOG_ID,
});
const articlesResponse = await vaporCmsClient.articles.list({ page: 1, pageSize: 10, localeCode: "en" // optional });
if (articlesResponse.ok) {
console.log("Articles:", articlesResponse.data);
} else {
console.error("Error fetching articles:", articlesResponse.error);
}