From nothing to listings on a page in four steps. The examples use TypeScript, but any language that can send HTTPS requests works.
1. Get a key
Section titled “1. Get a key”Keys come from the marketplace’s team. In the console, API keys → New key, they create:
- a secret key (
sk_test_…orsk_live_…) for your server, and - optionally a publishable key (
pk_…) for native apps.
A key is shown once. Keep the secret key out of your code and out of browsers: put it in an environment variable such as MONGRL_SECRET_KEY.
| Environment | API | Keys |
|---|---|---|
| Test | https://api.staging.mongrl.com |
sk_test_…, pk_test_… |
| Live | https://api.mongrl.com |
sk_live_…, pk_live_… |
Check a key:
curl https://api.staging.mongrl.com/v1/marketplace \ -H "Authorization: Bearer $MONGRL_SECRET_KEY"The answer is your marketplace: its currencies, languages, what a listing needs and its shipping table.
2. Generate a typed client
Section titled “2. Generate a typed client”The OpenAPI spec describes every endpoint and field. Generate a client from it instead of writing requests by hand: the compiler then catches wrong paths and fields.
npm install -D @hey-api/openapi-tscurl -o openapi.json https://dev.mongrl.com/openapi.jsonimport { defineConfig } from '@hey-api/openapi-ts'
export default defineConfig({ input: './openapi.json', output: { path: 'src/api/generated' }, plugins: ['@hey-api/client-fetch'],})npx openapi-tsEach operation becomes a typed function named after its operation id: listListings, getListing, placeOrder… Commit the spec with your code and update it on purpose, so a new API version never changes your build by surprise.
3. Call it from your server
Section titled “3. Call it from your server”Make the client on the server, per request, with your secret key and (when someone is signed in) their session. Never import it into code that runs in the browser.
// src/server/mongrl.ts (server only)import { createClient } from '../api/generated/client'
export function mongrl(session?: string) { return createClient({ baseUrl: process.env.MONGRL_API_URL, // https://api.staging.mongrl.com auth: () => process.env.MONGRL_SECRET_KEY, // sent as Authorization: Bearer sk_… headers: session ? { 'X-User-Session': session } : undefined, })}import { listListings } from '../api/generated'import { mongrl } from './mongrl'
const { data, error } = await listListings({ client: mongrl(), query: { q: 'lounge chair', currency: 'EUR', limit: 24 },})if (error) throw new Error(error.detail)
for (const l of data.items ?? []) { console.log(l.title, l.display_price?.amount, l.images?.[0]?.urls?.medium)}display_price is the price in the currency you asked for. Amounts are minor units: 125000 with SEK is 1 250,00 kr.
4. Sign a user in
Section titled “4. Sign a user in”Requests for a user (their orders, their listings, buying) also send the user’s session token. Your server gets it when the user signs in and keeps it in an HttpOnly cookie:
import { listMyOrders, signIn } from '../api/generated'
const { data } = await signIn({ client: mongrl(), body: { email, password } })// Store data.session.token in an HttpOnly, Secure, SameSite=Lax cookie.
const orders = await listMyOrders({ client: mongrl(tokenFromCookie) })Authentication explains keys and sessions in full.
- Building with Claude, Cursor or another agent? Start with Build with an AI agent.
- Otherwise, read the guide for the part you’re building: Browsing, Accounts, Checkout or Selling.