Skip to content

Latest commit

 

History

History
109 lines (97 loc) · 2.22 KB

README.md

File metadata and controls

109 lines (97 loc) · 2.22 KB

notion-database

Overview

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.

API Routes

Get All Databases

  • Endpoint: /databases
  • Method: GET
  • Description: Retrieves all databases.
  • Response:
    [
        {
            "id": "database_id",
            "title": "Database Title",
            ...
        }
    ]

Get Database by ID

  • 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",
        ...
    }

Get All Pages

  • Endpoint: /pages
  • Method: GET
  • Description: Retrieves all pages.
  • Response:
    [
        {
            "id": "page_id",
            "title": "Page Title",
            ...
        }
    ]

Get Page by ID

  • 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",
        ...
    }

Search Pages or Databases

  • 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",
            ...
        }
    ]

Installation

  1. Clone the repository:
    git clone https://github.com/yourusername/notion-database.git
  2. Navigate to the project directory:
    cd notion-database
  3. Install the dependencies:
    npm install
  4. Create a .env file in the root directory and add your Notion API key:
    NOTION_API_KEY=your_notion_api_key

Running the Server

To start the server, run:

npm start