Build a price screener in 50 lines: the batch endpoint walkthrough

BlazePhoenix Engineering · updated 2026-07-18 · 5 min · written from the deployed bytecode

Abstract in 15 languages · resumo · resumen · 摘要 · 要旨 · ملخص

EnglishPOST /api/quote/batch prices up to 10 pairs in one round-trip, order preserved, errors inline per item — one dead pair never breaks the loop. Resolve symbols once, batch with addresses, refresh at block speed.

PortuguêsPOST /api/quote/batch cota até 10 pares numa só ida, ordem preservada, erros inline por item — um par morto nunca quebra o loop. Resolve símbolos uma vez, agrupa com endereços, atualiza à velocidade do bloco.

EspañolPOST /api/quote/batch cotiza hasta 10 pares en un solo viaje, orden preservado, errores inline por ítem — un par muerto nunca rompe el bucle. Resuelve símbolos una vez, agrupa con direcciones, refresca a velocidad de bloque.

FrançaisPOST /api/quote/batch cote jusqu'à 10 paires en un aller-retour, ordre préservé, erreurs en ligne par élément — une paire morte ne casse jamais la boucle. Résolvez les symboles une fois, groupez par adresses, rafraîchissez au rythme des blocs.

DeutschPOST /api/quote/batch quotiert bis zu 10 Paare in einem Round-Trip, Reihenfolge erhalten, Fehler inline pro Eintrag — ein totes Paar bricht nie die Schleife. Symbole einmal auflösen, mit Adressen batchen, im Blocktakt aktualisieren.

РусскийPOST /api/quote/batch котирует до 10 пар за один запрос: порядок сохранён, ошибки inline по каждому элементу — мёртвая пара никогда не ломает цикл. Разрешите символы один раз, батчите адресами, обновляйте со скоростью блока.

TürkçePOST /api/quote/batch tek gidiş-dönüşte 10 çifte kadar fiyatlar; sıra korunur, hatalar öğe başına satır içidir — ölü bir çift döngüyü asla kırmaz. Sembolleri bir kez çözün, adreslerle toplayın, blok hızında yenileyin.

العربيةيسعّر POST /api/quote/batch حتى 10 أزواج في رحلة واحدة، بترتيب محفوظ وأخطاء مضمّنة لكل عنصر — الزوج الميت لا يكسر الحلقة أبداً. حُلَّ الرموز مرة، وادمج بالعناوين، وحدّث بسرعة الكتلة.

हिन्दीPOST /api/quote/batch एक ही राउंड-ट्रिप में 10 जोड़े तक कोट करता है, क्रम सुरक्षित, हर आइटम की त्रुटि इनलाइन — एक मृत जोड़ा कभी लूप नहीं तोड़ता। सिंबल एक बार रिज़ॉल्व करें, पतों से बैच करें, ब्लॉक गति पर रीफ्रेश करें।

日本語POST /api/quote/batchは1往復で最大10ペアを見積もり。順序は保持され、エラーは項目ごとにインライン。死んだペアがループを壊すことはありません。シンボルは一度だけ解決し、アドレスでバッチし、ブロック速度で更新を。

中文POST /api/quote/batch 一次往返为最多 10 个交易对报价,顺序保持、错误按项内联——一个死交易对永远不会中断循环。符号解析一次,用地址批量,按区块速度刷新。

한국어POST /api/quote/batch는 한 번의 왕복으로 최대 10개 페어를 견적합니다. 순서 유지, 항목별 인라인 오류 — 죽은 페어 하나가 루프를 깨지 않습니다. 심볼은 한 번만 해석하고, 주소로 배치하고, 블록 속도로 갱신하세요.

Bahasa IndonesiaPOST /api/quote/batch menguotasi hingga 10 pasangan dalam satu perjalanan, urutan terjaga, kesalahan inline per item — satu pasangan mati tak pernah memutus loop. Selesaikan simbol sekali, batch dengan alamat, segarkan secepat blok.

বাংলাPOST /api/quote/batch এক রাউন্ড-ট্রিপে ১০টি পর্যন্ত জোড়া কোট করে, ক্রম বজায়, প্রতি আইটেমে ইনলাইন ত্রুটি — একটি মৃত জোড়া কখনো লুপ ভাঙে না। সিম্বল একবার সমাধান করুন, ঠিকানা দিয়ে ব্যাচ করুন, ব্লকের গতিতে রিফ্রেশ করুন।

FilipinoAng POST /api/quote/batch ay nagpepresyo ng hanggang 10 pares sa isang round-trip, panatili ang pagkakasunod, errors inline bawat item — hindi kailanman sinisira ng patay na pares ang loop. Isang beses i-resolve ang simbolo, mag-batch gamit ang address, mag-refresh sa bilis ng block.

A screener's job is breadth: many pairs, refreshed often, cheaply. Serial GETs waste round-trips; the batch endpoint prices up to 10 requests in one POST, preserves order, and reports per-item errors INLINE — one dead pair returns its error object in place while the other nine return quotes. Your loop never breaks on a partial failure.

Batch deliberately accepts only addresses and built-in symbols (ETH/WETH/USDC/BZPX): bulk paths should not inherit the single-quote endpoint's symbol-resolution heuristics. Resolve exotic symbols once via GET (the response echoes the chosen address in `resolved`), cache the address, batch with addresses forever after.

const pairs = [
  { chain: 'base', in: 'WETH', out: 'USDC', amountIn: '1000000000000000000' },
  { chain: 'base', in: 'WETH', out: '0x532f27101965dd16442e59d40670faf5ebb142e4' }, // BRETT
  { chain: 'arbitrum', in: 'WETH', out: 'USDC', amountIn: '1000000000000000000' },
];
const r = await fetch('https://blazephoenix.xyz/api/quote/batch', {
  method: 'POST', headers: { 'content-type': 'application/json' },
  body: JSON.stringify({ requests: pairs }),
});
const { results } = await r.json();   // order preserved; errors inline per item
for (const q of results) console.log(q.ok ? q.amountOut : q.code);

The refresh loop that respects the physics

Chain state changes once per block — polling faster than block time buys nothing. On Base (2s blocks) a 2-second loop is the honest maximum; the edge cache means even an aggressive loop mostly hits shared work (watch meta.cache turn to "hit" and "coalesced"). For alerting, compare amountOut across cycles; for arbitrage scanning, remember the number you act on should be re-quoted with exact=1 and a recipient — the screener number is a preview by design.

Do not trust this page — reproduce it

Every claim above is checkable against the chain. Start here:

run the snippet above in any Node ≥18 terminal — three chains priced in one round-trip, no key

Contracts are verified on every chain we deploy to — addresses in the protocol manifest. Deeper formal treatment: the whitepaper (PDF).

Share this article · join the discussion

Related engineering