Client library
Install and use GitBook's official Node.js client library
Overview
GitBook provides an official TypeScript/JavaScript client for the HTTP API . This client can be used in a browser or Node.js environment.
Installation
When bootstrapping an integration using the GitBook CLI , the library will be installed by default. If you need to, you can also install the GitBook Node.js library through npm.
npminstall@gitbook/apiInitialize the client
To start using the GitBook client library, you’ll first need to initialize the library with your developer token .
import{GitBookAPI}from'@gitbook/api';
constclient=newGitBookAPI({
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 module.
import{GitBookAPI}from'@gitbook/api';
importfetchfrom'node-fetch';
constclient=newGitBookAPI({
customFetch:fetch
});Last updated
Was this helpful?