Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to insert data in database via Notion API?

Tags:

notion-api

I am really new to Notion, and I want to use the API for a project.

How I am supposed to insert data in a Notion database ? I know how to read information about the database, I know how to update schema, I know how to retrieve data from database, but I do not know how to insert data to or remove data from database.

THX.

like image 832
thmatew Avatar asked Mar 30 '26 23:03

thmatew


1 Answers

Each data represent a page. So you want to import a page to the database. And here it tells how you can import a page https://developers.notion.com/reference/post-page

exports.newEntryToDatabase = async function (name, description) {
  const response = await notion.pages.create({
    parent: {
      database_id: process.env.NOTION_API_DATABASE,
    },
    properties: {
      Name: {
        title: [
          {
            text: {
              content: name,
            },
          },
        ],
      },
      Description: {
        rich_text: [
          {
            text: {
              content: description,
            },
          },
        ],
      },
    },
  });

  return response;
};
like image 58
Ali Özben Avatar answered Apr 03 '26 16:04

Ali Özben