API Client Introduction
The Content Island API client is a JavaScript library that allows you to interact with the REST API. It provides a simple and easy-to-use interface to fetch all projects and content in your Content Island account. The library is designed for use in web and mobile applications and is compatible with modern browsers and Node.js.
Installation
You can install the Content Island API client using your preferred package manager:
npm install @content-island/api-client
pnpm add @content-island/api-client
yarn add @content-island/api-client
Requirements
- Node.js 18.x or higher.
TypeScript is optional, but recommended for the best development experience. The Content Island API client is written in TypeScript and provides types for all functions and exposed objects.
Usage
Once installed, follow these steps to set up and use the Content Island API client:
-
Create an instance of the API client using your project’s
access token
. You can find the access token in the General tab.import { createClient } from '@content-island/api-client';const client = createClient({ accessToken: "YOUR_ACCESS_TOKEN" }); -
You can now use the client to interact with the Content Island API. For example, to fetch all content from your project:
const contents = await client.getContentList(); -
To fetch content from a specific model you’ve defined, such as the
post
model:const posts = await client.getContentList({ contentType: 'post' });
For more information on how to retrieve content from your project, see the getContentList and getContent methods.