npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@emagri_112/foodforagentsapi

v1.1.0

Published

Typed JavaScript SDK and agent tools for restaurant search, menus, food orders and order tracking.

Readme

@emagri_112/foodforagentsapi

Typed JavaScript SDK, REST API and website demo for agent-driven food ordering.

The repository is operational in sandbox mode: an agent can search the included catalog, resolve a menu item, create a confirmed idempotent order and read its status. A real delivery transaction is created only when the backend runs in live mode with a contracted provider adapter configured.

Install the SDK

npm install @emagri_112/foodforagentsapi
import { FoodAPI } from "@emagri_112/foodforagentsapi";

const food = new FoodAPI({
  apiKey: process.env.FOODAPI_KEY,
  baseUrl: process.env.FOODAPI_BASE_URL,
});

const order = await food.order({
  query: "Crispy McBacon",
  location: "Milano",
  delivery: { address: "Via Roma 1, Milano" },
  confirm: true,
});

console.log(order.id, order.status, order.delivery.estimated_time);

confirm: true is mandatory. An agent should set it only after the user has explicitly approved the order.

Agent tools

The SDK exposes JSON-schema function tools and a dispatcher compatible with common LLM tool-calling loops:

const tools = food.agentTools();
const result = await food.executeTool(toolCall.function.name, JSON.parse(toolCall.function.arguments));

Available tools are search_restaurants, get_restaurant_menu, create_order and get_order_status.

Run the complete project

Install dependencies at the repository root and in the API directory, then start both processes:

pnpm install
pnpm dev
cd server
pnpm install
pnpm start

The website defaults to http://localhost:5173; the API defaults to http://localhost:3001. The local sandbox key is foodapi_test_sk_local and must never be reused in a shared or production environment.

REST endpoints

  • GET /health
  • GET /v1/restaurants?query=...&location=...
  • GET /v1/restaurants/:id
  • POST /v1/orders (requires confirm: true and an Idempotency-Key header)
  • GET /v1/orders/:id
  • GET /v1/tools

All /v1 requests accept Authorization: Bearer <FOODAPI_API_KEY>. The legacy X-API-Key header is also accepted.

Live provider adapter

Set these backend variables to forward confirmed orders to your ordering provider:

FOODAPI_MODE=live
FOODAPI_API_KEY=replace-with-a-private-key
FOODAPI_ORDER_WEBHOOK_URL=https://provider.example/orders
FOODAPI_ORDER_WEBHOOK_TOKEN=replace-with-provider-token
FOODAPI_CORS_ORIGIN=https://your-site.example

The provider endpoint receives the normalized order JSON plus the same Idempotency-Key. It must return JSON with an id or order_id and may return a status. Without this adapter, the API intentionally remains in sandbox and does not claim to purchase food.

Verify

pnpm test
pnpm build

Before publishing a new SDK version, inspect the package with pnpm pack --dry-run.