Skip to main content

scrapbox-python

CircleCI PyPI version

An unofficial wrapper around the Scrapbox API.

Installation

pip install scrapbox
# or `pipenv install scrapbox`

Basic Use

import scrapbox

client = scrapbox.Client()
project = client.get("/pages/help-jp/")

Examples

Get all the data of a project in JSON format

import json

client = scrapbox.Client()
project = client.get("/pages/help-jp/", limit=10)
# https://scrapbox.io/help-jp/

print(json.dumps(project, ensure_ascii=False, indent=2))
"""
{
  "projectName": "help-jp",
  "skip": 0,
  "limit": 10,
  "count": 73,
  "pages": [
    {
      "id": "57c7d72ad25ef00f00100688",
      "title": "Scrapboxの使い方",
      "image": "https://gyazo.com/7057219f5b20ca8afd122945b72453d3/raw",
      "descriptions": [
        "[https://gyazo.com/7057219f5b20ca8afd122945b72453d3]",
        "Scrapbox(スクラップボックス)の使い方・活用方法についてご紹介します。",
        "[* 編集を始める]",
        "まず最初に[ブラケティング]を読んでみましょう",
        "[* チュートリアルで雰囲気をつかむ]"
      ],
      "user": {
        "id": "566f8b954fb08e1100af5c5b"
      },
      "pin": 9007197717386014,
      "views": 34396,
      "linked": 2,
      "commitId": "5cf9c78742fc7800179f8c19",
      "created": 1472713402,
      "updated": 1559271981,
      "accessed": 1562487581,
      "snapshotCreated": 1559315996
    },
...
"""

Get page data in JSON format

import json

client = scrapbox.Client()
page = client.get("/pages/help-jp/API")
# https://scrapbox.io/help-jp/API

print(json.dumps(page, ensure_ascii=False, indent=2))
"""
{
  "id": "58e67688d0a4fe0011a0249c",
  "title": "API",
  "image": "https://gyazo.com/5bf55bb6223a62bf4477f07a9aad39b8/raw",
  "descriptions": [
    "[https://gyazo.com/5bf55bb6223a62bf4477f07a9aad39b8]",
    "あくまで内部APIです。APIは予告なく変更を行います。",
    "ページデータを取得するAPI",
    "ページリスト",
    "`/api/pages/:projectName`"
  ],
  "user": {
    "id": "5724627723541f110097c291",
    "name": "shokai",
    "displayName": "Sho Hashimoto",
    "photo": "https://lh3.googleusercontent.com/-auiW-ZOVu6Y/AAAAAAAAAAI/AAAAAAAADLg/YwBeR9cziLU/photo.jpg"
  },
  "pin": 0,
  "views": 7072,
  "linked": 1,
  "commitId": "5d135304ff5b5d0017cd83cc",
  "created": 1491498636,
  "updated": 1561547524,
  "accessed": 1562490240,
  "snapshotCreated": 1561586966,
  "persistent": true,
  "lines": [
    {
      "id": "58e67688d0a4fe0011a0249c",
      "text": "API",
      "userId": "5724627723541f110097c291",
      "created": 1491498636,
      "updated": 1491499158
    },
...
"""

Get the body text of a page

client = scrapbox.Client()
text = client.get("/pages/help-jp/Scrapboxの使い方/text")

print(text)
"""
Scrapboxの使い方
[https://gyazo.com/7057219f5b20ca8afd122945b72453d3]
Scrapbox(スクラップボックス)の使い方・活用方法についてご紹介します。

[* 編集を始める]
	まず最初に[ブラケティング]を読んでみましょう

[* チュートリアルで雰囲気をつかむ]
 サンプルプロジェクト
 	Scrapboxを開発するNotaが実際に利用したページを一部そのまま公開します。
   [Nota社のScrapboxを一部公開 https://scrapbox.io/nota-private-sample/]
	[Scrapboxチュートリアルスライド]
		使い方の概要を掴むことができます
 実践テクニック
  [エンジニアの生産性をあげるScrapboxの使い方 https://scrapbox.io/business/tutorial]
...
"""

Get the title image of a page

client = scrapbox.Client()

raw_image = client.get("/pages/help-jp/Scrapboxの使い方/icon")
with open("title.jpg", "wb") as f:
    f.write(raw_image)
# Download the top icon as "title.jpg"

Release files for scrapbox 0.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scrapbox 0.6.1
File Size Uploaded
scrapbox-0.6.1.tar.gz 3.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for scrapbox 0.6.1
File Interpreter ABI Platform
scrapbox-0.6.1-py3-none-any.whl Python 3 none any Details

Total release size: 8.9 kB

Release files / scrapbox-0.6.1.tar.gz

Download URL scrapbox-0.6.1.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2087e385de9f1ee8e63bd54a5e4e376ac0fc155fee91b4b579b53a700d67bd7c
BLAKE2b-256 checksum
How to use checksums
84deeef28840102ee23cc1dee4246e2f9387919c2f542bd64152e86950c2990f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.2

Release files / scrapbox-0.6.1-py3-none-any.whl

Download URL scrapbox-0.6.1-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
78a21b6e1d46b4c0ecd87be591e12bbe9abb6aec7d996d06ec3aea8f2d00e666
BLAKE2b-256 checksum
How to use checksums
41f7df46b4c127d1a389b33c016e1b51fa487ba10e8606287c985fa33dc33ceb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.2

Release history Release notifications | RSS feed

This release

0.6.1 This release

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

1 release file

0.5.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page