API Scope

Developer API reference

Production-focused cURL and Node examples for stablecoin checkout, order creation, and delivery tracking.

Covered in this guide

  • Gift cards
  • Mobile top-ups
  • eSIM purchases

Not covered here

  • Flights
  • Stays

Need the broader integration context before diving into endpoints?

Open integration overview
1

Authentication

Every API request requires these headers. After creating a Cryptorefills account, you can find your Partner ID on your account information page.
bash
# Required headers for every API request
-H 'X-Cr-Application: YOUR_PARTNER_ID'
-H 'X-Cr-Version: YOUR_APP_VERSION'
-H 'X-Country-ISO-Code: US'
-H 'Content-Type: application/json'
2

Payment methods

GET/v3/payment_vias
Fetch all supported coins and blockchain networks. Returns USDC, USDT on Solana, Ethereum, Base, Arbitrum, Polygon, and more.
bash
curl -X GET 'https://api.cryptorefills.com/v3/payment_vias' \
  -H 'Content-Type: application/json' \
  -H 'X-Cr-Application: YOUR_PARTNER_ID' \
  -H 'X-Cr-Version: YOUR_APP_VERSION'

Recommended: USDC on Solana offers the lowest fees and fastest settlement.

3

Brand catalog

GET/v2/brands?country_code={countryCode}
(Optional) List all available brands for a country. Great for building brand directory or search features.
bash
curl -X GET 'https://api.cryptorefills.com/v2/brands?country_code=US' \
  -H 'Content-Type: application/json' \
  -H 'X-Cr-Application: YOUR_PARTNER_ID' \
  -H 'X-Cr-Version: YOUR_APP_VERSION'
4

Homepage feed

GET/v2/homepage?country_code={countryCode}
(Optional) Fetch a curated homepage feed for a country. Useful for displaying trending or featured gift cards.
bash
curl -X GET 'https://api.cryptorefills.com/v2/homepage?country_code=US' \
  -H 'Content-Type: application/json' \
  -H 'X-Cr-Application: YOUR_PARTNER_ID' \
  -H 'X-Cr-Version: YOUR_APP_VERSION'
5

Browse products

GET/v5/products/country/{countryCode}
List all available gift cards for a brand and country. Supports fixed denominations and custom amounts (ranges).
bash
curl -X GET 'https://api.cryptorefills.com/v5/products/country/US?family_name=airbnb&coin=USDC&lang=en' \
  -H 'Content-Type: application/json' \
  -H 'X-Cr-Application: YOUR_PARTNER_ID' \
  -H 'X-Cr-Version: YOUR_APP_VERSION'
6

Get crypto price

GET/v4/products/price
Convert any gift card value to stablecoin amount. Use this to show users the exact crypto amount before they confirm purchase.
bash
curl -X GET 'https://api.cryptorefills.com/v4/products/price?brand_name=Airbnb&country_code=US&face_value=100&coin=USDC' \
  -H 'Content-Type: application/json' \
  -H 'X-Cr-Application: YOUR_PARTNER_ID' \
  -H 'X-Cr-Version: YOUR_APP_VERSION'
7

Validate order

POST/v5/orders/validations
(Recommended) Check for issues before creating the order. Use the real end-user email in email/beneficiary_account, since Cryptorefills delivers to that recipient.
bash
curl -X POST 'https://api.cryptorefills.com/v5/orders/validations' \
  -H 'Content-Type: application/json' \
  -H 'X-Cr-Application: YOUR_PARTNER_ID' \
  -H 'X-Cr-Version: YOUR_APP_VERSION' \
  -d '{
    "email": "END_USER_EMAIL",
    "payment": {
      "type": "via",
      "payment_via": "USER_WALLET",
      "coin": "USDC"
    },
    "deliveries": [
      {
        "beneficiary_account": "END_USER_EMAIL",
        "brand_name": "Airbnb",
        "country_code": "US",
        "denomination": "100 USD",
        "localized_denomination": "$100"
      }
    ],
    "lang": "en"
  }'
8

Create order

POST/v5/orders
Create an order and receive a wallet address for payment. Use the real end-user email because Cryptorefills must deliver the product to that recipient. Payment window is 30 minutes.
bash
curl -X POST 'https://api.cryptorefills.com/v5/orders' \
  -H 'Content-Type: application/json' \
  -H 'X-Cr-Application: YOUR_PARTNER_ID' \
  -H 'X-Cr-Version: YOUR_APP_VERSION' \
  -d '{
    "deliveries": [
      {
        "kind": "giftcard",
        "quantity": 1,
        "deliverable": {
          "brand_name": "Airbnb",
          "country_code": "US",
          "denomination": "100"
        }
      }
    ],
    "payment": {
      "type": "via",
      "coin": "USDC",
      "network": "Solana",
      "payment_via": "USER_WALLET"
    },
    "user": {
      "email": "END_USER_EMAIL",
      "has_accepted_newsletter": true
    },
    "lang": "en",
    "acquisition": {
      "utm_source": "your_platform"
    }
  }'

Response includes wallet_address and coin_amount. Share these with your user.

9a

Track order (stream API)

GET/api/orders/{orderId}/subscribe
Implement this in two required pieces: a server-side SSE proxy route and a client-side stream hook.
  • API route receives/api/orders/{orderId}/subscribe and forwards to upstream/v5/orders/{orderId}/subscribe.
  • Client hook opensEventSource to the local API route, validates payloads, and reconnects with backoff when needed.

Server-Side Essential Code

javascript
// app/api/orders/[orderId]/subscribe/route.ts
let upstream: Response;

try {
  upstream = await fetch(
    `https://api.cryptorefills.com/v5/orders/${params?.orderId}/subscribe`,
    {
      method: 'GET',
      headers: {
        ...(await genHeader.server(session)),
        'User-Agent': user_agent,
        Accept: 'text/event-stream',
        Connection: 'keep-alive',
      },
    },
  );
} catch (err) {
  return NextResponse.json(
    { error: 'Failed to connect to upstream stream' },
    { status: 502 },
  );
}

if (!upstream.ok || !upstream.body) {
  return NextResponse.json(
    { error: 'Upstream returned an error' },
    { status: upstream.status || 502 },
  );
}

// stream = ReadableStream that proxies upstream SSE events
return new Response(stream, {
  status: 200,
  headers: {
    'Content-Type': 'text/event-stream',
    'Cache-Control': 'no-cache, no-transform',
    Connection: 'keep-alive',
    'X-Accel-Buffering': 'no',
  },
});

Client-Side Essential Code

javascript

const { data: lastEvent, error } = useSWRSubscription<TOrderSchema>(
  referenceOrderId ? `orders-info-stream-${referenceOrderId}` : null,
  ((key, { next }) => {
    let es: EventSource | null = null;
    let stopped = false;
    let shouldReconnect = true;
    let retryTimeout: number | null = null;
    let retryDelay = 1000;

    const cleanup = () => {
      if (es) {
        es.close();
        es = null;
      }
      if (retryTimeout !== null) {
        window.clearTimeout(retryTimeout);
        retryTimeout = null;
      }
    };

    const stopForever = () => {
      shouldReconnect = false;
      stopped = true;
      cleanup();
    };

    const connect = () => {
      if (stopped) return;
      cleanup();
      es = new EventSource(`/api/orders/${referenceOrderId}/subscribe`);

      es.addEventListener('message', (ev) => {
        try {
          const raw = JSON.parse(ev.data);
          const parsed = orderSchema.safeParse(raw);
          if (!parsed.success) return;
          retryDelay = 1000;
          next(null, parsed.data as TOrderSchema);
        } catch (err) {
          next(err as Error);
        }
      });

      es.addEventListener('stop', () => {
        stopForever();
      });

      es.onerror = () => {
        if (stopped || !shouldReconnect) return;
        cleanup();
        retryTimeout = window.setTimeout(() => {
          retryDelay = Math.min(retryDelay * 2, 30000);
          connect();
        }, retryDelay);
      };
    };

    connect();

    return () => {
      stopped = true;
      cleanup();
    };
  }) as SubscriptionCallback<TOrderSchema>,
);

Route in this repo

app/api/orders/[orderId]/subscribe/route.ts

Server side (API route)

Uses session-based server headers viagenHeader.server(session), then calls upstream${process.env.API_URL}/v5/orders/${params?.orderId}/subscribe. On connection failure it returns502.

Client side (hook)

OpensEventSource to/api/orders/${referenceOrderId}/subscribe, validates each payload withorderSchema.safeParse, handlesstop events, and reconnects with exponential backoff.

9b

Track order (polling)

GET/v5/orders/{orderId}
Fallback approach: poll every 5-10 seconds until payment is received. Gift card code appears when status is 'Done'.
bash
curl -X GET 'https://api.cryptorefills.com/v5/orders/ord_abc123xyz' \
  -H 'Content-Type: application/json' \
  -H 'X-Cr-Application: YOUR_PARTNER_ID' \
  -H 'X-Cr-Version: YOUR_APP_VERSION'

Use polling when

You cannot keep an SSE connection open, or your client environment does not support EventSource reliably.

Typical order states

WaitingForPayment -> WaitingForDelivery -> Done