Code Blocks
👩🏼‍💻

Code Blocks

Common Languages

TypeScript

/**
 * Base properties shared by all block types.
 */
export interface BaseBlock {
  id: ID
  version: number
  created_time: number
  last_edited_time: number
  parent_id: ID
  parent_table: string
  alive: boolean
  created_by_table: string
  created_by_id: ID
  last_edited_by_table: string
  last_edited_by_id: ID
  space_id?: ID
  properties?: any
  content?: ID[]
  type: BlockType
}

JSON & JavaScript

{
  "page_icon": "🔥",
  "page_cover": "https://images.unsplash.com/photo-1532386236358-a33d8a9434e3?ixlib=rb-1.2.1&q=85&fm=jpg&crop=entropy&cs=srgb",
  "page_cover_position": 0.5
}

const { NotionAPI } = require('./build')

async function main() {
  const api = new NotionAPI()

  // const output = await api.getPage('067dd719-a912-471e-a9a3-ac10710e7fdf')

  const collectionId = '2d8aec23-8281-4a94-9090-caaf823dd21a'
  const collectionViewId = 'ab639a5a-853e-45e1-9ef7-133b486c0acf'
  const output = await api.getCollectionData(collectionId, collectionViewId)

  console.log(JSON.stringify(output, null, 2))
}

main()

Bash

#!/bin/bash
for (( counter=10; counter>0; counter-- ))
do
echo -n "$counter "
done
printf "\n"

Python

# Program to display the Fibonacci sequence up to n-th term

nterms = int(input("How many terms? "))

# first two terms
n1, n2 = 0, 1
count = 0

# check if the number of terms is valid
if nterms <= 0:
   print("Please enter a positive integer")
elif nterms == 1:
   print("Fibonacci sequence upto",nterms,":")
   print(n1)
else:
   print("Fibonacci sequence:")
   while count < nterms:
       print(n1)
       nth = n1 + n2
       # update values
       n1 = n2
       n2 = nth
       count += 1

Markdown

All examples use this public [notion workspace](https://www.notion.so/Notion-Tests-067dd719a912471ea9a3ac10710e7fdf) which **aims to cover 100% of Notion's public functionality**.

## Docs

| Package                                   | NPM                                                                                                   | Docs                            | Description                                       |
| ----------------------------------------- | ----------------------------------------------------------------------------------------------------- | ------------------------------- | ------------------------------------------------- |
| [notion-client](./packages/notion-client) | [![NPM](https://img.shields.io/npm/v/notion-client.svg)](https://www.npmjs.com/package/notion-client) | [docs](./docs/notion-client.md) | TypeScript client for the unofficial Notion API.  |
| [notion-types](./packages/notion-types)   | [![NPM](https://img.shields.io/npm/v/notion-types.svg)](https://www.npmjs.com/package/notion-types)   | [docs](./docs/notion-types.md)  | TypeScript types for core Notion data structures. |
| [notion-utils](./packages/notion-utils)   | [![NPM](https://img.shields.io/npm/v/notion-utils.svg)](https://www.npmjs.com/package/notion-utils)   | [docs](./docs/notion-utils.md)  | Useful utilities for working with Notion data.    |

## Related

- [notion test suite](https://www.notion.so/saasifysh/Notion-Tests-067dd719a912471ea9a3ac10710e7fdf) - Comprehensive suite of public Notion pages to test individual features.
- [react-notion](https://github.com/splitbee/react-notion) - React renderer for Notion data.

## License

MIT © [Travis Fischer](https://transitivebullsh.it)

Seen in the Wild

Invalid JavaScript

Participating
216 investors
94% invest in pre-seed + seed
96% US-based investor
19% angels
81% venture capitalists
6 investments made via tool

HTML-ish

🦄 Team Abstract
		☕ Tightrope Coffee
				✨ Mobile App
				✨ Landing Page
				✨ Kiosk UI