Giter VIP home page Giter VIP logo

notion-api-examples's Introduction

Notion API Examples

This is a Notion API playground.

You can find some Notion API examples in the aptly named "examples" directory.

Set up

If you're using nvm, you can nvm install and then nvm use, otherwise, you will need to install node to run these example scripts. If you're not sure, download the LTS version for your platform.

Once you've done this, make sure the following command outputs the node version when run inside this project's directory:

node --version

From the root directory of this project, run:

npm install

Create a .env file in the root directory of this project and add your Notion API Token there (after the = in the example below).

NOTION_API_TOKEN=secret_abc123

Now all the scripts in the examples folder will use your token.

Be very careful not to commit your Notion API token to the repository if you create a fork of this repository.

Running Examples

In general, you will select a file in the examples directory and run it with node:

node examples/databases/sort-multi-select/index.js

Most scripts have parameters that can be passed via the command line. The defaults of these are all using my stuff, so you will either have to change them in the code, or use the command line arguments.

Example:

node examples/databases/sort-multi-select/index.js --database-id=DATABASE_ID --sort-prop=PROPERTY_NAME --no-case-sensitive

Parameters

I will add comments to the top of each script indicating parameters that can be specified (WIP), but the following are always available to all scripts:

  • --notion-api-token overrides the var NOTION_API_TOKEN if specified in .env file. Must be provided for all scripts if not set in .env file.

Caveats

There is very little error handling in these examples. Mostly because I want to fail hard and see the errors. So you will see very few try...catch statements throughout. You will want to handle errors gracefully in real-world scenarios.

notion-api-examples's People

Contributors

typeoneerror avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.