Skip to content

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:

Terminal window
npm install @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:

  1. 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" });
  2. 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();
  3. 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.