0

All Categories

by
Published Oct 17, 2025

This endpoint returns all Yelp business categories across all locales by default. Include the "locale" parameter to filter to only those categories available for a particular locale, and translate/localize the names of those categories.

Script yelp Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Yelp = {
3
  apiKey: string;
4
};
5
/**
6
 * All Categories
7
 * This endpoint returns all Yelp business categories across all locales by default.
8
Include the "locale" parameter to filter to only those categories available for a particular locale, and translate/localize the names of those categories.
9

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