Overview
Food Web is the system of record. Your site keeps its own pages, blog and submission queue; it reads organizations, programs and dates from the API on the server, and sends programs your coordinator approves back through the suggestions endpoint. A saved map names your member organizations, and a curator area decides what you may publish without Food Web review.
Server-side only
Setup
Food Web gives you an account with the partner and local-curator roles, a curator area, a saved-map token and a key with map:read and suggestions:write. Store the key and the token as server environment variables (FOODWEB_API_KEY, FOODWEB_SAVED_MAP).
// lib/foodweb.ts — server only
import 'server-only';
const BASE = process.env.FOODWEB_API_BASE ?? 'https://api.foodweb.network/v1';
export async function foodweb<T>(path: string, revalidate = 300): Promise<T> {
const res = await fetch(`${BASE}${path}`, {
headers: { Authorization: `Bearer ${process.env.FOODWEB_API_KEY}` },
next: { revalidate }
});
if (res.status === 404) throw new Error('not_found');
if (!res.ok) throw new Error(`Food Web ${res.status}`);
return res.json() as Promise<T>;
}Directory
One call returns every organization on your saved map, with updated_at on each. Read with your key to get phone and email; anonymous reads leave those blank. Labels for organization types and for every program filter are in GET /v1/map/taxonomy.
// app/directory/page.tsx — the member organizations on your saved map
import { foodweb } from '@/lib/foodweb';
export default async function Directory() {
// Every organization on your saved map, in one page, with phone and email (your key).
// Narrow by organization type with &types=food_bank,community_garden (taxonomy slugs).
const { items: orgs } = await foodweb<{ items: any[]; next_cursor: null }>(
`/map/entities?saved_map=${process.env.FOODWEB_SAVED_MAP}&include=programs`
);
return <ul>{orgs.map((o) => <li key={o.entity_id}>{o.name} · {o.phone}</li>)}</ul>;
}
// Organization pages: /organizations/<entity_id>/<name-in-kebab-case>. Look up by the id and
// redirect when the name part no longer matches. Re-sync a page when items[].updated_at changes.Programs
Filter by category, audience, access, cost, kind or frequency. Each program has a human schedule label, its next date, its organizer and a canonical page on Food Web. The programs guide lists every parameter.
const { items } = await foodweb<{ items: any[]; next_cursor: string | null }>(
`/programs?saved_map=${process.env.FOODWEB_SAVED_MAP}&categories=free-food,community-meal&limit=100`
);
// items[].schedule_label → "Every Wednesday · 1–3pm"
// items[].next_occurrence → { starts_at: "2026-11-18T13:00:00-04:00", … }
// items[].organizer → { id, name, logo_url, website, map_url }
const { program } = await foodweb<{ program: any }>(`/programs/${slug}`);Calendar
// A month grid: at most 93 days per call, in your timezone.
const { items } = await foodweb<{ items: any[] }>(
`/programs/occurrences?saved_map=${process.env.FOODWEB_SAVED_MAP}&from=2026-11-01&to=2026-12-01&tz=America/Halifax`
);
// Group by items[].starts_at.slice(0, 10). Strike through items[].status === 'cancelled'.
// items[].program.schedule_confirmed === false → "Dates are estimates until the organizer confirms."Map embed
Frame your saved map next to the directory and drive it from your page. ?types= takes taxonomy slugs (an organization type, a sector or a subtype, OR-ed) and narrows the map’s own pins; unknown slugs are ignored, and when none is valid the map says “No results”. ?entity= opens on one organization with its card showing, and ?chrome=minimal hides the search box, legend, list and About card. The “Powered By Food Web” mark stays.
The map accepts messages only from the page that frames it, and posts foodweb:entity-selected back with the organization’s id when a visitor picks a pin — never for a pin you focused. Food Web can also point the pin card’s “View profile” and the drawer’s program links at your own pages ({id} and {slug} URL patterns): send us both patterns.
<!-- The saved map beside your directory: only food banks, no Food Web chrome. -->
<iframe id="foodweb-map" title="Map of member organizations"
src="https://maps.foodweb.network/embed/YOUR_SAVED_MAP_TOKEN?types=food_bank&chrome=minimal"
width="100%" height="520" style="border:0" loading="lazy"></iframe>
<script>
const MAPS = 'https://maps.foodweb.network';
const frame = document.getElementById('foodweb-map');
// Your filters changed: re-filter the map in place (types: [] shows every pin).
function showTypes(types) {
frame.contentWindow.postMessage({ type: 'foodweb:set-filters', types }, MAPS);
}
// "View on map": centre an organization and open its card.
function showOnMap(entityId) {
frame.contentWindow.postMessage({ type: 'foodweb:focus-entity', id: entityId }, MAPS);
}
// A visitor picked a pin on the map.
window.addEventListener('message', (e) => {
if (e.origin !== MAPS || e.source !== frame.contentWindow) return;
if (e.data?.type === 'foodweb:entity-selected') highlightRow(e.data.id);
});
</script>JSON-LD & ICS
Embed structured_data as-is so search engines see the same Event markup Food Web publishes, and set your own canonical on your page. Offer subscribe links with webcal://.
{program.structured_data && (
<script
type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify(program.structured_data).replace(/</g, '\\u003c') }}
/>
)}
<a href={program.ics_url.replace('https://', 'webcal://')}>Subscribe in your calendar</a>Sending submissions
When your coordinator approves a submission in your queue, send it. Inside your curator area it publishes at once; outside it, or with auto_apply: false, a Food Web curator reviews it. Add dry_run: true to test a push without storing anything.
// app/api/approve/route.ts — called when your coordinator approves a submission
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
const submission = await req.json(); // from your own review queue
const res = await fetch('https://api.foodweb.network/v1/suggestions', {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.FOODWEB_API_KEY}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
type: 'create_program',
payload: {
kind: 'event',
name: submission.name,
organizer: { entity_id: submission.organizerEntityId }, // or { name, website, address }
categories: submission.categories,
schedules: [{ frequency: 'dates', dates: [submission.date], start_time: '17:00', end_time: '19:00' }],
source_ref: `sfn:${submission.id}` // makes retries safe
}
})
});
const body = await res.json();
// 201 → status 'applied', published now (inside your area): body.web_url
// 202 → status 'pending', a Food Web curator reviews it: body.reason
return NextResponse.json(body, { status: res.status });
}Visitors’ suggestions (a new organization, an edit, a program, an event, a volunteer role) go the same way with auto_apply: false, so your curator reviews every one, plus who sent it.
// Forwarding a visitor's form: always pending, and Food Web knows who it is from.
await fetch('https://api.foodweb.network/v1/suggestions', {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.FOODWEB_API_KEY}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
type: 'create_place_entity', // or edit_entity, create_program (kind: program | event | volunteer)
auto_apply: false,
submitter: { name: form.name, email: form.email, role: 'resident' },
via: 'spryfieldfoodnetwork.ca new-organization form',
source_ref: `sfn:${form.id}`, // a retry returns the same suggestion, on every kind
note: form.extra, // hours, logo, socials: anything without a field
payload: {
// No geom needed: Food Web places the street address itself.
place: { address1: form.street, city: 'Halifax', province: 'NS', country: 'CA' },
entity: { name: form.orgName, primary_type: 'food_bank', email: form.orgEmail }
}
})
});
// Food Web never emails the visitor; your curator sees their name, email, role, via and note.
// Their name and email are deleted 90 days after the suggestion is decided.Errors & caching
401 unauthorizedThe key is unknown or revoked. Check FOODWEB_API_KEY.403 insufficient_scopeThe key lacks map:read or suggestions:write. Ask Food Web to re-issue it.400 validation_errorThe payload or a parameter is wrong; the message names the field. Test pushes with dry_run: true.202 organizer_unresolvedA pushed program names an organizer that is not on the map yet. It is stored and waits for a curator.429 rate_limit_exceeded120 requests a minute per key. Wait Retry-After seconds; cache reads for five minutes.Cache reads in your own server for about five minutes (Next.js revalidate: 300); a new program shows within that window.
Attribution
Show “Program data from Food Web” with a link to https://foodweb.network/events on pages that list programs.