Skip to content

Instantly share code, notes, and snippets.

@jqtrde
Forked from tlehman/roam-api.sh
Created July 30, 2023 22:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jqtrde/219d13bccffd3a3c89551eb001344ee5 to your computer and use it in GitHub Desktop.
Save jqtrde/219d13bccffd3a3c89551eb001344ee5 to your computer and use it in GitHub Desktop.
#!/bin/bash
GRAPH_NAME=tlehman
function roam_api_get_blocks_containing_string() {
curl -X POST "https://api.roamresearch.com/api/graph/$GRAPH_NAME/q" --location-trusted \
-H "accept: application/json" \
-H "Authorization: Bearer $ROAM_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"query\" : \"[:find ?block-str :in \$ ?search-string :where [?b :block/uid ?block-uid] [?b :block/string ?block-str] [(clojure.string/includes? ?block-str ?search-string)]]\", \"args\": [\"$1\"]}"
}
function roam_api_create_block() {
local TODAY=$(date +"%m-%d-%Y")
curl -X POST "https://api.roamresearch.com/api/graph/$GRAPH_NAME/write" --location-trusted \
-H "accept: application/json" \
-H "Authorization: Bearer $ROAM_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"action\":\"create-block\",\"location\":{\"parent-uid\":\"$TODAY\",\"order\":\"last\"},\"block\":{\"string\":\"$1\",\"open\":false,\"children-view-type\":\"document\"}}"
}
roam_api_create_block "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment