Explore how adaptive content transforms your docs into a dynamic, tailored experience for every user.
Read the docs
LogoLogo
ProductPricingLog inSign up
  • Documentation
  • Developers
  • Guides
  • Changelog
  • Help Center
  • Getting Started
    • Developer Documentation
    • Quickstart
    • Development
    • Publishing
  • Integrations
    • Introduction
    • Using the CLI
    • Configuration
    • ContentKit
      • Component reference
    • Integration runtime
  • Client library
  • Guides
    • Creating a custom unfurl action
    • Creating interactive blocks
    • Referencing your integration in Markdown
    • Working with HTTP requests
    • Using the CLI in CI/CD
  • GitBook API
    • Introduction
    • Authentication
    • API reference
      • Organizations
        • Organization members
        • Organization invites
        • Organization AI ask
      • Docs sites
        • Site share links
        • Site structure
        • Site auth
        • Site preview
        • Site customization
        • Site spaces
        • Site sections
        • Site section groups
        • Site redirects
        • Site MCP servers
        • Site ads
        • Site users
        • Site insights
        • Site AI ask
      • Collections
        • Collection users
        • Collection teams
      • Spaces
        • Space content
        • Space comments
        • Space embeds
        • Space users
        • Space teams
        • Space integrations
        • Git
      • Change requests
        • Change request content
        • Change request contributors
        • Change request reviewers
        • Change request comments
      • Translations
        • Glossary
      • Integrations
      • URLs
      • OpenAPI
        • OpenAPI spec versions
      • Conversations
      • Custom fonts
      • Subdomains
      • Users
      • Teams
        • Team members
      • SSO
      • Storage
      • Custom hostnames
      • System info
    • Rate limiting
    • Pagination
    • Errors
  • Marketplace
    • Overview
    • Submit your app for review
  • Resources
    • Concepts
    • Changelog
    • ContentKit playground
    • GitHub examples
Powered by GitBook
On this page
Edit on GitHub

Client library

GitBook's official Node.js client library.

Last updated 4 months ago

Was this helpful?

LogoLogo

Resources

  • Showcase
  • Enterprise
  • Status

Company

  • Careers
  • Blog
  • Community

Policies

  • Subprocessors
  • Terms of Service
CtrlK
  • Overview
  • Installation
  • Usage
  • Reference

Was this helpful?

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

You can install the GitBook Node.js library through npm.

npm install @gitbook/api

Usage

General usage:

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 module.

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

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

Reference

Search

The following methods can be found on the client.search object.

Method

searchContent()

askQuery()

User

The following methods can be found on the client.user object.

Method

getAuthenticatedUser()

listSpacesForAuthenticatedUser()

Users

The following methods can be found on the client.users object.

Method

getUserById()

Spaces

The following methods can be found on the client.spaces object.

Method

getSpaceById()

searchSpaceContent()

askQueryInSpace()

importGitRepository()

exportToGitRepository()

getContentAnalyticsForSpaceById()

getSearchAnalyticsForSpaceById()

getTrafficAnalyticsForSpaceById()

trackViewInSpaceById()

getCurrentRevision()

importContent()

listFiles()

getPageById()

importContentInPageById()

getPageByPath()

createChangeRequest()

mergeChangeRequest()

updateChangeRequest()

getRevisionOfChangeRequestById()

importContentInChangeRequest()

listFilesInChangeRequestById()

getPageInChangeRequestById()

importContentInChangeRequestPageById()

getPageInChangeRequestByPath()

getRevisionById()

listFilesInRevisionById()

getPageInRevisionById()

getPageInRevisionByPath()

listPermissionsAggregateInSpace()

Collections

The following methods can be found on the client.collections object.

Method

getCollectionById()

listSpacesInCollectionById()

listPermissionsAggregateInCollection()

Integrations

The following methods can be found on the client.integrations object.

Method

listIntegrations()

getIntegrationByName()

publishIntegration()

unpublishIntegration()

listIntegrationInstallations()

listIntegrationSpaceInstallations()

renderIntegrationUiWithGet()

renderIntegrationUiWithPost()

updateIntegrationInstallation()

createIntegrationInstallationToken()

updateIntegrationSpaceInstallation()

Orgs

The following methods can be found on the client.orgs object.

Method

listOrganizationsForAuthenticatedUser()

listMembersInOrganizationById()

getMemberInOrganizationById()

updateMemberInOrganizationById()

removeMemberFromOrganizationById()

setUserAsSsoMemberForOrganization()

listSpacesForOrganizationMember()

listTeamsInOrganizationById()

createOrganizationTeam()

getTeamInOrganizationById()

updateTeamInOrganizationById()

removeTeamFromOrganizationById()

updateMembersInOrganizationTeam()

listTeamMembersInOrganizationById()

addMemberToOrganizationTeamById()

deleteMemberFromOrganizationTeamById()

inviteUsersToOrganization()

joinOrganizationWithInvite()

upgradeOrganizationPlan()

getOrganizationBillingPortal()

requestOrganizationUpgrade()

transferOrganization()

searchOrganizationContent()

listSpacesInOrganizationById()

listCollectionsInOrganizationById()

setupDirectorySync()

listDirectorySyncGroups()

syncDirectorySyncGroupsToTeams()

Urls

The following methods can be found on the client.urls object.

Method

getContentByUrl()