Back

    Buyamia Directory API

    v1.1.0

    Quick Start

    1. Get an API key

    Request a key from the Buyamia team, telling them which scopes your integration needs (see Authentication & Scopes). Keys are shown once at creation and stored only as a hash, so save it somewhere safe — it cannot be recovered later, only replaced.

    2. Call the API

    cURLbash
    curl -s "https://rjpxllsycikfabazvkdh.supabase.co/functions/v1/directory-api/v1/businesses?limit=5" \
      -H "X-API-Key: your-api-key-here"
    TypeScript clienttypescript
    const API_BASE = 'https://rjpxllsycikfabazvkdh.supabase.co/functions/v1/directory-api';
    const API_KEY = process.env.DIRECTORY_API_KEY!;
    
    async function directoryApi<T = unknown>(path: string, init?: RequestInit): Promise<T> {
      const res = await fetch(API_BASE + path, {
        ...init,
        headers: {
          'X-API-Key': API_KEY,
          'Content-Type': 'application/json',
          ...init?.headers,
        },
      });
      const body = await res.json().catch(() => ({}));
      if (!res.ok) throw new Error(body?.error ?? `HTTP ${res.status}`);
      return body as T;
    }
    
    type ListResponse<T> = { data: T[]; total: number; limit: number; offset: number };
    
    const page = await directoryApi<ListResponse<{ id: string; name: string }>>(
      '/v1/businesses?limit=5'
    );
    console.log(page.data.length, 'of', page.total);

    3. Page through a list

    Full pulltypescript
    async function pullAll<T>(path: string): Promise<T[]> {
      const out: T[] = [];
      let offset = 0;
      const limit = 100; // maximum allowed
      for (;;) {
        const sep = path.includes('?') ? '&' : '?';
        const page = await directoryApi<ListResponse<T>>(
          `${path}${sep}limit=${limit}&offset=${offset}`
        );
        out.push(...page.data);
        offset += page.data.length;
        // No has_more field — derive it:
        if (page.data.length === 0 || offset >= page.total) break;
      }
      return out;
    }

    4. Push an RFQ

    POST /v1/rfq/inboundtypescript
    const created = await directoryApi<{ data: { id: string; rfq_number: string }; items_created: number }>(
      '/v1/rfq/inbound',
      {
        method: 'POST',
        body: JSON.stringify({
          external_rfq_id: 'PROC-2026-0042',
          title: 'Office furniture — Q3',
          buyer_name: 'Andi Pratama',
          buyer_company: 'Nusantara Works',
          buyer_email: 'andi@nusantara.example',
          delivery_location: 'Denpasar, Bali',
          priority: 'medium',
          items: [
            {
              name: 'Ergonomic office chair',
              quantity: 40,
              unit_of_measure: 'piece',
              target_price: 1500000,
              target_currency: 'IDR', // always pair amount + currency
              category_slug: 'furniture',
            },
          ],
        }),
      }
    );

    5. Read the quotes

    const quotes = await directoryApi(`/v1/rfq/${created.data.id}/quotes`);
    // { rfq_id, external_rfq_id, rfq_number, title, suppliers: [...] }

    Prefer a rfq.quote_submitted webhook over polling — see the Webhooks page.

    Current as of API 1.1.0 — released 7 September 2026