Skip to main content

Make your first Pollarix API request

Use the Pollarix API to read surveys from your department. You'll generate a token, then request one survey to check access. You need a Pro or Enterprise department and an API user from that department.

Get your credentials​

Ask a department administrator to create a dedicated API user under Department settings → Users. In Department settings → API keys, find the department API key and API secret. Keep the secret in your integration's secret store and use the API user's identifier email.

Exchange your credentials and read a survey​

Send a JSON request with apiKey, apiSecret, and email to POST /api/v1/auth/access-token. The response includes access_token, token_type, and expires_in. Use the token as a bearer token. It expires after three hours.

The following Python example reads credentials from the process environment and prints only the number of matching surveys. Run it against a department you're authorized to read.

import json
import os
from urllib.request import Request, urlopen

base = "https://api.pollarix.com/api/v1"
department_id = os.environ["POLLARIX_API_KEY"]
credentials = {
"apiKey": department_id,
"apiSecret": os.environ["POLLARIX_API_SECRET"],
"email": os.environ["POLLARIX_API_USER_EMAIL"],
}
token_request = Request(
f"{base}/auth/access-token",
data=json.dumps(credentials).encode(),
headers={"Content-Type": "application/json"},
)
with urlopen(token_request, timeout=15) as response:
token = json.load(response)["access_token"]

survey_request = Request(
f"{base}/survey/department/{department_id}?pageSize=1",
headers={"Authorization": f"Bearer {token}"},
)
with urlopen(survey_request, timeout=15) as response:
print("Surveys:", json.load(response)["totalCount"])

You should see Surveys: followed by a number. A department with no surveys returns zero.

  • If token generation fails, verify the key, secret, and API user belong to the same department.
  • If the read returns 403, check department scope, permissions, and REST API availability on the plan.
  • If a previously working token expires, request a fresh token before retrying.

Next steps​

Was this page helpful?