認証
# 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'支払い方法
/v3/payment_viascurl -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は、最も低い手数料と最速の決済を提供します。
ブランドカタログ
/v2/brands?country_code={countryCode}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
サポートされている国コード
233GET https://cryptorefills.com/api/available-countriesAXÅland IslandsALAlbaniaDZAlgeriaASAmerican SamoaADAndorraAOAngolaAIAnguillaAQAntarcticaAGAntigua and BarbudaARArgentinaAMArmeniaAWArubaAUAustraliaATAustriaAZAzerbaijanBSBahamasBHBahrainBDBangladeshBBBarbadosBEBelgiumBZBelizeBJBeninBMBermudaBTBhutanBOBoliviaBQBonaire, Sint Eustatius and SabaBABosnia and HerzegovinaBWBotswanaBVBouvet IslandBRBrazilIOBritish Indian Ocean TerritoryBNBrunei DarussalamBGBulgariaBFBurkina FasoBIBurundiCVCabo VerdeKHCambodiaCMCameroonCACanadaKYCayman IslandsTDChadCLChileCNChinaCXChristmas IslandCCCocos (Keeling) IslandsCOColombiaKMComorosCGCongoCKCook IslandsCRCosta RicaCICôte d'IvoireHRCroatiaCWCuraçaoCYCyprusCZCzechiaDKDenmarkDJDjiboutiDMDominicaDODominican RepublicECEcuadorEGEgyptSVEl SalvadorGQEquatorial GuineaEREritreaEEEstoniaSZEswatiniETEthiopiaFKFalkland IslandsFOFaroe IslandsFJFijiFIFinlandFRFranceGFFrench GuianaPFFrench PolynesiaTFFrench Southern TerritoriesGAGabonGMGambiaGEGeorgiaDEGermanyGHGhanaGIGibraltarGRGreeceGLGreenlandGDGrenadaGPGuadeloupeGUGuamGTGuatemalaGGGuernseyGNGuineaGWGuinea-BissauGYGuyanaHTHaitiHMHeard Island and McDonald IslandsHNHondurasHKHong KongHUHungaryISIcelandINIndiaIDIndonesiaIEIrelandIMIsle of ManILIsraelITItalyJMJamaicaJPJapanJEJerseyJOJordanKZKazakhstanKEKenyaKIKiribatiXKKosovoKWKuwaitKGKyrgyzstanLALaosLVLatviaLBLebanonLSLesothoLRLiberiaLILiechtensteinLTLithuaniaLULuxembourgMOMacaoMGMadagascarMWMalawiMYMalaysiaMVMaldivesMTMaltaMHMarshall IslandsMQMartiniqueMRMauritaniaMUMauritiusYTMayotteMXMexicoFMMicronesiaMDMoldovaMCMonacoMNMongoliaMEMontenegroMSMontserratMAMoroccoMZMozambiqueNANamibiaNRNauruNPNepalNLNetherlandsNCNew CaledoniaNZNew ZealandNINicaraguaNENigerNGNigeriaNUNiueNFNorfolk IslandMKNorth MacedoniaMPNorthern Mariana IslandsNONorwayOMOmanPKPakistanPWPalauPSPalestinePAPanamaPGPapua New GuineaPYParaguayPEPeruPHPhilippinesPNPitcairnPLPolandPTPortugalPRPuerto RicoQAQatarRERéunionRORomaniaRWRwandaBLSaint BarthélemySHSaint HelenaKNSaint Kitts and NevisLCSaint LuciaMFSaint Martin (French part)PMSaint Pierre and MiquelonVCSaint Vincent and the GrenadinesWSSamoaSMSan MarinoSTSao Tome and PrincipeSASaudi ArabiaSNSenegalRSSerbiaSCSeychellesSLSierra LeoneSGSingaporeSXSint MaartenSKSlovakiaSISloveniaSBSolomon IslandsSOSomaliaZASouth AfricaGSSouth Georgia and the South Sandwich IslandsKRSouth KoreaESSpainLKSri LankaSRSurinameSJSvalbard and Jan MayenSESwedenCHSwitzerlandTWTaiwanTJTajikistanTZTanzaniaTHThailandTLTimor-LesteTGTogoTKTokelauTOTongaTTTrinidad and TobagoTNTunisiaTRTürkiyeTMTurkmenistanTCTurks and Caicos IslandsTVTuvaluUGUgandaUAUkraineAEUnited Arab EmiratesGBUnited KingdomUSUnited StatesUMUnited States Minor Outlying IslandsUYUruguayUZUzbekistanVUVanuatuVAVatican CityVNVietnamVGVirgin Islands (British)VIVirgin Islands (U.S.)WFWallis and FutunaEHWestern SaharaYEYemenZMZambia
ホームページフィード
/v2/homepage?country_code={countryCode}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'商品をブラウズ
/v5/products/country/{countryCode}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'暗号価格を取得
/v4/products/pricecurl -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'注文を検証
/v5/orders/validationscurl -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"
}'可能なエラー
レスポンスは問題の配列を返します。各エントリは { problem, moreDetails? } の形を持ち、複数の問題が一度に返されることがあります。トップレベルのHTTPエラー(サスペンション)は、代わりに { status, detail, 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.
注文を作成
/v5/orderscurl -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. これをユーザーと共有してください。
注文を追跡 (ストリームAPI)
/api/orders/{orderId}/subscribe- APIルートが受信します
/api/orders/{orderId}/subscribeそして上流に転送します/v5/orders/{orderId}/subscribe. - クライアントフックが開きます
EventSourceローカルAPIルートに、ペイロードを検証し、必要に応じてバックオフで再接続します。
サーバーサイドの必須コード
// 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',
},
});クライアントサイドの必須コード
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 イベントを、そして指数バックオフで再接続します。
注文を追跡 (ポーリング)
/v5/orders/{orderId}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を信頼できるようにサポートしていない場合です。
典型的な注文状態
WaitingForPayment -> WaitingForDelivery -> Done