Example: export all responses
Retrieve all responses of a survey page by page, in Python and JavaScript.
The examples retrieve all responses of a survey since September 2026. They follow links.next until there is no further page. links.next is an absolute URL and already contains all parameters.
Replace ph_xxxxxxxx with your API token and the UUID with the id of your survey.
Python
import requests
BASE = "https://app.poll-hero.com/api/v1"
HEADERS = {"Authorization": "Bearer ph_xxxxxxxx"}
SURVEY = "42293d51-fdd7-49cb-a693-cc6f9f0a070b"
url = f"{BASE}/surveys/{SURVEY}/responses"
params = {"page[size]": 100, "from": "2026-09-01"}
responses = []
while url:
reply = requests.get(url, headers=HEADERS, params=params)
reply.raise_for_status()
body = reply.json()
responses.extend(body["data"])
url = body["links"]["next"] # absolute URL, carries all parameters
params = None
print(len(responses), "responses")JavaScript (Node.js)
const BASE = 'https://app.poll-hero.com/api/v1';
const HEADERS = { Authorization: 'Bearer ph_xxxxxxxx' };
const SURVEY = '42293d51-fdd7-49cb-a693-cc6f9f0a070b';
const params = new URLSearchParams({ 'page[size]': '100', from: '2026-09-01' });
let url = `${BASE}/surveys/${SURVEY}/responses?${params}`;
const responses = [];
while (url) {
const reply = await fetch(url, { headers: HEADERS });
if (!reply.ok) throw new Error(`HTTP ${reply.status}`);
const body = await reply.json();
responses.push(...body.data);
url = body.links.next; // absolute URL, carries all parameters
}
console.log(responses.length, 'responses');Tips
- Load the questions too: Also retrieve the questions of the survey (with
include_deleted=true). Usequestion_idto assign each answer to its question. - Sync regularly: Remember the time of the last retrieval and load only newer responses next time with
from. Responses can still change while a participation is in progress (for example when further questions are answered). It's best to reload the last few days and overwrite responses by theirid. - Respect the rate limit: On
429, wait for the seconds given inRetry-Afterand repeat the request. See Basics.