Skip to main content
ParaLens uses permissive CORS so browsers can call the API directly, but production apps should use a backend or API route as a proxy. This keeps the Railway URL out of client code and gives you control over caching, rate limiting, and future API key forwarding.

Direct vs. Proxied Calls

Architecture

Setting Up a Proxy

The following example uses a Node.js Express server as the proxy. If you are using Next.js, see the Next.js Proxy guide for a more complete integration.
1

Install Express

Add Express (and optionally node-cache for caching) to your project.
2

Create the proxy route

Create a file at server/proxy.js (or wherever your backend lives) with the following contents.
3

Set the environment variable

Add the Railway URL to your server environment. Never commit this value to source control.
4

Mount the router

Mount the proxy router in your main Express app.

Error Handling

ParaLens returns three meaningful HTTP status codes. Your client should handle each one explicitly.

Caching

Ethereum transactions are immutable once confirmed. A transaction hash always resolves to the same on-chain data, so caching responses by hash is safe and strongly recommended.
Cache responses by tx_hash with a TTL of 24 hours. This eliminates redundant upstream calls for any hash your users look up more than once and dramatically reduces latency for popular transactions.
A minimal in-memory cache example:
For production use, prefer a shared cache such as Redis or an HTTP cache layer so multiple server instances share the same warm entries.

TypeScript Types

Use these minimal interfaces to type the parts of TxReport most relevant to frontend rendering. The full schema includes additional fields; see Dashboard Layouts for guidance on which fields to surface per intent kind.
Always check DisplayMoney.available before rendering text. When available is false, the text field may be empty or a placeholder — display a fallback such as “Price unavailable” instead.

Next Steps

For a complete integration walkthrough including response caching and future API key support, see the Next.js Proxy guide.