npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@roam-research/roam-api-sdk

v0.10.0

Published

SDK to use Roam Reasearch API.

Downloads

17

Readme

SDK for Roam Reasearch API

This JS module allows to use the Roam API outside of the Roam Research webapp.

Usage

1. Create a token

You can create and edit roam-graph-tokens from a new section "API tokens" in the "Graph" tab in the Settings:

![https://firebasestorage.googleapis.com/v0/b/firescript-577a2.appspot.com/o/imgs%2Fapp%2Froamteam%2FkqaM1ePPbV.png?alt=media&token=e113f2b5-4fbe-4b75-8d30-a114a6aa0f8d]

For more details, see [https://roamresearch.com/#/app/developer-documentation/page/bmYYKQ4vf].

2. Create the graph object

The graph object bundles a graph and its token, it will be passed to all other functions.

const graph = initializeGraph({
  token: "roam-graph-token-XYZ",
  graph: "YourGraphName",
});

3. Call the API functions

These "other functions" are: q, pull, createBlock, moveBlock, updateBlock, deleteBlock, createPage, updatePage and deletePage.

For example you can search for all blocks containing the string "sdk" in your graph:

q(graph,
  "[:find ?block-uid ?block-str :in $ ?search-string :where [?b :block/uid ?block-uid] [?b :block/string ?block-str] [(clojure.string/includes? ?block-str ?search-string)]]",
  ["sdk"])
.then((r) => {
  console.log(r);
});

Refer to the Roam API documentation for an exhaustive reference of the provided functions.

Using into the browser

<script type="module">
import {initializeGraph, q} from 'https://unpkg.com/@roam-research/[email protected]/dist/roamapisdk.js';
const graph = initializeGraph({
  token: "roam-graph-token-XYZ",
  graph: "YourGraphName",
});
q(graph,
  "[:find ?block-uid ?block-str :in $ ?search-string :where [?b :block/uid ?block-uid] [?b :block/string ?block-str] [(clojure.string/includes? ?block-str ?search-string)]]",
  ["sdk"])
.then((r) => {
  console.log(r);
});
</script>

Using from Node.js

Depending on the type set in your package.json

Common JS (the default):

// this works also in ES module mode
import('@roam-research/roam-api-sdk')
.then(({initializeGraph, q}) => {
  const graph = initializeGraph({
    token: "roam-graph-token-XYZ",
    graph: "YourGraphName",
  });
  q(graph,
    "[:find ?block-uid ?block-str :in $ ?search-string :where [?b :block/uid ?block-uid] [?b :block/string ?block-str] [(clojure.string/includes? ?block-str ?search-string)]]",
    ["sdk"])
  .then((r) => {
    console.log(r);
  });
});

ES Module (for type: 'module')

import {initializeGraph, q} from 'https://unpkg.com/@roam-research/[email protected]/dist/roamapisdk.js';
const graph = initializeGraph({
  token: "roam-graph-token-XYZ",
  graph: "YourGraphName",
});
q(graph,
  "[:find ?block-uid ?block-str :in $ ?search-string :where [?b :block/uid ?block-uid] [?b :block/string ?block-str] [(clojure.string/includes? ?block-str ?search-string)]]",
  ["sdk"])
.then((r) => {
  console.log(r);
});