Efficiently Fetching Large Trello Boards with API Pagination
Learn how to fetch thousands of Trello cards without overwhelming memory or hitting rate limits by using the API’s limit/before/after pagination parameters.
19 May 2026, 14:08 UTC

The problem: huge boards choke the client
When a Trello board grows beyond a few thousand cards, a single request to /boards/{id}/cards can return a payload that overwhelms browser memory and slows UI rendering. Even if the API allowed a larger limit, the default ceiling of 1000 cards per response means many boards are split across multiple requests anyway, but without a strategy you end up making unnecessary large transfers or hitting rate‑limit walls.
Thesis: use cursor‑based pagination to retrieve cards in manageable chunks
Trello’s listCards endpoint supports the limit, before and after query parameters. By stepping through the result set with a cursor (the ID of the last card seen) you can fetch pages of, say, 200 cards each, keep network overhead low, and stay comfortably within the platform’s rate‑limit window.
How pagination works
- Endpoint:
GET https://api.trello.com/1/boards/{boardId}/cards - Parameters:
limit– maximum cards per page (1‑1000).beforeorafter– cursor value; the ID of a card that marks the start of the next page.
- The API returns cards sorted by their position in the list, and the cursor value is guaranteed to be stable for sequential requests.
Worked example: a simple Bash script
The following illustrative script fetches all cards from a board, storing each page in a JSON file. It respects the 30‑requests‑per‑10‑seconds limit by pausing after every 25 calls.
#!/usr/bin/env bash
BOARD_ID="your_board_id"
TOKEN="your_token"
KEY="your_api_key"
LIMIT=200
CURSOR="" # empty for first page
PAGE=0
while true; do
QUERY="limit=$LIMIT"
if [[ -n "$CURSOR" ]]; then
QUERY="$QUERY&before=$CURSOR"
fi
URL="https://api.trello.com/1/boards/$BOARD_ID/cards?$QUERY&key=$KEY&token=$TOKEN"
RESPONSE=$(curl -s -S "$URL")
HTTP_CODE=$(echo "$RESPONSE" | head -n1 | cut -d' ' -f2)
if [[ "$HTTP_CODE" != "200" ]]; then
echo "Error $HTTP_CODE on page $PAGE"
break
fi
echo "$RESPONSE" > "cards_page_${PAGE}.json"
# Extract the ID of the last card to use as the next cursor
LAST_ID=$(echo "$RESPONSE" | jq -r '.[-1].id // empty')
if [[ -z "$LAST_ID" ]]; then
echo "No more cards."
break
fi
CURSOR="$LAST_ID"
((PAGE++))
# Rate‑limit courtesy: sleep after every 25 requests
if (( PAGE % 25 == 0 )); then
echo "Pausing to stay under rate limit…"
sleep 10
fi
done
echo "Fetched $PAGE pages."
Note: This script is illustrative; you should adapt error handling, token storage, and output format to your environment.
Trade‑offs and limitations
- Rate limits remain: Pagination reduces the size of each request but does not change the total number of calls needed. You must still monitor
X‑RateLimit‑RemainingandX‑RateLimit‑Resetheaders and implement back‑off when approaching zero. - Cursor encoding: The
before/aftervalues are card IDs, which are URL‑safe, but if you ever use a custom cursor (e.g., a timestamp) you must URL‑encode it to avoid request failures. - Ordering guarantees: The API guarantees stable ordering only when you paginate strictly forward or backward using the returned cursor. Mixing
beforeandafterin the same session can lead to duplicate or missing cards.
Practical verification
- Create a test board with >2000 cards (you can use the Trello UI or API to bulk‑add).
- Run the script above, capturing the total number of cards returned (
jq 'length' cards_page_*.json | awk '{s+=$1} END{print s}'). - Compare that total to the board’s card count shown in the Trello UI; they should match.
- While the script runs, periodically inspect response headers with
curl -ion a single request to confirmX‑RateLimit‑Remainingstays above zero and thatX‑RateLimit‑Resetupdates as expected.
Actionable closing
If you manage large Trello boards, adopt cursor‑based pagination as the default data‑fetching pattern. Start with a modest page size (200‑500 cards), respect the rate‑limit headers, and verify end‑to‑end counts with a quick script like the one shown. This approach keeps network payloads small, improves UI responsiveness, and gives you a reliable foundation for further automation or analytics.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.