# Client library

### Overview

GitBook provides an official TypeScript/JavaScript client for the [HTTP API](/docs/developers/gitbook-api/api-reference.md). This client can be used in a browser or Node.js environment.&#x20;

### Installation

When [bootstrapping an integration using the GitBook CLI](/docs/developers/integrations/quickstart.md#bootstrap-your-app), the library will be installed by default. If you need to, you can also install the GitBook Node.js library through `npm`.

```bash
npm install @gitbook/api
```

### Initialize the client

To start using the GitBook client library, you’ll first need to initialize the library with your [developer token](/docs/developers/integrations/quickstart.md#create-a-personal-access-token).&#x20;

```typescript
import { GitBookAPI } from '@gitbook/api';

const client = new GitBookAPI({
  authToken: <your_access_token>
});
```

#### Usage with Node.js

When using the `@gitbook/api` module with Node.js < v18, you should pass a custom `fetch` function.

You can install one using the [`node-fetch`](https://github.com/node-fetch/node-fetch) module.

```typescript
import { GitBookAPI } from '@gitbook/api';
import fetch from 'node-fetch';

const client = new GitBookAPI({
  customFetch: fetch
});
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gitbook.com/docs/developers/integrations/development/client-library.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
