Saltearse al contenido

API Client Introduction

The Content Island API client is a JavaScript library that enables interaction with the REST API. It provides a simple and easy-to-use interface to retrieve all projects and content in your Content Island account. The library is designed to be used in web and mobile applications, and it is compatible with modern browsers and Node.js.

Installation

You can install the Content Island API client using your preferred package manager:

Ventana de terminal
npm install @content-island/api-client

Requirements

  • Node.js 18.x or higher.

TypeScript is optional but recommended for the best developer experience. The Content Island API client is written in TypeScript and provides types for all exposed functions and objects.

Usage

Once installed, follow these steps to configure 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 retrieve all content in your project:

    const contents = await client.getContentList();
  3. To retrieve content from a specific model you’ve declared, 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.