Halal Eats

JavaScript SDK

Install and use @halal-eats/sdk to fetch halal restaurant data.

@halal-eats/sdk is the recommended way to use Halal Eats from JavaScript or TypeScript.

Install

npm install @halal-eats/sdk

Create a client

import { HalalEatsClient } from "@halal-eats/sdk";

const client = new HalalEatsClient();

List restaurants

const response = await client.stores.list({
  search: "Turkish",
  halalStatus: "verified_halal",
  limit: 10,
});

console.log(response.data);

Find restaurants nearby

const response = await client.stores.nearby({
  lat: -33.8688,
  lng: 151.2093,
  radius: 5000,
  limit: 20,
});

console.log(response.data);

Get restaurant details

const response = await client.stores.get("STORE_ID");

console.log(response.data.name);

Categories and stats

const categories = await client.categories.list();
const stats = await client.stats.get();

Custom API URL

Use baseUrl for local development or self-hosted environments:

const client = new HalalEatsClient({
  baseUrl: "http://localhost:3000/api/v1",
});

API keys

Public read endpoints do not require an API key. If you have an API key for contribution endpoints, pass it when creating the client:

const client = new HalalEatsClient({
  apiKey: process.env.HALAL_EATS_API_KEY,
});

Error handling

Failed API responses throw HalalEatsError.

import { HalalEatsClient, HalalEatsError } from "@halal-eats/sdk";

const client = new HalalEatsClient();

try {
  await client.stores.get("missing-id");
} catch (error) {
  if (error instanceof HalalEatsError) {
    console.error(error.status, error.code, error.body);
  }
}

Available methods

client.stores.list(params);
client.stores.get(id);
client.stores.nearby({ lat, lng, radius, limit });
client.categories.list();
client.stats.get();

TypeScript

The package ships with TypeScript declarations. Useful exported types include:

import type {
  PublicStore,
  PublicHalalStatus,
  StoreListResponse,
  StoreResponse,
  CategoriesResponse,
  StatsResponse,
} from "@halal-eats/sdk";

On this page