Updated Oct 2026
Trustpilot API in Python: public reviews, OAuth and replies
Trustpilot has one of the more complete review APIs, and one of the more gated: you need the API module on your business plan, an API application with a key and a secret, and a business-user OAuth token for anything beyond public reviews. This guide does the whole flow in Python with requests. If you don’t have the key yet, start with how to get a Trustpilot API key.
pip install requestsValues you need from Trustpilot Business → Integrations → API: the API key, the API secret, and the email and password of a business user with permission to reply.
1. Find your business unit ID
Everything hangs off the business unit (one per domain):
import os, requests
KEY = os.environ["TRUSTPILOT_API_KEY"]
BASE = "https://api.trustpilot.com/v1"
r = requests.get(f"{BASE}/business-units/find", params={"name": "example.com", "apikey": KEY}, timeout=30)
r.raise_for_status()
BU = r.json()["id"]
print(BU, r.json()["displayName"], r.json()["trustScore"], r.json()["numberOfReviews"]["total"])2. Read public reviews (API key only)
def public_reviews(bu):
page = 1
while True:
r = requests.get(f"{BASE}/business-units/{bu}/reviews", params={"apikey": KEY, "perPage": 100, "page": page, "orderBy": "createdat.desc"}, timeout=30)
r.raise_for_status()
data = r.json()
yield from data["reviews"]
if page * 100 >= data["pagination"]["totalCount"] if "pagination" in data else len(data["reviews"]) < 100:
break
page += 1
for rev in public_reviews(BU):
print(rev["stars"], rev["consumer"]["displayName"], rev["title"], (rev.get("text") or "")[:80], bool(rev.get("companyReply")))Public reviews include stars, title, text, createdAt, the consumer’s display name and companyReply with your existing reply. They don’t include the reviewer’s email, the reference ID you used in the invitation, or reviews that aren’t published.
3. Get a business-user access token (private endpoints and replies)
import base64
basic = base64.b64encode(f"{KEY}:{os.environ['TRUSTPILOT_API_SECRET']}".encode()).decode()
r = requests.post(f"{BASE}/oauth/oauth-business-users-for-applications/accesstoken",
headers={"Authorization": f"Basic {basic}", "Content-Type": "application/x-www-form-urlencoded"},
data={"grant_type": "password", "username": os.environ["TRUSTPILOT_USER"], "password": os.environ["TRUSTPILOT_PASSWORD"]}, timeout=30)
r.raise_for_status()
tok = r.json()
H = {"Authorization": f"Bearer {tok['access_token']}"}
REFRESH = tok["refresh_token"] # access tokens last about 100 hours; refresh with grant_type=refresh_tokenPrivate reviews, with consumer details and every state:
r = requests.get(f"{BASE}/private/business-units/{BU}/reviews", headers=H, params={"perPage": 100, "orderBy": "createdat.desc"}, timeout=30)
r.raise_for_status()
for rev in r.json()["reviews"]:
print(rev["id"], rev["stars"], rev.get("referenceId"), rev["consumer"].get("email"))4. Reply, or remove a reply
me = requests.get(f"{BASE}/private/business-users/me", headers=H, timeout=30).json() # the user who signs the reply
review_id = rev["id"]
requests.post(f"{BASE}/private/reviews/{review_id}/reply", headers=H,
json={"message": "Thank you, Laura. We've refunded the delivery fee and passed your note to the courier team.",
"authorBusinessUserId": me["id"]}, timeout=30).raise_for_status()
# DELETE f"{BASE}/private/reviews/{review_id}/reply" removes itReplies show on the public profile right away and the reviewer is notified. Trustpilot’s guidelines apply: no personal data about the reviewer in the reply, no asking them to change the rating.
5. The same job through Prisma
Prisma connects a Trustpilot profile with the business user’s sign-in (OAuth) plus the domain, keeps the tokens, polls for new reviews and sends a webhook per review; replies go through the same private endpoint. One key then covers Trustpilot, Google, the app stores and 50+ other platforms.
H = {"Authorization": f"Bearer {os.environ['PRISMA_API_KEY']}"}
r = requests.get("https://api.prismareviews.com/v1/reviews", headers=H, params={"platform": "trustpilot", "has_reply": "false"}, timeout=30)
for rev in r.json()["data"]:
print(rev["rating"], rev["title"], rev["text"])
requests.post(f"https://api.prismareviews.com/v1/reviews/{rev['id']}/reply", headers=H, json={"text": "Thank you, Laura…"}, timeout=30)What’s true today: Trustpilot in Prisma is in beta, and replies through Prisma start when Trustpilot approves Prisma’s integration (Trustpilot reviews each integrator); until then Trustpilot reviews are read through the connection and you answer on Trustpilot. Test keys (pk_test_…) return sample Trustpilot reviews so the code runs now. Status per platform: Platforms.
Common errors
| Error | Cause | Fix |
|---|---|---|
401 on /business-units/find | Key missing or wrong | Pass apikey as a query parameter or apikey header |
403 on /private/... | Public key used where a token is needed, or the user can’t reply | Get the business-user token (section 3); check the user’s permissions |
400 invalid_grant on the token call | Wrong Basic header (key:secret) or wrong user password | Rebuild the Basic header; the user must be a Trustpilot Business login, not an API key |
Empty reviews | Wrong business unit | Look it up again with /business-units/find?name= |
FAQ
Do I need a paid Trustpilot plan to use the API in Python?
Yes. API access comes with Trustpilot’s API module, sold to the business as part of a plan. Without it you can’t create an API application, so there is no key and no secret.
What’s the difference between public and private Trustpilot review endpoints?
Public endpoints (/v1/business-units/{id}/reviews) take the API key as a query parameter or header and return published reviews with limited fields. Private endpoints (/v1/private/...) need an OAuth access token of a business user and return consumer details, unpublished states and allow replies.
Can I reply to Trustpilot reviews from Python?
Yes: POST /v1/private/reviews/{reviewId}/reply with a business-user access token, the message and the authorBusinessUserId of the user who signs the reply. DELETE on the same path removes it.
Trustpilot, Google and 40+ more, one key.
2 locations free. Test keys return sample reviews from every platform.