SDKs & embeds
DocumentationSDKs & embedsGrubhub supported
TRY IT. MAKE IT YOURS.

A head start
for your whole app.

Use the same ordering experience as the playground, build your own with the server SDK, or drop in hosted tracking.

TypeScript typesNo runtime dependenciesSDK v0.3.4
Install server + browser SDKs
npm install https://mealmeai.vercel.app/sdk/mealme-sdk-0.3.4.tgz
01

Create a session on your server.

Your backend authenticates the customer and creates a short-lived session for your app’s origin.

your-server.ts
// Your authenticated server. Derive customerId from the login.
const session = await mealme.createOrderingSession({
  externalCustomerId: customerId,
  allowedOrigin: 'https://your-app.example'
});
// Return this scoped session to that customer's browser.
// Keep your developer API key on the server.
02

Mount the ordering experience.

Address suggestions, restaurant and grocery selection, menus, required options, cart building, and checkout are included.

your-frontend.ts
import { mountOrdering } from '@mealme/sdk/browser';

const ordering = mountOrdering({
  element: '#ordering', session,
  async onCheckout(quote) {
    const response = await fetch('/api/approve-order', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ quoteId: quote.quoteId })
    });
    if (!response.ok) throw new Error('Checkout not approved.');
    return response.json(); // checkoutToken + idempotencyKey
  },
  onOrder: order => showTracking(order.trackingUrl)
});
// On unmount: ordering.destroy();
03

Approve customer payment in your backend.

Your app decides when a customer can spend. Verify the quote and your payment authorization before returning a scoped checkout approval.

/api/approve-order
// In /api/approve-order, authenticate your customer first.
const quote = await mealme.getQuote(requestedQuoteId);
if (quote.externalCustomerId !== customerId ||
    quote.expired || quote.orderId) {
  throw new Error('This quote is unavailable.');
}

// YOUR CUSTOMER PAYMENT GOES HERE.
// Authorize the exact USD amount with your payment processor.
// Persist that payment ID, the quote and a stable purchase key.
const approval = await mealme.authorizeCheckout({
  sessionUrl: yourSavedSession.url,
  quoteId: quote.quoteId,
  maxTotalCents: quote.quote.totalCents
});
// Persist approval.idempotencyKey with the payment and quote.
return approval;
// Confirmed order: capture. Definite failure: void.
// Unknown outcome: reconcile before retrying or moving money.
Your credits fund the order. The customer payment in your app is separate from developer funding. A checkout approval does not by itself place the food order; the customer confirms submission in the ordering UI.

Use only the pieces you need

The server package exposes discovery, menus, quotes, ordering, tracking, support, and webhook methods. The browser entry point provides mountOrdering and mountTracking. Clean up mounted views on navigation.