Skip to content

Usage

Create a Client

The createClient function allows you to set up an API client with default options that are used in every API call. This simplifies the process of managing common settings like the API base URL and headers.

ts
import { createClient } from 'apiful'

const client = createClient({
  // Defaults to `/` if not set
  baseURL: 'https://api.example.com',
  headers: {
    Authorization: `Bearer ${token}`,
  },
})

NOTE

No matter which adapter you use, the default options are always passed to the adapter.

Use Adapters

Adapters are used to handle requests and responses to and from the API. You can choose from the following pre-built adapters:

Alternatively, you can create your own custom adapter to meet your specific requirements.