Skip to main content
These examples use a local instance. For authenticated calls, set NODELOC_SESSION_TOKEN to an existing NodeLoc session token or use the session cookie from a same-origin browser. See the Community API v1 overview for authentication and common errors.
GET /api/v1/search accepts anonymous requests. Results reflect what the current viewer can access.
The response includes posts, topics, users, nodes, and tags arrays. topics groups matching posts by topic and can contain fewer entries than posts. Follow has_more and the returned next_page or next_offset. The last page omits the continuation fields.
Search allows 30 requests per minute per account or per IP for anonymous requests. If it returns 429 rate_limited, wait the number of seconds in Retry-After.

Upload images and attachments

POST /api/v1/uploads requires a session. Send file in a multipart/form-data request. JPEG, PNG, GIF, and WebP images are accepted by default. For a non-image attachment such as a PDF, add the form field kind=attachment. The account needs the uploads.attach permission. The single-file limit is 15 MiB.
cURL generates the multipart Content-Type header and boundary. A successful upload returns HTTP 201 and an upload object.
url is relative to the site, and size is in bytes. Attachments return image: false with null dimensions. Use the URL in an image or download link in your post’s Markdown. File validation returns 422 invalid with details in error.fields.file. Missing attachment permission returns 403 trust_level_too_low. Exceeding the daily upload limit returns 429 upload_daily_limit.

List notifications and mark them read

GET /api/v1/notifications returns the signed-in user’s notifications. Omit filter for all notifications, or use unread, reply, mention, vote, follow, points, system, or moderation. limit defaults to 30 and accepts 1–50. Pass next_before as before on the next request. A null value marks the end. unread is the account’s total unread count.
Send a notification id from the list to POST /api/v1/notifications/read to mark one notification read. {"up_to_id":240} marks notifications with IDs up to and including 240. {} marks all notifications. Success returns HTTP 204 with an empty body.

Subscribe to the unread count

GET /api/v1/notifications/stream uses Server-Sent Events (SSE). It sends the current unread count when you connect and an updated total when notifications change. A same-origin browser can use EventSource to listen for unread. A native client can use an SSE client that sends the Bearer header.
Parse the event’s data as JSON and use its unread value to update the badge. If the notification list is open, fetch it again. The server sends a : ping comment about every 25 seconds and closes connections after at most 30 minutes. After reconnecting, use the first unread event to update the badge and refresh any open lists.