Skip to content

Client libraries

For Python and Node there are client packages, both called notefeed. They post, edit and delete notes, read a feed back page by page, and each comes with the notefeed command. Both are generated from the server's OpenAPI description and wrapped in a small hand-written Client; any other language can generate its own client from /api/v1/openapi.json.

Install

pip install notefeed        # Python 3.11 or newer
npm install notefeed        # Node 22 or newer; no dependencies

From code

Create the client with the server's URL and, usually, a default feed; every call can name another. Pass password only if the instance has one, token for an account token (the client then acts as that account: account_feeds() / accountFeeds(), claim_feed, and an owned feed's feed_passwords, add_feed_password and revoke_feed_password; never together with password), and feed_password / feedPassword for a protected feed. Client.from_env() / Client.fromEnv() reads NOTEFEED_URL, NOTEFEED_FEED, NOTEFEED_PASSWORD, NOTEFEED_TOKEN and NOTEFEED_FEED_PASSWORD instead. Keep the password and the feed name out of source code.

import os
from notefeed import Client, NotefeedError

client = Client("https://notes.example.com", feed="homelab-7f3k2q9x4m8wz",
                password=os.environ.get("MY_NOTEFEED_PASSWORD"))
try:
    created = client.post("# Deploy done\nimmich v3.2.4 on host-2", tags=["ci", "deploy"])
    print(created.id, created.url, created.read_url)

    for note in client.notes():  # newest first, fetched a page at a time
        print(note.date, note.title)
except NotefeedError as e:
    print("notefeed failed:", e, e.status, e.code)
import { Client, NotefeedError } from "notefeed";

const client = new Client({ url: "https://notes.example.com", feed: "homelab-7f3k2q9x4m8wz",
                            password: process.env.MY_NOTEFEED_PASSWORD });
try {
  const created = await client.post("# Deploy done\nimmich v3.2.4 on host-2", { tags: ["ci", "deploy"] });
  console.log(created.id, created.url, created.read_url);

  for await (const note of client.notes()) { // newest first, fetched a page at a time
    console.log(note.date, note.title);
  }
} catch (e) {
  if (e instanceof NotefeedError) console.error("notefeed failed:", e.message, e.status, e.code);
  else throw e;
}
Python Node Does
post(content, feed=, type=, title=, sender=, tags=, alt=, name=, date=, read_id=, attachments=) post(content, { feed, type, title, sender, tags, alt, name, date, readId, attachments }) Posts a note, dated now unless date is given (a date, also in the future). sender is who posted it, as shown on the note. A string is markdown; bytes are a file of media type type. attachments posts pictures with the note in one request, Attachment(name, content, type, alt) in Python, { name, content, type, alt } in Node; content may be empty to post only pictures. name is the note's file name, served for the newest note with it at /r/<read id>/<name>. Returns id, url, read_url (RSS), atom_url (the same as Atom), file, file_url and, with attachments, attachments. On notefeed.me, a post that creates a feed with a password or pictures needs the client's account token with room in its license.
create_feed(feed=, password=, read_id=) createFeed({ feed, password, readId }) Creates the feed without a note, to reserve its name; returns the feed. On notefeed.me it needs the client's account token with room in its license. A feed that exists is refused.
notes(feed=, page_size=, tag=) notes({ feed, pageSize, tag }) Every note in the feed, newest first; the next page is fetched as you iterate.
note(id, feed=) note(id, { feed }) One note.
file(name, feed=) file(name, { feed }) A note's file by its file name, as bytes: also a draft's or a scheduled note's, which file_url does not serve yet.
edit(id, content, feed=, type=) edit(id, content, { feed, type }) Replaces a note's content; id, URLs and metadata stay.
update(id, title=, alt=, sender=, tags=, date=, feed=) update(id, { title, alt, sender, tags, date }, { feed }) Sets a note's title, a picture's alt text, its sender, a note's tags (the whole list; [] removes them) or its date; "" removes a title, alt text or sender.
delete(id, feed=) delete(id, { feed }) Deletes a note for good.
feed_info(feed=) feedInfo({ feed }) The feed's name, title, description, image_url, protected, read_url and atom_url.
set_feed_image(content, type, feed=), remove_feed_image(feed=) setFeedImage(content, type, { feed }), removeFeedImage({ feed }) Sets the feed's title image from an image's bytes (no post; a previous one set this way is deleted), or removes it.
update_feed(title, description, feed=, image=, read_id=, name=) updateFeed({ title, description, image, read_id, name }, { feed }) Replaces the feed's title and description; image is the file of a picture for the title image. name renames the feed; when it is the client's own feed, the client uses the new name for the rest of that run; change NOTEFEED_FEED before the next one.
set_feed_password(password, feed=) setFeedPassword(password, { feed }) Changes a protected feed's password (the current one is the client's feed password), or gives an open feed one.
delete_feed(feed=) deleteFeed({ feed }) Deletes the feed with everything in it, for good.
set_feed_licensed(licensed, feed=) setFeedLicensed(licensed, { feed }) On notefeed.me, for the feed's owner (an account token): puts it under the account's license, or takes it off. Returns the feed.
license(), buy_license(period=, units=), change_license_units(subscription, units) license(), buyLicense({ period, units }), changeLicenseUnits(subscription, units) On notefeed.me, for the client's account: its license (subscriptions, units, the covered and licensed feeds), a checkout URL to pay at, and a subscription's new number of feeds.
licenses() licenses() On notefeed.me: the plans (amounts per feed, in cents), buy_url (the license page) and manage_url, the account page. Needs no feed.
read_notes(read_id, page_size=), read_note(read_id, id) readNotes(readId, { pageSize }), readNote(readId, id) Like notes() and note(), by the feed's read id: public, no password, never the name.

A note has id, type, title, content (absent for a picture), file, file_url, size, tags, date, scheduled (only for the owner, when the date is in the future), draft (only for the owner, for a draft) and url, and optionally alt, name and sender. Timeouts default to 10 seconds. Feed names are checked on the client, so a typo fails with a ConfigError before any request.

The Python client checks the instance's certificate against the operating system's trusted certificates (truststore, not certifi's bundle, and only for its own connections), so an instance behind your own certificate authority works once that authority is trusted on the machine. Node uses its own bundled certificates unless started with --use-system-ca (or NODE_USE_SYSTEM_CA=1).

Errors

Every error is a NotefeedError with status and code (both empty for network and configuration problems). The type follows the code:

Type When
ConfigError Empty URL, no feed, an invalid feed name, no content and no attachments: checked before any request.
InvalidRequestError The server refused the request itself (invalid_feed, reserved_feed, empty_note, invalid_body, unsupported_type, blocked).
AuthError The instance or the feed has a password and it's missing or wrong.
NotFoundError No such note or feed, or a feed the operator removed.
NoteTooLargeError A note over 100 KB, or a picture over the size limit.
RateLimitedError Too many posts or wrong passwords; retry_after / retryAfter is the wait in seconds.
LimitReachedError The instance's feed cap, or the feed's note or image cap, is reached.
ImagesOffError The instance takes no pictures.

The message is the server's own reason; every status and code is in the REST API.