Back

    Buyamia Directory API

    v1.0

    Quick Start Guide

    Get up and running with the Directory API in under 5 minutes. This guide walks you through obtaining an API key, making your first request, and integrating with the procurement workflow.

    Step 1: Obtain an API Key

    Contact the Buyamia admin team or navigate to the Admin Dashboard → Integrations → Directory API panel to generate a new API key. Each key has scoped permissions — request the scopes you need.

    API keys are shown only once at creation time. Store them securely — they cannot be retrieved later.

    Step 2: Make Your First Request

    Test your API key by listing businesses:

    cURLbash
    curl -X GET "https://rjpxllsycikfabazvkdh.supabase.co/functions/v1/directory-api/v1/businesses?limit=5" \
      -H "X-API-Key: your-api-key-here" \
      -H "Content-Type: application/json"
    TypeScripttypescript
    const API_BASE = 'https://rjpxllsycikfabazvkdh.supabase.co/functions/v1/directory-api';
    const API_KEY = 'your-api-key-here';
    
    async function directoryApi(path: string, options?: RequestInit) {
      const res = await fetch(API_BASE + path, {
        ...options,
        headers: {
          'X-API-Key': API_KEY,
          'Content-Type': 'application/json',
          ...options?.headers,
        },
      });
      if (!res.ok) throw new Error(`API error: ${res.status}`);
      return res.json();
    }
    
    // List businesses
    const businesses = await directoryApi('/v1/businesses?limit=5');
    console.log(businesses.data);

    Step 3: Create an RFQ

    The primary integration use case — push an RFQ from your procurement system into the Directory:

    Create RFQtypescript
    const rfq = await directoryApi('/v1/rfq/inbound', {
      method: 'POST',
      body: JSON.stringify({
        external_rfq_id: 'PROC-2026-0042',
        title: 'Office Furniture Q3',
        buyer_name: 'John Doe',
        buyer_company: 'Acme Corp',
        buyer_email: 'john@acme.com',
        buyer_phone: '+628123456',
        delivery_location: 'Jakarta',
        delivery_date: '2026-04-15',
        priority: 'high',
        items: [
          {
            name: 'Executive Desk',
            quantity: 50,
            unit_of_measure: 'piece',
            description: 'Mahogany, 180x80cm',
            target_price: 5000000,
            target_currency: 'IDR',
            category_slug: 'office-furniture',
          },
        ],
      }),
    });
    
    console.log('Created RFQ:', rfq.data.rfq_number);

    Step 4: Poll for Quotes

    Once the Directory team collects supplier quotes, retrieve them:

    Get Quotestypescript
    const quotes = await directoryApi(`/v1/rfq/${rfq.data.id}/quotes`);
    
    for (const supplier of quotes.data) {
      console.log(`${supplier.business_name}: ${supplier.quoted_currency} ${supplier.quoted_price}`);
      for (const item of supplier.line_items) {
        console.log(`  - ${item.item_name}: ${item.unit_price} x ${item.quantity}`);
      }
    }

    Instead of polling, consider registering a webhook for the rfq.quote_submitted event to get notified in real-time when new quotes arrive.

    Next Steps

    • Read the Authentication guide for API key management best practices
    • Explore the Businesses and Products endpoints for full data access
    • Try Semantic Search for AI-powered supplier discovery
    • Set up Webhooks for real-time event notifications
    • Integrate the Agent Gateway for natural language procurement queries
    • Review Error Codes for proper error handling
    Last updated on February 23, 2026