Appearance
Pagination
Lists return one page at a time. Every list takes limit from 1 to 100 and defaults to 20; a limit outside that range answers 400 and code 1701: with the description limit is 1 to 100 for a value of one to three digits, and the generic description for anything else (1000, -1, abc). The API has three ways to ask for the next page, and each route uses one of them.
| Route | Style | Order | Next page |
|---|---|---|---|
GET /accounts | Cursor | Newest first | data.next_cursor, sent back as cursor |
GET /accounts/:id/transactions | Cursor, tied to its filters | Oldest first | data.next_cursor, sent back as cursor |
GET /transactions | Cursor | Newest first | data.next_cursor, sent back as cursor |
GET /accounts/:id/payouts | starting_after | Newest first | The last payout_id on the page, sent as starting_after, while data.has_more is true |
GET /refunds | starting_after | Newest first | The last id on the page, sent as starting_after, while data.has_more is true |
GET /charges | None | Newest first | No next page. limit caps how many charges for the reference come back |
Cursors
A cursor is an opaque string. Do not parse it, build it or store it for later use: send back exactly what the last page gave you.
next_cursorisnullon the last page. Stop there.- A cursor is signed and tied to your platform. An edited cursor, or one made for another platform, answers
400and code3012. - On
GET /accounts/:id/transactionsthe cursor is also tied to the account, thewalletand thefrom/towindow it was made for. Send it with no other filters, or with the same ones. A different filter alongside it answers400, code3012. - On
GET /transactions, send the cursor with the sameaccount,type,fromandtoyou used for the first page. The route does not check that they match, and changing them part way through gives a list that is neither one query nor the other. - If you get
3012, start the list again from the first page.
A page can be short and still not be the last
GET /transactions leaves out movements of accounts your platform can no longer reach (the seller revoked your access) after the page has been read. A page can therefore hold fewer than limit rows, or none, while next_cursor is still set. Keep going until next_cursor is null; do not stop at a short page.
GET /accounts/:id/transactions pages by position within the window, oldest first. Movements that arrive while you page are added at the end, so a loop that runs to next_cursor: null sees them if they fall inside the window.
Read the whole feed
sh
BASE=https://payments-ke-staging.mookhpay.co/v1/payments/merchant
CURSOR=""
while :; do
if [ -z "$CURSOR" ]; then
URL="$BASE/transactions?limit=100&from=2026-11-01T00:00:00Z"
else
URL="$BASE/transactions?limit=100&from=2026-11-01T00:00:00Z&cursor=$CURSOR"
fi
PAGE=$(curl -s "$URL" -H "Authorization: Bearer $MOOKHPAY_SECRET_KEY")
echo "$PAGE" | jq -c '.data.movements[]'
CURSOR=$(echo "$PAGE" | jq -r '.data.next_cursor // empty')
[ -z "$CURSOR" ] && break
donejs
const BASE = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant";
export async function* allMovements(from) {
let cursor = null;
do {
const params = new URLSearchParams({ limit: "100", from });
if (cursor) params.set("cursor", cursor);
const res = await fetch(`${BASE}/transactions?${params}`, {
headers: { Authorization: `Bearer ${process.env.MOOKHPAY_SECRET_KEY}` },
});
const answer = await res.json();
if (!res.ok) throw new Error(`${res.status} ${answer.code}: ${answer.description}`);
yield* answer.data.movements;
cursor = answer.data.next_cursor;
} while (cursor);
}
for await (const movement of allMovements("2026-11-01T00:00:00Z")) {
console.log(movement.account, movement.type, movement.amount);
}python
import os
import requests
BASE = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant"
def all_movements(since):
cursor = None
while True:
params = {"limit": 100, "from": since}
if cursor:
params["cursor"] = cursor
res = requests.get(
f"{BASE}/transactions",
params=params,
headers={"Authorization": f"Bearer {os.environ['MOOKHPAY_SECRET_KEY']}"},
timeout=15,
)
answer = res.json()
if not res.ok:
raise RuntimeError(f"{res.status_code} {answer['code']}: {answer['description']}")
yield from answer["data"]["movements"]
cursor = answer["data"]["next_cursor"]
if not cursor:
return
for movement in all_movements("2026-11-01T00:00:00Z"):
print(movement["account"], movement["type"], movement["amount"])php
<?php
const BASE = 'https://payments-ke-staging.mookhpay.co/v1/payments/merchant';
function allMovements(string $from): Generator
{
$cursor = null;
do {
$params = ['limit' => 100, 'from' => $from];
if ($cursor !== null) {
$params['cursor'] = $cursor;
}
$ch = curl_init(BASE . '/transactions?' . http_build_query($params));
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 15,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('MOOKHPAY_SECRET_KEY')],
]);
$answer = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($status !== 200) {
throw new RuntimeException("$status {$answer['code']}: {$answer['description']}");
}
yield from $answer['data']['movements'];
$cursor = $answer['data']['next_cursor'];
} while ($cursor !== null);
}
foreach (allMovements('2026-11-01T00:00:00Z') as $movement) {
echo $movement['account'], ' ', $movement['type'], ' ', $movement['amount'], PHP_EOL;
}starting_after
GET /accounts/:id/payouts returns data.payouts and data.has_more. For the next page, send the last payout_id on the current page as starting_after. A payout_id that is not one of this account's payouts answers 400, code 3012. Stop when has_more is false.
sh
BASE=https://payments-ke-staging.mookhpay.co/v1/payments/merchant
ACCOUNT=acct_ke_9c2f41b07e5d38a6c1f0b294
AFTER=""
while :; do
URL="$BASE/accounts/$ACCOUNT/payouts?limit=100${AFTER:+&starting_after=$AFTER}"
PAGE=$(curl -s "$URL" -H "Authorization: Bearer $MOOKHPAY_SECRET_KEY")
echo "$PAGE" | jq -c '.data.payouts[]'
[ "$(echo "$PAGE" | jq -r '.data.has_more')" = "true" ] || break
AFTER=$(echo "$PAGE" | jq -r '.data.payouts[-1].payout_id')
donejs
const BASE = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant";
export async function* allPayouts(accountId) {
let after = null;
for (;;) {
const params = new URLSearchParams({ limit: "100" });
if (after) params.set("starting_after", after);
const res = await fetch(`${BASE}/accounts/${accountId}/payouts?${params}`, {
headers: { Authorization: `Bearer ${process.env.MOOKHPAY_SECRET_KEY}` },
});
const answer = await res.json();
if (!res.ok) throw new Error(`${res.status} ${answer.code}: ${answer.description}`);
const { payouts, has_more } = answer.data;
yield* payouts;
if (!has_more || payouts.length === 0) return;
after = payouts[payouts.length - 1].payout_id;
}
}python
import os
import requests
BASE = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant"
def all_payouts(account_id):
after = None
while True:
params = {"limit": 100}
if after:
params["starting_after"] = after
res = requests.get(
f"{BASE}/accounts/{account_id}/payouts",
params=params,
headers={"Authorization": f"Bearer {os.environ['MOOKHPAY_SECRET_KEY']}"},
timeout=15,
)
answer = res.json()
if not res.ok:
raise RuntimeError(f"{res.status_code} {answer['code']}: {answer['description']}")
payouts = answer["data"]["payouts"]
yield from payouts
if not answer["data"]["has_more"] or not payouts:
return
after = payouts[-1]["payout_id"]php
<?php
const BASE = 'https://payments-ke-staging.mookhpay.co/v1/payments/merchant';
function allPayouts(string $accountId): Generator
{
$after = null;
while (true) {
$params = ['limit' => 100];
if ($after !== null) {
$params['starting_after'] = $after;
}
$ch = curl_init(BASE . "/accounts/$accountId/payouts?" . http_build_query($params));
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 15,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('MOOKHPAY_SECRET_KEY')],
]);
$answer = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($status !== 200) {
throw new RuntimeException("$status {$answer['code']}: {$answer['description']}");
}
$payouts = $answer['data']['payouts'];
yield from $payouts;
if (!$answer['data']['has_more'] || count($payouts) === 0) {
return;
}
$after = end($payouts)['payout_id'];
}
}Rate limits while paging
Every page is one request against the platform bucket of 120 a minute. Reading 10,000 movements at 100 a page is 100 requests. Page in the background, keep your own copy, and read only new movements next time by passing from. See Limits.