/api/v1 is the site API shared by the NodeLoc web interface and native apps. Public resources can be read anonymously. Viewer-specific permissions and writes use a site session. These examples send a native-app-style session token in Authorization: Bearer. Same-origin browser requests can use the nl_session cookie. The third-party OAuth token from Open Login grants access to authorized profile information. See v1 overview, Accounts and authentication, and Open Login.
The examples use a local instance. Set BASE_URL, NODE_SLUG, and TOPIC_ID to the instance and resources you are using. The authenticated requests assume NODELOC_SESSION_TOKEN is set in your environment. API paths are independent of the interface language prefix.
Find a Node
UseGET /api/v1/nodes to list visible Nodes. Add q to search and use an empty cursor= to start at the beginning. Pass next_cursor back as cursor on the next request and keep the same search criteria. The final response omits next_cursor. For numbered pages, start with page=1 and follow next_page. The default page size is 20 and limit accepts 1–100. Use one pagination mode per request. Without any search or pagination parameters, the response contains only nodes.
slug to fetch its details. Before posting, fetch details with the writer’s session and inspect permissions.create_topic and posting. min_tags is the minimum number of tags. If tags_restricted is true, use tags from tag_options.
Browse topics and posts
Without filters,GET /api/v1/topics returns home feed topics in order of most recent activity. Add node or tag to narrow the list. Topic lists, topic details, and reply lists accept a limit of 1–50 and default to 30.
topics[].id. Topic details return topic, one page of posts, next_after, and the viewer’s permissions. Posts appear in order by post number, starting with the first post at 1. Use next_after as the next request’s after. A null value marks the last page.
GET /api/v1/topics/{id}/replies?sort=best&offset=0&limit=10. It excludes the first post and system action records. The supported sorts are best, new, old, and controversial. Pass next_offset as offset to continue. The last page omits next_offset.
Publish a topic
Send the Node’sslug in node and the Markdown body in raw. Titles must contain 6–255 characters, and the first post must contain at least 8 characters. Use tags that match the target Node’s rules. Change node and tags in the example if you are posting to a different Node.
topic.id to open the topic or send a reply. If held is true, the content is awaiting review and appears publicly once approved.
Reply to a topic or post
Fetch topic details with the writer’s session and checkpermissions.reply. Send the reply in raw. To reply to a particular post in the topic, set reply_to_post_number. To reply to the topic itself, omit the field or set it to 0. A post_number identifies a post within the topic. The id identifies the post across the site.
Set TOPIC_ID to the topic.id returned by the previous request. The example replies to its first post.
Handle permissions and errors
Lists and details reflect what the viewer can access. A title may appear in a list while the body still requires sign-in or a minimum tier. Publishing checks permissions, account status, Node rules, and rate limits again at the time of the request.
Use the HTTP status and
error.code in application logic. error.message and values in error.fields are display text and can vary by language. In this example, merged_into gives the new location of the original first post.
