Git Product home page Git Product logo

pyroaman's Introduction

Pyroaman helps you explore Roam Research databases with Python.

Installation

You need Python 3.6 or later to use Pyroaman.
Install and update using pip:

$ pip install -U pyroaman

A Simple Example

First, you need the JSON export of a Roam database.
For this demo, we will use a public one: roamhacker.

$ curl https://raw.githubusercontent.com/br-g/roam-public-db/main/json/roamhacker.json -o roamhacker.json

Load

import pyroaman

db = pyroaman.load('roamhacker.json')
print(db)
Database (276 pages, 2397 blocks)

Lookup

Let's query blocks that contain the word "agile":

some_blocks = db.lookup('agile')
print(some_blocks)
[Block (string: "Goal for myself: Fight desire to...", is_page: False, children: 1, links: 1, backlinks: 0),
 Block (string: "Agile Note Taking", is_page: True, children: 0, links: 0, backlinks: 1),
 Block (string: "[9]  This example comes from Nas...", is_page: False, children: 0, links: 0, backlinks: 0)]

Explore

Get the text of a block (its string without images, references...):

print(some_blocks[0].text)
'Goal for myself: Fight desire to have the "perfect system". Better to use and iterate improvements, rather than wait for perfect system. And by the way, is there a perfect system? Agile Note Taking?? - sprint, try, iterate'

Get the children of a block:

print(some_blocks[0].children)
[Block (string: "Open organization: disorder with...", is_page: False, children: 0, links: 0, backlinks: 0)]

Get its links:

print(some_blocks[0].links)
[Block (string: "Agile Note Taking", is_page: True, children: 0, links: 0, backlinks: 1)]

Get backlinks:

print(some_blocks[1].backlinks)
[Block (string: "Goal for myself: Fight desire to...", is_page: False, children: 1, links: 1, backlinks: 0)]

Get block's metadata:

print(some_blocks[0].metadata)
{'edit-time': 1606399607792,
 'refs': [{'uid': 'YAYZKdubo'}],
 'uid': 'XP9lZauAg',
 ':block/refs': [{':block/uid': 'YAYZKdubo'}],
 ':create/user': {':user/uid': 'kfmqimzFiIOQwL1xgoBOApXxsup1'},
 'create-time': 1599461612984,
 ':edit/user': {':user/uid': 'kfmqimzFiIOQwL1xgoBOApXxsup1'}}

pyroaman's People

Contributors

br-g avatar

Stargazers

 avatar  avatar Brian Ataka  avatar Jag Chadha avatar  avatar Robert Collar avatar Stephen S avatar Thomas Allison avatar Ravi Mandliya avatar  avatar Lisa Ross avatar Papi Peppers avatar

Watchers

 avatar

Forkers

deklanw

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.