> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nodeloc.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Community API v1

> Make your first NodeLoc community API request and learn how sessions, permissions, pagination, and errors work.

The NodeLoc website and native apps use this API to read Nodes, publish topics, and manage accounts. The production base URL is `https://www.nodeloc.com/api/v1`. For a self-hosted instance, replace the origin. Use the same API paths for every interface language.

## Make a first request

This public request searches tags. Each match in `tags` includes its `name`, display `label`, and `topic_count`. An empty array means there were no matches.

```bash theme={null}
curl --get 'https://www.nodeloc.com/api/v1/search' \
  --header 'Accept: application/json' \
  --data-urlencode 'q=linux' \
  --data 'type=tags'
```

## Choose credentials

| Caller | How to authenticate |
| - | - |
| Guest reader | Call routes marked **Public** directly. Node and topic visibility still depends on the reader. |
| Signed-in browser | Same-origin requests use the `nl_session` cookie. Cross-site browser writes can return `403 cross_origin`. |
| NodeLoc native client | Send `Authorization: Bearer <session_token>`. The token identifies a user session. If the request also includes a session cookie, the server reads the cookie first. |

For sign-in, two-factor authentication, and sign-out, see [Accounts and sessions](https://docs.nodeloc.com/en/api-reference/v1/accounts.md). Third-party websites can use [Open Login](https://docs.nodeloc.com/en/api-reference/introduction.md) to authenticate users. Merchants create orders through the [payment API](https://docs.nodeloc.com/en/api-reference/payment.md). Mini Apps have their own [API and credentials](https://docs.nodeloc.com/en/miniprogram/introduction.md).

## Send requests and read responses

* For JSON requests, set `Content-Type: application/json`. Endpoints using the standard JSON decoder accept one JSON value, reject unknown fields, and limit the body to 1 MiB. File uploads use multipart and notification streams use SSE.
* A `204 No Content` response has an empty body. Other success responses have endpoint-specific fields. A tag search returns `tags`, for example, while a successful upload returns `upload`.
* Follow each endpoint's pagination rules. Return the next cursor unchanged. Depending on the list, it can be called `next_cursor`, `next_after`, or `next_before`. Search supports numbered pages.
* Transfers, lottery ticket purchases, and escrow order creation require an `Idempotency-Key` header. Reuse the same key when retrying the same operation and choose a new key for each new operation. The route tables identify endpoints that require it.
* Send `Accept-Language` to indicate a preferred language. Display the localized error message and branch on `error.code`.

## Handle errors

Calling `GET /api/v1/search` without a search term returns `422`. With English as the response language, the error includes a message for the missing field.

```json theme={null}
{"error":{"code":"invalid","message":"Please enter something to search for","fields":{"q":"Please enter something to search for"}}}
```

| HTTP status | How to handle it |
| - | - |
| `400` / `413` | For `invalid_json`, check field names, JSON syntax, and trailing content. Reduce the body size for `body_too_large`. |
| `401` | An `unauthorized` error on a protected route requires a valid session. Sign-in itself can also return `401` for invalid credentials or a second-factor challenge. Check the code. |
| `403` | Check access and account state. Sensitive operations can return `reauth_required` when the user needs to verify their identity again. |
| `404` / `405` | Check the resource, its visibility, the path, and the HTTP method. |
| `409` / `422` | Resolve the state conflict or correct the input. Show per-field feedback when `error.fields` is present. |
| `429` | When the server sends `Retry-After`, wait the indicated number of seconds. |
| `500` | Record the `X-Request-Id` response header so the site administrator can locate the request in the logs. |

## Find an operation

* [Accounts and sessions](https://docs.nodeloc.com/en/api-reference/v1/accounts.md) covers sign-in and session lifecycle.
* [Nodes, topics, and replies](https://docs.nodeloc.com/en/api-reference/v1/content.md) covers browsing, pagination, and publishing.
* [Search, uploads, and notifications](https://docs.nodeloc.com/en/api-reference/v1/client-workflows.md) shows how to page through search results, upload files, and stream unread counts.
* [Direct messages and chat](https://docs.nodeloc.com/en/api-reference/v1/inbox.md) covers conversation IDs, message history, and read positions.
* The [route index](https://docs.nodeloc.com/en/api-reference/v1/routes.md) lists methods, paths, and access requirements for community clients and integrations.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.