GuideGuides/Recettes/Fetch recent reviews

Ce guide est disponible en anglais.

How do I fetch recent reviews through the API?

Fetch Recent Reviews via API

Pull a location's reviews from every connected platform with the Synup API, filter to what needs attention, and page through with a cursor.

En bref

Ce que ce guide permet
Read a location's reviews across platforms, filtered and paged, for an inbox or a feed.
API utilisées
Référence
Reviews
Prérequis
  • An API key
  • A locationId and its clientId
Cas d'usage typiques
  • Building a review inbox
  • Pulling the latest reviews into your own dashboard
  • Finding unreplied negative reviews to triage

GET /api/v1/reviews returns a page of one location's reviews, up to 100 at a time, from every connected platform plus any custom pages the account added. Every call takes locationId and clientId together. The filters combine into a single request, so an inbox view is one call, not a fetch-then-filter.

curl "https://ai.synup.com/api/v1/reviews?locationId=LOCATION_ID&clientId=CLIENT_ID&status=unreplied&ratings=1,2,3&sort=newest&limit=100" \
  -H "Authorization: Bearer $SYNUP_API_KEY"
const API = "https://ai.synup.com/api/v1";
const headers = { Authorization: `Bearer ${process.env.SYNUP_API_KEY}` };

async function* reviews(locationId, clientId, filters = {}) {
  let cursor = "";
  do {
    const params = new URLSearchParams({ locationId, clientId, limit: "100", cursor, ...filters });
    const res = await fetch(`${API}/reviews?${params}`, { headers });
    if (!res.ok) throw new Error(`${res.status}: ${(await res.json()).error}`);
    const { data } = await res.json();
    yield* data.reviews; // { id, author, rating, body, reviewDate, platform, sentiment, reply, respondable }
    cursor = data.nextCursor ?? "";
  } while (cursor);
}

for await (const r of reviews("LOCATION_ID", "CLIENT_ID", { status: "unreplied", sort: "newest" })) {
  console.log(r.rating, r.platform, r.body.slice(0, 80));
}
import os
import requests

API = "https://ai.synup.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['SYNUP_API_KEY']}"}

def reviews(location_id, client_id, **filters):
    cursor = ""
    while True:
        params = {"locationId": location_id, "clientId": client_id, "limit": 100, "cursor": cursor, **filters}
        r = requests.get(f"{API}/reviews", headers=HEADERS, params=params, timeout=30)
        r.raise_for_status()
        data = r.json()["data"]
        yield from data["reviews"]
        cursor = data.get("nextCursor") or ""
        if not cursor:
            return

The filters that matter: status=unreplied for the queue, ratings=1,2 for the ones that sting, sentiment=negative when the text is worse than the stars, from and to for a window, sort=newest for a feed. Each review also carries topics, the themes Synup pulled from the text, and respondable, which is false when the source does not accept replies or the review has been removed. Pass deleted=1 to list reviews that have vanished from their platform instead of the live ones.

Ready to answer them? Respond to a review is the next call. Filters, notes and analytics are all in the reviews guide.