0

Category Details

by
Published Oct 17, 2025

This endpoint returns detailed information about the Yelp category specified by a Yelp category alias. The alias for each category can be found either by using the /v3/categories endpoint, or the category list.

Script yelp Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Yelp = {
3
  apiKey: string;
4
};
5
/**
6
 * Category Details
7
 * This endpoint returns detailed information about the Yelp category specified by a Yelp category alias. The alias for each category can be found either by using the /v3/categories endpoint, or the category list.
8

9
 */
10
export async function main(
11
  auth: Yelp,
12
  alias: string,
13
  locale: string | undefined,
14
) {
15
  const url = new URL(`https://api.yelp.com/v3/categories/${alias}`);
16
  for (const [k, v] of [["locale", locale]]) {
17
    if (v !== undefined && v !== "" && k !== undefined) {
18
      url.searchParams.append(k, v);
19
    }
20
  }
21
  const response = await fetch(url, {
22
    method: "GET",
23
    headers: {
24
      Authorization: "Bearer " + auth.apiKey,
25
    },
26
    body: undefined,
27
  });
28
  if (!response.ok) {
29
    const text = await response.text();
30
    throw new Error(`${response.status} ${text}`);
31
  }
32
  return await response.json();
33
}
34