Skip to content

List and Search Chainers

In this tutorial you will retrieve a list of chainers (users) from the API, paginate through large result sets using cursor-based pagination, and search by username.

Prerequisites

  • A Chainabit account with a valid access token
  • curl available in your terminal

Set your environment variables:

bash
export TOKEN="your-access-token"

Step 1: List Chainers

Retrieve the first page of chainers:

bash
curl -s "https://api.chainabit.com/api/v1/chainers?limit=10" \
  -H "Authorization: Bearer $TOKEN"
javascript
const res = await fetch(`https://api.chainabit.com/api/v1/chainers?limit=10`, {
  headers: { Authorization: `Bearer ${TOKEN}` },
});
const data = await res.json();
console.log(data);
python
import requests

res = requests.get(
    f"{BASE}/chainers",
    headers={"Authorization": f"Bearer {TOKEN}"},
    params={"limit": 10},
)
print(res.json())

Response:

json
{
  "data": [
    {
      "id": "chainer_01HQA...",
      "username": "alex_builder",
      "displayName": "Alex Builder",
      "avatarUrl": "https://cdn.chainabit.com/avatars/alex.png",
      "createdAt": "2026-01-15T08:00:00.000Z"
    },
    {
      "id": "chainer_01HQB...",
      "username": "jordan_creates",
      "displayName": "Jordan Creates",
      "avatarUrl": null,
      "createdAt": "2026-02-01T12:30:00.000Z"
    }
  ],
  "meta": {
    "hasMore": true,
    "nextCursor": "eyJpZCI6ImNoYWluZXJfMDFIUUIuLi4ifQ=="
  }
}

Step 2: Paginate with Cursors

When meta.hasMore is true, use the nextCursor value to fetch the next page:

bash
curl -s "https://api.chainabit.com/api/v1/chainers?limit=10&cursor=eyJpZCI6ImNoYWluZXJfMDFIUUIuLi4ifQ==" \
  -H "Authorization: Bearer $TOKEN"
javascript
const cursor = 'eyJpZCI6ImNoYWluZXJfMDFIUUIuLi4ifQ==';
const res = await fetch(`https://api.chainabit.com/api/v1/chainers?limit=10&cursor=${cursor}`, {
  headers: { Authorization: `Bearer ${TOKEN}` },
});
const data = await res.json();
console.log(data);
python
cursor = "eyJpZCI6ImNoYWluZXJfMDFIUUIuLi4ifQ=="
res = requests.get(
    f"{BASE}/chainers",
    headers={"Authorization": f"Bearer {TOKEN}"},
    params={"limit": 10, "cursor": cursor},
)
print(res.json())

Continue passing the nextCursor from each response until hasMore is false.

Pagination Flow


Step 3: Search by Username

Filter chainers by username using the search query parameter:

bash
curl -s "https://api.chainabit.com/api/v1/chainers?search=alex&limit=10" \
  -H "Authorization: Bearer $TOKEN"
javascript
const res = await fetch(`https://api.chainabit.com/api/v1/chainers?search=alex&limit=10`, {
  headers: { Authorization: `Bearer ${TOKEN}` },
});
const data = await res.json();
console.log(data);
python
res = requests.get(
    f"{BASE}/chainers",
    headers={"Authorization": f"Bearer {TOKEN}"},
    params={"search": "alex", "limit": 10},
)
print(res.json())

Response:

json
{
  "data": [
    {
      "id": "chainer_01HQA...",
      "username": "alex_builder",
      "displayName": "Alex Builder",
      "avatarUrl": "https://cdn.chainabit.com/avatars/alex.png",
      "createdAt": "2026-01-15T08:00:00.000Z"
    }
  ],
  "meta": {
    "hasMore": false,
    "nextCursor": null
  }
}

The search is case-insensitive and matches against the username field.


Summary

In this tutorial you:

  1. Listed chainers with a page size limit
  2. Used cursor-based pagination to walk through results
  3. Searched by username to filter results

Next Steps

Built with purpose.