Accessing the Bear API via JavaScript and HTML

Hi everyone,

I’d like to do a request to the bear api, get certain files, and then render them to HTML, so that I can display my notes in column form and make changes to the display to help me visualize my projects, etc.

Is there a way to do this?

I tried doing it like this:

document.addEventListener("DOMContentLoaded", async () => {
  const response = await fetch(
      method: "GET",
      headers: {
        Authorization: "Bearer DA3FC-5-BE6BO6-C2E97", // Example header for authentication
        "Content-Type": "application/json",

  console.log("response from bear", response);

but got the following errors in safari:

[Error] Cross origin requests are only supported for HTTP.
(anonymous function) (bear-app.js:2)
(anonymous function) (bear-app.js:1)

[Error] Fetch API cannot load bear://x-callback-url/create?title=My%20Note%20Title&text=First%20line&tags=home,home%2Fgroceries due to access control checks.
(anonymous function) (bear-app.js:2)
(anonymous function) (bear-app.js:1)

[Error] Unhandled Promise Rejection: TypeError: Load failed
(anonymous function) (bear-app.js:2)

If you cannot get the data from your notes via JavaScript and HTML, is there another route? I need to visualize the information in columns, etc. which is not currently available in Bear - but I like Bear’s interface, privacy, etc.

You can’t use JS async calls on an HTML page with XURLs for security reasons.
Also, Bear’s API supports returning values but you need another app with XURL support to handle the reply.

I suggest trying to achieve this using Shortcuts’ Bear actions you can do multiple requests, get what you need from Bear, compose the HTML, and save it into a file.

Hi Trix180,

Thanks for that tip!

So, it seems like what I am actually looking for is a feature request for a shortcut that can dump all of the files of a certain tag into a document into a folder on my hard drive.
Do you happen to know if something like this is feasible?

(BTW - I tried to use shortcuts to save just one file to an .md file on my hard drive. It worked with the first state of the Bear note, but when I update the Bear note and then run the shortcut again, it did not continue to update the note on the hard drive).

The shortcut I’d be looking for is:

  1. search tag → get all files from that tag —> save those files to a folder on my hard drive → overwrite existing files with the same name (so that files are completely updated to the latest version).

Update: Seeing this can be done pretty easily from a keyboard shortcut to export a folder of the current tag, via Bear directly.