All Projects → cstrnt → Notion Api

cstrnt / Notion Api

Unofficial Notion.so API

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Notion Api

Groovehq
Ruby gem for GrooveHQ api
Stars: ✭ 22 (-91.2%)
Mutual labels:  api-client, api-wrapper
Avenue
Wrapper around URLSession and URLSessionTask to enable seamless integration with Operation / OperationQueue.
Stars: ✭ 58 (-76.8%)
Mutual labels:  api-client, api-wrapper
Apipie
Transform api declaration to js object for frontend. Inspired by VueRouter, koa-middleware and axios.
Stars: ✭ 29 (-88.4%)
Mutual labels:  api-client, api-wrapper
Pizzly
The simplest, fastest way to integrate your app with an OAuth API 😋
Stars: ✭ 796 (+218.4%)
Mutual labels:  api-client, api-wrapper
Mega.py
Python library for the https://mega.nz/ API.
Stars: ✭ 145 (-42%)
Mutual labels:  api-client, api-wrapper
Slack
🎉✨ Slack API client for Node and browsers.
Stars: ✭ 903 (+261.2%)
Mutual labels:  api-client, api-wrapper
Github
Ruby interface to GitHub API
Stars: ✭ 1,081 (+332.4%)
Mutual labels:  api-client, api-wrapper
kaggler
🏁 API client for Kaggle
Stars: ✭ 50 (-80%)
Mutual labels:  api-client, api-wrapper
Anyapi
AnyAPI is a library that helps you to write any API wrappers with ease and in pythonic way.
Stars: ✭ 126 (-49.6%)
Mutual labels:  api-client, api-wrapper
Instagram api gem
A Ruby wrapper for the Instagram API
Stars: ✭ 100 (-60%)
Mutual labels:  api-client, api-wrapper
Bitly
A Ruby wrapper for the bit.ly API
Stars: ✭ 435 (+74%)
Mutual labels:  api-client, api-wrapper
Virustotal Api
Virus Total Public/Private/Intel API
Stars: ✭ 189 (-24.4%)
Mutual labels:  api-client, api-wrapper
Hubspot Php
HubSpot PHP API Client
Stars: ✭ 273 (+9.2%)
Mutual labels:  api-client, api-wrapper
Binance
A .NET Standard Binance API library.
Stars: ✭ 199 (-20.4%)
Mutual labels:  api-client, api-wrapper
cl-kraken
A Common Lisp API wrapper for the Kraken cryptocurrency exchange.
Stars: ✭ 12 (-95.2%)
Mutual labels:  api-client, api-wrapper
Wikipedir
R's MediaWiki API client library
Stars: ✭ 54 (-78.4%)
Mutual labels:  api-client, api-wrapper
radiobrowser4j
RadioBrowser Java API library
Stars: ✭ 30 (-88%)
Mutual labels:  api-client, api-wrapper
pushover
Go wrapper for the Pushover API
Stars: ✭ 112 (-55.2%)
Mutual labels:  api-client, api-wrapper
Newsapi
A python wrapper for News API.
Stars: ✭ 71 (-71.6%)
Mutual labels:  api-client, api-wrapper
Coingecko Api
A Node.js wrapper for the CoinGecko API with no dependencies.
Stars: ✭ 159 (-36.4%)
Mutual labels:  api-client, api-wrapper

Unofficial Notion.so API Wrapper (WIP)

npm npm bundle size

This repository contains an unofficial port of the Notion API to Node.js. Important: It only works in the backend using Node.js and not in a client-side environment.

IMPORTANT: You need a token to use the Notion API. You can obtain one by reading your local cookie. You can find instructions for that below.

Documentation

Installation

You can either use npm or yarn to install it:

npm i --save notion-api-js
yarn add notion-api-js

Usage

Creating an instance

To create an instance, simply pass an object with the token you read from the cookie:

// ES Modules syntax
import Notion from "notion-api-js";

// require syntax
const Notion = require("notion-api-js").default;

const notion = new Notion({
  token: "YOUR_TOKEN_V2"
});

You can also provide options for the HTML parsing:

const notion = new Notion({
  token: "YOUR_TOKEN_V2",
  options: {
    colors: {
      orange: 'CSS COLOR HERE'
    },
    pageUrl: 'ABSOLUTE PAGE URL (e.g. /posts/'),
  }
});

Obtaining Credentials

Right now there is no official way of accessing the Notion API but there is a little work-around to get your credentials.

Prerequisites

You need to have an account on Notion.so and need to be logged in.

Getting your credentials

Most of the modern web browsers support inspecting cookies visually using the browser's devtools. You can read how to do it in your browser here:

After you found the Notion.so cookie, look for an entry called token_v2. It is the necessary credential for the Notion instance. Simply copy it into your code when you create the instance.

Instance Options

The options are optionally passed to the instance as a parameter. Those options contain information on how the HTML will be parsed and returned using the instance methods.

Colors (Object)

Contains definitions for the colors. If this option is omitted the default HTML colors like orange, pink and blue are used. You can change this behavior by passing an object containing color definitions. Example:

options: {
    colors: {
      red: 'tomato',
      blue: 'rgb(100, 149, 237)',
      purple: '#9933cc',
    }
}

Possible colors are:

  • red
  • brown
  • orange
  • yellow
  • teal
  • blue
  • purple
  • pink

PageUrl (String)

The PageUrl is the string passed to the <a> tag and is used to build the href of it. The id is inserted after the passed string. By default it looks like this /page?id=, which results in <a href="/page?id=SOME_ID">Hello World</a>

Instance Methods

getPages()

Gets all pages of the user by the userId passed to the Notion instance. All pages are parsed to HTML.

Example

notion.getPages().then(pages => {
  // Your Code here
});

getPageById(pageId)

Gets a Notion page by the pageId and returns the parsed HTML.

Parameters:

Parameter Type Opt/Required
pageId string Required

Example

notion.getPageById("pageId").then(page => {
  // Your code here
});

getPagesByIndexId(pageId)

Gets a Notion page by the given pageId and all subpages of that page. Useful if you want to use a homepage.

Parameters:

Parameter Type Opt/Required
pageId string Required

Example

notion.getPagesByIndexId("pageId").then(page => {
  // Your code here
});

getAllHTML() [WIP]

Gets the HTML for all pages.

notion.getAllHTML().then(html => {
  // Your Ccode here
});

Disclaimer

It's really WIP right now but I would highly appreciate if you would like to contribute to the project. Just fork this repository and create a PR 😄

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].