This project is a Node.js API for interacting with Notion databases and pages. It uses the Notion SDK to perform various operations such as retrieving all pages or databases, retrieving a single page or database by ID, and searching for pages or databases by a search term.
- Endpoint:
/databases
- Method:
GET
- Description: Retrieves all databases.
- Response:
[ { "id": "database_id", "title": "Database Title", ... } ]
- Endpoint:
/databases/:id
- Method:
GET
- Description: Retrieves a database by its ID.
- Parameters:
id
(string): The ID of the database.
- Response:
{ "id": "database_id", "title": "Database Title", ... }
- Endpoint:
/pages
- Method:
GET
- Description: Retrieves all pages.
- Response:
[ { "id": "page_id", "title": "Page Title", ... } ]
- Endpoint:
/pages/:id
- Method:
GET
- Description: Retrieves a page by its ID.
- Parameters:
id
(string): The ID of the page.
- Response:
{ "id": "page_id", "title": "Page Title", ... }
- Endpoint:
/search
- Method:
GET
- Description: Searches for pages or databases by a search term.
- Parameters:
query
(string): The search term.
- Response:
[ { "id": "result_id", "title": "Result Title", ... } ]
- Clone the repository:
git clone https://github.com/yourusername/notion-database.git
- Navigate to the project directory:
cd notion-database
- Install the dependencies:
npm install
- Create a
.env
file in the root directory and add your Notion API key:NOTION_API_KEY=your_notion_api_key
To start the server, run:
npm start