Skip to main content

Batch data

For admins needing to access batch data, Privy allows you to page through user data via the privy-node client.

Accessing batch data

To get the fields first-name and last-name for 50 users:

// Initialize client.
const client = new PrivyClient(PRIVY_API_KEY, PRIVY_API_SECRET);
// Call getBatch.
let batchData = await client.getBatch(['first-name', 'last-name'], {
limit: 50,
// Returns {next_cursor_id: "0x456", users: [{user_id: '0x123', data: [...]}, ...]}.

Using the cursor

The getBatch calls follows the standard pattern for cursor-based pagination. Specifically the call to getBatch returns next_cursor_id, which can then be passed to subsequent calls to getBatch in order to get subsequent batches of user data. If there are no more users, an empty string is returned for next_cursor_id.

// The next_cursor_id returned from the previous call to `getBatch`.
const cursor_id = '0x456';
// Call to `getBatch` to get the next 50 users.
const batchData = await client.getBatch(['first-name', 'last-name'], {
cursor: cursor_id
limit: 50,
// Returns {next_cursor_id: "0x789", users: [{user_id: '0x456', data: [...]}, ...]}.