@halal-eats/sdk
v1.0.0
Published
TypeScript SDK for the Halal Eats public API.
Downloads
73
Maintainers
Readme
@halal-eats/sdk
A tiny TypeScript SDK for the Halal Eats public API.
npm install @halal-eats/sdkQuick start
import { HalalEatsClient } from "@halal-eats/sdk";
const client = new HalalEatsClient({
apiKey: process.env.HALAL_EATS_API_KEY, // optional for public endpoints
});
const response = await client.stores.list({
search: "Turkish",
halalStatus: "verified_halal",
});
console.log(response.data);Configuration
By default, the SDK points at the hosted Halal Eats API:
const client = new HalalEatsClient();You can point it at another API base URL for local development or self-hosting:
const client = new HalalEatsClient({
baseUrl: "http://localhost:3000/api/v1",
});Available methods
client.stores.list({ page, limit, search, halalStatus, cuisine, bounds })client.stores.get(id)client.stores.nearby({ lat, lng, radius, limit })client.categories.list()client.stats.get()
Errors
Failed API responses throw HalalEatsError with:
statuscodebody
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);
}
}Development
npm install
npm run typecheck
npm run buildLicense
MIT
