Docs
SupportGet Started
  • Get Started
  • Platform
  • Products
  • Tutorials
  • Enterprise
  • Tutorials Overview
  • How to Deploy a React Token dApp to Code Capsules
  • Nuxt3 and Nitro
  • Optimizing Performance in MERN Stack: Tips and Techniques
  • Creating and Hosting an API With Flask
    • API Reference [Sample]
  • Building a Full Stack Application with Flask and HTMx
  • How to Create and Host a Telegram Bot on Code Capsules
  • Create and Host a Telegram Bot with Node.js on Code Capsules
  • Build a Slackbot with Node.js to Monitor your Applications
  • Video Guides
  • Building a Full Stack Application With Express and HTMx
  • Getting Started With MEAN Stack: A Step-by-Step Tutorial
  • Building a Web File Store
  • Building a Book Recommendations App With PHP, SQLite, and Docker
  • Build a MERN Job Board
  • Build a Generative Art Application With Pillow, Flask and HTMx
  • White-Label Your App With Code Capsules
  • Building a Game Catalogue API
  • Deploy a Python Telegram Bot (Webhook Method) to Production in 5 Minutes
  • Deploy a Node.js Telegram Bot (Webhook Method) to Production in 5 Minutes
  • Deploy a Node.js Discord Bot to Production in 5 Minutes
  • Best Practices for Structuring MEAN/MERN/MEVN Projects
Powered by GitBook

© Copyright Code Capsules. All rights reserved.

On this page

Was this helpful?

Export as PDF
  1. Creating and Hosting an API With Flask

API Reference [Sample]

PreviousCreating and Hosting an API With FlaskNextBuilding a Full Stack Application with Flask and HTMx

Was this helpful?

Get information about the state of the GitBook API

get

Access the release version and build date of the GitBook codebase

Authorizations
Responses
200
OK
application/json
default
Unexpected Error
application/json
get
GET /v1/ HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
{
  "version": "text",
  "build": "text"
}

Search content across spaces that is accessible by the currently authenticated target

get
Authorizations
Query parameters
querystring · max: 512Required
pagestringOptional

Identifier of the page results to fetch.

limitnumber · max: 1000Optional

The number of results per page

Responses
200
OK
application/json
Responseall of
default
Unexpected Error
application/json
get
GET /v1/search HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
{
  "next": {
    "page": "text"
  },
  "count": 1,
  "items": [
    {
      "id": "text",
      "title": "text",
      "pages": [
        {
          "id": "text",
          "title": "text",
          "path": "text",
          "sections": [
            {
              "id": "text",
              "title": "text",
              "path": "text",
              "body": "text",
              "urls": {
                "app": "https://example.com"
              }
            }
          ],
          "urls": {
            "app": "https://example.com"
          }
        }
      ]
    }
  ]
}
Deprecated

Ask a question to an AI across spaces that is accessible by the currently authenticated target.

get
Authorizations
Query parameters
querystringRequired
formatstring · enumOptional

Output format for the content.

Possible values:
detailsbooleanOptional

Return query details in the result

Responses
200
OK
application/json
default
Unexpected Error
application/json
get
GET /v1/search/ask HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
{
  "answer": {
    "answer": {
      "markdown": "text"
    },
    "followupQuestions": [
      "text"
    ],
    "sources": [
      {
        "type": "page",
        "page": "text",
        "revision": "text",
        "space": "text",
        "sections": [
          "text"
        ]
      }
    ]
  }
}

Soft-deletes a space. Soft-deleted spaces will be permanently removed after 7 days.

delete
Authorizations
Path parameters
spaceIdstringRequired

The unique id of the space

Responses
205
Space has been deleted
default
Unexpected Error
application/json
delete
DELETE /v1/spaces/{spaceId} HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*

No content

  • GETGet information about the state of the GitBook API
  • GETSearch content across spaces that is accessible by the currently authenticated target
  • GETAsk a question to an AI across spaces that is accessible by the currently authenticated target.
  • POSTAsk a question to an AI across spaces that is accessible by the currently authenticated target.
  • PATCHUpdate the details of a space
  • DELETESoft-deletes a space. Soft-deleted spaces will be permanently removed after 7 days.

Ask a question to an AI across spaces that is accessible by the currently authenticated target.

post
Authorizations
Query parameters
formatstring · enumOptional

Output format for the content.

Possible values:
detailsbooleanOptional

Return query details in the result

Body
querystringRequired
previousQueriesstring[] · max: 10OptionalDeprecated
Responses
200
OK
application/json
default
Unexpected Error
application/json
post
POST /v1/search/ask HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 16

{
  "query": "text"
}
{
  "answer": {
    "answer": {
      "markdown": "text"
    },
    "followupQuestions": [
      "text"
    ],
    "sources": [
      {
        "type": "page",
        "page": "text",
        "revision": "text",
        "space": "text",
        "sections": [
          "text"
        ]
      }
    ]
  }
}

Update the details of a space

patch
Authorizations
Path parameters
spaceIdstringRequired

The unique id of the space

Body
all ofOptional
and
one ofOptional
or
or
Responses
200
The space has been updated
application/json
default
Unexpected Error
application/json
patch
PATCH /v1/spaces/{spaceId} HTTP/1.1
Host: api.gitbook.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 72

{
  "editMode": "live",
  "title": "text",
  "defaultLevel": "admin",
  "emoji": "🎉"
}
{
  "object": "space",
  "id": "text",
  "title": "text",
  "emoji": "🎉",
  "visibility": "public",
  "createdAt": "2025-06-16T10:34:37.064Z",
  "updatedAt": "2025-06-16T10:34:37.064Z",
  "deletedAt": "2025-06-16T10:34:37.064Z",
  "editMode": "live",
  "urls": {
    "location": "https://example.com",
    "app": "https://example.com",
    "published": "https://example.com",
    "public": "https://example.com",
    "icon": "https://example.com"
  },
  "organization": "text",
  "parent": "text",
  "gitSync": {
    "installationProvider": "github",
    "integration": "text",
    "url": "text",
    "updatedAt": "2025-06-16T10:34:37.064Z"
  },
  "visitorAuth": {
    "backend": "custom"
  },
  "revision": "text",
  "defaultLevel": "admin",
  "comments": 1,
  "changeRequests": 1,
  "changeRequestsOpen": 1,
  "changeRequestsDraft": 1,
  "permissions": {
    "access": true,
    "admin": true,
    "edit": true,
    "comment": true,
    "merge": true,
    "review": true
  }
}