0

Reviews

by
Published Oct 17, 2025

This endpoint returns up to three review excerpts for a given business ordered by Yelp's default sort order. **Note:** at this time, the API does not return businesses without any reviews. To use this endpoint, make the GET request to the following URL with the ID of the business you want to get reviews for. Normally, you'll get the Business ID from /v3/businesses/search, /v3/businesses/search/phone, /v3/transactions/{transaction_type}/search or /v3/autocomplete.

Script yelp Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Yelp = {
3
  apiKey: string;
4
};
5
/**
6
 * Reviews
7
 * This endpoint returns up to three review excerpts for a given business ordered by Yelp's default sort order.
8

9
**Note:** at this time, the API does not return businesses without any reviews.
10

11
To use this endpoint, make the GET request to the following URL with the ID of the business you want to get reviews for.
12
Normally, you'll get the Business ID from /v3/businesses/search,
13
/v3/businesses/search/phone, /v3/transactions/{transaction_type}/search or
14
/v3/autocomplete.
15

16
 */
17
export async function main(
18
  auth: Yelp,
19
  business_id_or_alias: string,
20
  locale: string | undefined,
21
  offset: string | undefined,
22
  limit: string | undefined,
23
  sort_by: "yelp_sort" | undefined,
24
) {
25
  const url = new URL(
26
    `https://api.yelp.com/v3/businesses/${business_id_or_alias}/reviews`,
27
  );
28
  for (const [k, v] of [
29
    ["locale", locale],
30
    ["offset", offset],
31
    ["limit", limit],
32
    ["sort_by", sort_by],
33
  ]) {
34
    if (v !== undefined && v !== "" && k !== undefined) {
35
      url.searchParams.append(k, v);
36
    }
37
  }
38
  const response = await fetch(url, {
39
    method: "GET",
40
    headers: {
41
      Authorization: "Bearer " + auth.apiKey,
42
    },
43
    body: undefined,
44
  });
45
  if (!response.ok) {
46
    const text = await response.text();
47
    throw new Error(`${response.status} ${text}`);
48
  }
49
  return await response.json();
50
}
51