Skip to content

Instantly share code, notes, and snippets.

@vested-sigil
Created January 26, 2024 00:07
Show Gist options
  • Save vested-sigil/a491930c8a2bc446effb6260838b837f to your computer and use it in GitHub Desktop.
Save vested-sigil/a491930c8a2bc446effb6260838b837f to your computer and use it in GitHub Desktop.
swagger spec for notion.so for custom GPTS
openapi: 3.0.0
info:
title: Notion API
description: API for interacting with Notion resources such as pages and databases.
version: 1.0.0
servers:
- url: https://api.notion.com/v1
description: Main API server
paths:
/pages/{page_id}:
get:
operationId: getPage
summary: Retrieve a page by its ID.
parameters:
- name: page_id
in: path
required: true
description: The ID of the page to retrieve.
schema:
type: string
format: uuid
- name: Notion-Version
in: header
required: true
description: Notion API version
schema:
type: string
default: 2022-06-28
responses:
"200":
description: A JSON object representing the page.
content:
application/json:
schema:
$ref: "#/components/schemas/Page"
patch:
operationId: updatePage
summary: Update a page by its ID.
parameters:
- name: page_id
in: path
required: true
description: The ID of the page to update.
schema:
type: string
format: uuid
- name: Notion-Version
in: header
required: true
description: Notion API version
schema:
type: string
default: 2022-06-28
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/PageUpdate"
responses:
"200":
description: The updated page.
content:
application/json:
schema:
$ref: "#/components/schemas/Page"
/databases/{database_id}:
get:
operationId: getDatabase
summary: Retrieve a database by its ID.
parameters:
- name: database_id
in: path
required: true
description: The ID of the database to retrieve.
schema:
type: string
format: uuid
- name: Notion-Version
in: header
required: true
description: Notion API version
schema:
type: string
default: 2022-06-28
responses:
"200":
description: A JSON object representing the database.
content:
application/json:
schema:
$ref: "#/components/schemas/Database"
#error1
/databases/{database_id}/query:
post:
operationId: queryDatabase
summary: Query a database.
parameters:
- name: database_id
in: path
required: true
description: The ID of the database to query.
schema:
type: string
format: uuid
- name: Notion-Version
in: header
required: true
description: Notion API version
schema:
type: string
default: 2022-06-28
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/DatabaseQuery"
responses:
"200":
description: The query results.
content:
application/json:
schema:
$ref: "#/components/schemas/DatabaseRecord"
#error2
/search:
post:
#error3
operationId: search
summary: Search all pages and databases.
parameters:
- name: Notion-Version
in: header
required: true
description: Notion API version
schema:
type: string
default: 2022-06-28
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/SearchRequest"
responses:
"200":
description: The search results.
content:
application/json:
schema:
$ref: "#/components/schemas/SearchResult"
components:
headers:
NotionVersion:
required: true
schema:
type: string
default: 2022-06-28
description: Notion API version
schemas:
Page:
type: object
required:
- object
- id
properties:
object:
type: string
enum:
- page
id:
type: string
format: uuid
properties:
type: object
additionalProperties: true
PageUpdate:
type: object
properties:
properties:
type: object
additionalProperties: true
Database:
type: object
required:
- object
- id
properties:
object:
type: string
enum:
- database
id:
type: string
format: uuid
properties:
type: object
additionalProperties: true
User:
type: object
required:
- object
- id
properties:
object:
type: string
enum:
- user
id:
type: string
format: uuid
name:
type: string
avatar_url:
type: string
format: uri
BlockChildren:
type: array
items:
$ref: "#/components/schemas/Block"
Block:
type: object
required:
- object
- id
properties:
object:
type: string
enum:
- block
id:
type: string
format: uuid
type:
type: string
block_data:
type: object
additionalProperties: true
Comment:
type: object
required:
- object
- id
properties:
object:
type: string
enum:
- comment
id:
type: string
format: uuid
parent:
type: object
additionalProperties: true
content:
type: string
PagePropertyItem:
type: object
required:
- object
- id
properties:
object:
type: string
enum:
- property_item
id:
type: string
format: uuid
property_data:
type: object
additionalProperties: true
DatabaseQuery:
type: object
properties:
filter:
type: object
additionalProperties: true
sorts:
type: array
items:
type: object
additionalProperties: true
DatabaseRecord:
type: object
required:
- object
- id
properties:
object:
type: string
enum:
- database_record
id:
type: string
format: uuid
record_data:
type: object
additionalProperties: true
SearchRequest:
type: object
properties:
query:
type: string
sort:
type: object
additionalProperties: true
SearchResponse:
type: array
items:
$ref: "#/components/schemas/SearchResult"
SearchResult:
type: object
required:
- object
- id
properties:
object:
type: string
enum:
- search_result
id:
type: string
format: uuid
result_data:
type: object
additionalProperties: true
securitySchemes:
BearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
security:
- BearerAuth: []
#errors:
#In context=('paths', '/databases/{database_id}/query', '200', 'response', 'content', 'application/json', 'schema'), object schema missing properties
#In context=('paths', '/search', 'post', 'requestBody', 'content', 'application/json', 'schema'), reference to unknown component Search; using empty schema
#In path /search, method post, operationId search, request body schema is not an object schema; skipping
#In path /search, method post, operationId search, skipping function due to errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment