API 범위

개발자 API 참조

생산 중심의 cURL 및 Node 예제, 스테이블코인 체크아웃, 주문 생성 및 배송 추적을 위한.

이 가이드에서 다루는 내용

  • 기프트 카드
  • 모바일 충전
  • eSIM 구매

여기서 다루지 않음

  • 항공편
  • 숙박

엔드포인트에 들어가기 전에 더 넓은 통합 맥락이 필요하신가요?

통합 개요 열기
1

인증

모든 API 요청에는 이러한 헤더가 필요합니다. Cryptorefills 계정을 생성한 후, 계정 정보 페이지에서 파트너 ID를 찾을 수 있습니다.
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

결제 방법

GET/v3/payment_vias
모든 지원되는 코인 및 블록체인 네트워크를 가져옵니다. Solana, Ethereum, Base, Arbitrum, Polygon 등에서 USDC, USDT를 반환합니다.
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'

추천: Solana의 USDC는 가장 낮은 수수료와 가장 빠른 정산을 제공합니다.

3

브랜드 카탈로그

GET/v2/brands?country_code={countryCode}
(선택 사항) 국가별로 사용 가능한 모든 브랜드를 나열합니다. 브랜드 디렉토리 또는 검색 기능을 구축하는 데 유용합니다.
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'

로고 URL 변형

각 브랜드는 logo_url(기본값)과 logo_base_url을 반환합니다. 최적화된 크기와 형식을 가져오기 위해 logo_base_url에 접미사를 추가하세요.

.webp추천

  • {logo_base_url}.webp
  • {logo_base_url}_500x318.webp
  • {logo_base_url}_300x190.webp

.jpg

  • {logo_base_url}.jpg
  • {logo_base_url}_500x318.jpg
  • {logo_base_url}_300x190.jpg

예: https://cdn.cryptorefills.com/logos_v2/esim_500x318.webp

지원되는 국가 코드

233
  • AXÅland Islands
  • ALAlbania
  • DZAlgeria
  • ASAmerican Samoa
  • ADAndorra
  • AOAngola
  • AIAnguilla
  • AQAntarctica
  • AGAntigua and Barbuda
  • ARArgentina
  • AMArmenia
  • AWAruba
  • AUAustralia
  • ATAustria
  • AZAzerbaijan
  • BSBahamas
  • BHBahrain
  • BDBangladesh
  • BBBarbados
  • BEBelgium
  • BZBelize
  • BJBenin
  • BMBermuda
  • BTBhutan
  • BOBolivia
  • BQBonaire, Sint Eustatius and Saba
  • BABosnia and Herzegovina
  • BWBotswana
  • BVBouvet Island
  • BRBrazil
  • IOBritish Indian Ocean Territory
  • BNBrunei Darussalam
  • BGBulgaria
  • BFBurkina Faso
  • BIBurundi
  • CVCabo Verde
  • KHCambodia
  • CMCameroon
  • CACanada
  • KYCayman Islands
  • TDChad
  • CLChile
  • CNChina
  • CXChristmas Island
  • CCCocos (Keeling) Islands
  • COColombia
  • KMComoros
  • CGCongo
  • CKCook Islands
  • CRCosta Rica
  • CICôte d'Ivoire
  • HRCroatia
  • CWCuraçao
  • CYCyprus
  • CZCzechia
  • DKDenmark
  • DJDjibouti
  • DMDominica
  • DODominican Republic
  • ECEcuador
  • EGEgypt
  • SVEl Salvador
  • GQEquatorial Guinea
  • EREritrea
  • EEEstonia
  • SZEswatini
  • ETEthiopia
  • FKFalkland Islands
  • FOFaroe Islands
  • FJFiji
  • FIFinland
  • FRFrance
  • GFFrench Guiana
  • PFFrench Polynesia
  • TFFrench Southern Territories
  • GAGabon
  • GMGambia
  • GEGeorgia
  • DEGermany
  • GHGhana
  • GIGibraltar
  • GRGreece
  • GLGreenland
  • GDGrenada
  • GPGuadeloupe
  • GUGuam
  • GTGuatemala
  • GGGuernsey
  • GNGuinea
  • GWGuinea-Bissau
  • GYGuyana
  • HTHaiti
  • HMHeard Island and McDonald Islands
  • HNHonduras
  • HKHong Kong
  • HUHungary
  • ISIceland
  • INIndia
  • IDIndonesia
  • IEIreland
  • IMIsle of Man
  • ILIsrael
  • ITItaly
  • JMJamaica
  • JPJapan
  • JEJersey
  • JOJordan
  • KZKazakhstan
  • KEKenya
  • KIKiribati
  • XKKosovo
  • KWKuwait
  • KGKyrgyzstan
  • LALaos
  • LVLatvia
  • LBLebanon
  • LSLesotho
  • LRLiberia
  • LILiechtenstein
  • LTLithuania
  • LULuxembourg
  • MOMacao
  • MGMadagascar
  • MWMalawi
  • MYMalaysia
  • MVMaldives
  • MTMalta
  • MHMarshall Islands
  • MQMartinique
  • MRMauritania
  • MUMauritius
  • YTMayotte
  • MXMexico
  • FMMicronesia
  • MDMoldova
  • MCMonaco
  • MNMongolia
  • MEMontenegro
  • MSMontserrat
  • MAMorocco
  • MZMozambique
  • NANamibia
  • NRNauru
  • NPNepal
  • NLNetherlands
  • NCNew Caledonia
  • NZNew Zealand
  • NINicaragua
  • NENiger
  • NGNigeria
  • NUNiue
  • NFNorfolk Island
  • MKNorth Macedonia
  • MPNorthern Mariana Islands
  • NONorway
  • OMOman
  • PKPakistan
  • PWPalau
  • PSPalestine
  • PAPanama
  • PGPapua New Guinea
  • PYParaguay
  • PEPeru
  • PHPhilippines
  • PNPitcairn
  • PLPoland
  • PTPortugal
  • PRPuerto Rico
  • QAQatar
  • RERéunion
  • RORomania
  • RWRwanda
  • BLSaint Barthélemy
  • SHSaint Helena
  • KNSaint Kitts and Nevis
  • LCSaint Lucia
  • MFSaint Martin (French part)
  • PMSaint Pierre and Miquelon
  • VCSaint Vincent and the Grenadines
  • WSSamoa
  • SMSan Marino
  • STSao Tome and Principe
  • SASaudi Arabia
  • SNSenegal
  • RSSerbia
  • SCSeychelles
  • SLSierra Leone
  • SGSingapore
  • SXSint Maarten
  • SKSlovakia
  • SISlovenia
  • SBSolomon Islands
  • SOSomalia
  • ZASouth Africa
  • GSSouth Georgia and the South Sandwich Islands
  • KRSouth Korea
  • ESSpain
  • LKSri Lanka
  • SRSuriname
  • SJSvalbard and Jan Mayen
  • SESweden
  • CHSwitzerland
  • TWTaiwan
  • TJTajikistan
  • TZTanzania
  • THThailand
  • TLTimor-Leste
  • TGTogo
  • TKTokelau
  • TOTonga
  • TTTrinidad and Tobago
  • TNTunisia
  • TRTürkiye
  • TMTurkmenistan
  • TCTurks and Caicos Islands
  • TVTuvalu
  • UGUganda
  • UAUkraine
  • AEUnited Arab Emirates
  • GBUnited Kingdom
  • USUnited States
  • UMUnited States Minor Outlying Islands
  • UYUruguay
  • UZUzbekistan
  • VUVanuatu
  • VAVatican City
  • VNVietnam
  • VGVirgin Islands (British)
  • VIVirgin Islands (U.S.)
  • WFWallis and Futuna
  • EHWestern Sahara
  • YEYemen
  • ZMZambia
4

홈페이지 피드

GET/v2/homepage?country_code={countryCode}
(선택 사항) 국가별로 큐레이션된 홈페이지 피드를 가져옵니다. 트렌드 또는 추천 기프트 카드 표시하는 데 유용합니다.
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

제품 탐색

GET/v5/products/country/{countryCode}
브랜드 및 국가별로 사용 가능한 모든 기프트 카드를 나열합니다. 고정 금액 및 사용자 정의 금액(범위)을 지원합니다.
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/v4/products/price
모든 기프트 카드 가치를 스테이블코인 금액으로 변환합니다. 사용자가 구매를 확인하기 전에 정확한 암호화폐 금액을 표시하는 데 사용합니다.
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

주문 확인

POST/v5/orders/validations
(권장) 주문을 생성하기 전에 문제를 확인합니다. Cryptorefills가 해당 수신자에게 배달하므로 이메일/수혜자 계정에 실제 최종 사용자 이메일을 사용합니다.
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"
  }'

가능한 오류

응답은 문제 배열을 반환합니다. 각 항목은 { 문제, moreDetails? } 형태를 가지며, 여러 문제를 한 번에 반환할 수 있습니다. 최상위 HTTP 오류(정지)는 대신 { 상태, 세부정보, moreDetails? } 형태로 반환됩니다.

Order amount & limits

  • AMOUNT_LESS_THEN_MINIMUM_ALLOWEDOrder total is below the minimum coin amount allowed.
  • MAXIMUM_AMOUNT_PER_ORDER_EXCEEDEDOrder total exceeds the per-order maximum.
  • DAILY_SPENDING_LIMIT_EXCEEDEDUser has hit the daily spending limit for their tier.
  • MONTHLY_SPENDING_LIMIT_EXCEEDEDUser has hit the monthly spending limit for their tier.
  • PRODUCT_COUNT_EXCEEDEDCart contains more products than the per-order maximum.
  • MULTIPLE_LIMITED_PRODUCT_SAME_ORDEROrder contains more than one rate-limited product.

Product availability

  • NOT_AVAILABLE_PRODUCTProduct is no longer in the catalogue.
  • OUT_OF_STOCKProduct is currently out of stock.
  • NOT_ACTIVEProduct is inactive or paused.
  • INVALID_BENEFICIARY_ACCOUNTBeneficiary account is invalid — e.g. phone number for a mobile topup or email for a gift card.

Payment method & network

  • NOT_ALLOWED_PAYMENT_VIASelected payment_via is not allowed for this order. moreDetails lists allowed kinds.
  • UNSUPPORTED_PROTOCOL_COIN_COMBINATIONChosen protocol + coin pair is not supported. moreDetails lists supported combinations.

Authentication

  • LOGIN_REQUIREDOne or more products require a signed-in user.
  • COUPON_REQUIRES_LOGINThe coupon can only be redeemed by a signed-in user.

Coupon codes

  • COUPON_NOT_FOUNDCoupon code does not exist.
  • COUPON_NOT_ACTIVECoupon is not yet active.
  • COUPON_ALREADY_SPENTCoupon has already been redeemed by this user.
  • COUPON_MAX_USAGE_REACHEDCoupon has reached its overall usage cap.
  • COUPON_EXPIREDCoupon is past its validity date.
  • COUPON_BELOW_MIN_AMOUNTOrder total is below the coupon’s minimum amount.
  • COUPON_NOT_VALID_FOR_USERCoupon is not valid for this user.
  • COUPON_NOT_VALID_FOR_CATEGORYCoupon does not apply to the selected product categories.
  • COUPON_NOT_VALID_FOR_KINDCoupon does not apply to the selected product kind.
  • COUPON_NOT_VALID_FOR_BRANDCoupon does not apply to the selected brands.
  • COUPON_NOT_VALID_FOR_COUNTRYCoupon is not valid in the order country.
  • COUPON_NOT_VALID_FOR_STORECoupon is not valid for the requested store or region.

HTTP-level errors (top-level detail field)

  • SUSPENDED_COINThe selected coin is temporarily suspended.
  • SUSPENDED_NETWORKThe selected network is temporarily suspended.
8

주문 생성

POST/v5/orders
주문을 생성하고 결제를 위한 지갑 주소를 받습니다. Cryptorefills가 해당 수신자에게 제품을 배달해야 하므로 실제 최종 사용자 이메일을 사용합니다. 결제 시간은 30분입니다.
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",
          "beneficiary_account": "END_USER_EMAIL"
        }
      }
    ],
    "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"
    }
  }'

수혜자 계좌

각 배송에는 다음이 포함되어야 합니다. beneficiary_account 배송물에 Cryptorefills가 제품을 전달하는 곳입니다. 필요한 형식은 제품 종류에 따라 다릅니다.

  • 기프트 카드 및 eSIM: 최종 사용자의 이메일 주소를 사용하세요 — 예를 들어 user@example.com.
  • 모바일 충전: 수신자의 전화번호를 E.164 형식으로 사용하세요. 여기에는 앞에 +와 국가 코드가 포함되어야 합니다 — 예를 들어 +14155551234.

응답 포함 wallet_address and coin_amount. 이것들을 사용자와 공유하세요.

9a

주문 추적 (스트림 API)

GET/api/orders/{orderId}/subscribe
서버 측 SSE 프록시 경로와 클라이언트 측 스트림 훅의 두 가지 필수 구성 요소로 구현합니다.
  • API 경로가 수신합니다/api/orders/{orderId}/subscribe 그리고 업스트림으로 전달합니다/v5/orders/{orderId}/subscribe.
  • 클라이언트 훅이 엽니다EventSource 로컬 API 경로에, 페이로드를 검증하고 필요할 때 백오프와 함께 재연결합니다.

서버 측 필수 코드

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',
  },
});

클라이언트 측 필수 코드

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>,
);

이 리포지토리의 경로

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

서버 측 (API 경로)

세션 기반 서버 헤더를 사용하여genHeader.server(session), 그런 다음 업스트림을 호출합니다${process.env.API_URL}/v5/orders/${params?.orderId}/subscribe. 연결 실패 시 반환합니다502.

클라이언트 측 (훅)

열립니다EventSource /api/orders/${referenceOrderId}/subscribe, 각 페이로드를 검증합니다orderSchema.safeParse, 처리합니다stop 이벤트를 처리하고 지수 백오프와 함께 재연결합니다.

9b

주문 추적 (폴링)

GET/v5/orders/{orderId}
대체 접근 방식: 결제가 수신될 때까지 5-10초마다 폴링합니다. 상태가 '완료'일 때 기프트 카드 코드가 나타납니다.
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'

다음과 같은 경우 폴링을 사용합니다

SSE 연결을 열어둘 수 없거나 클라이언트 환경이 EventSource를 안정적으로 지원하지 않습니다.

일반적인 주문 상태

결제 대기 -> 배송 대기 -> 완료