Quotes API
Quotes provide real-time pricing for crypto purchases. They include exchange rates, fees, and the final amounts.
Generate Quote
Create a new quote for a crypto purchase.
Quotes are valid for a limited time (typically 60 seconds). Use the returned expiresAt timestamp and expiresInSeconds countdown to track validity.
Endpoint
Request Body
| Parameter | Type | Required | Description |
|---|
customerId | string | Yes | Customer ID |
sourceCurrency | string | Yes | Fiat currency code (e.g., “USD”, “EUR”) |
targetCurrency | string | Yes | Crypto currency code (e.g., “BTC”, “ETH”) |
sourceAmount | string | No* | Amount in source currency |
targetAmount | string | No* | Amount in target currency |
network | string | No | Target blockchain network (e.g., “ethereum”, “polygon”, “arbitrum”) |
walletId | string | No | Target wallet ID |
Provide either sourceAmount or targetAmount, not both.
Network Selection
When purchasing tokens available on multiple networks, specify the network parameter to select the target blockchain. This affects network fees and delivery times.
| Network | Description | Typical Fee |
|---|
ethereum | Ethereum mainnet | Higher fees, widest compatibility |
polygon | Polygon PoS | Lower fees, fast confirmation |
arbitrum | Arbitrum One | Lower fees, Ethereum security |
optimism | Optimism | Lower fees, Ethereum security |
base | Base | Lower fees, Coinbase ecosystem |
If network is not specified, the default network for the target currency will be used. For native assets like BTC, the network parameter is ignored.
Example Request
curl -X POST https://api.nowramp.com/v1/quotes \
-H "X-API-Key: your_api_key" \
-H "Content-Type: application/json" \
-d '{
"customerId": "cust_abc123",
"sourceCurrency": "USD",
"targetCurrency": "USDC",
"sourceAmount": "100.00",
"network": "polygon"
}'
Response
{
"success": true,
"data": {
"id": "quote_xyz789",
"customerId": "cust_abc123",
"sourceCurrency": "USD",
"targetCurrency": "USDC",
"sourceAmount": "100.00",
"targetAmount": "96.50",
"exchangeRate": "1.00",
"network": "polygon",
"fees": {
"network": "0.50",
"service": "3.00",
"total": "3.50"
},
"expiresAt": "2024-01-15T10:31:00Z",
"expiresInSeconds": 60,
"isExpired": false,
"createdAt": "2024-01-15T10:30:00Z"
}
}
Response Fields
| Field | Type | Description |
|---|
id | string | Unique quote identifier |
customerId | string | Customer ID |
sourceCurrency | string | Fiat currency code |
targetCurrency | string | Crypto currency code |
sourceAmount | string | Amount in fiat currency |
targetAmount | string | Amount in crypto currency (after fees) |
exchangeRate | string | Exchange rate used |
network | string | Target blockchain network |
fees | object | Detailed fee breakdown |
fees.network | string | Network/gas fees for the transaction |
fees.service | string | NowRamp service fee |
fees.total | string | Total fees (network + service) |
expiresAt | string | ISO 8601 timestamp when quote expires |
expiresInSeconds | number | Seconds remaining until expiration |
isExpired | boolean | Whether the quote has expired |
createdAt | string | ISO 8601 timestamp when quote was created |
Get Quote
Retrieve an existing quote by ID.
Endpoint
Example Request
curl https://api.nowramp.com/v1/quotes/quote_xyz789 \
-H "X-API-Key: your_api_key"
Response
{
"success": true,
"data": {
"id": "quote_xyz789",
"customerId": "cust_abc123",
"sourceCurrency": "USD",
"targetCurrency": "BTC",
"sourceAmount": "100.00",
"targetAmount": "0.00234567",
"exchangeRate": "42650.00",
"network": "bitcoin",
"fees": {
"network": "0.50",
"service": "2.50",
"total": "3.00"
},
"status": "active",
"expiresAt": "2024-01-15T10:31:00Z",
"expiresInSeconds": 45,
"isExpired": false,
"createdAt": "2024-01-15T10:30:00Z"
}
}
Quote Expiry Handling
Quotes expire after a short period (typically 60 seconds) due to cryptocurrency price volatility. Your application should handle quote expiration gracefully.
Tracking Expiration
Use the expiry fields to monitor quote validity:
expiresAt - Absolute expiration timestamp (ISO 8601)
expiresInSeconds - Countdown in seconds (decreases on each fetch)
isExpired - Boolean flag indicating if quote is no longer valid
Example: Quote Expiry Handling
// Fetch a quote
async function getQuote(customerId, amount) {
const response = await fetch('https://api.nowramp.com/v1/quotes', {
method: 'POST',
headers: {
'X-API-Key': 'your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
customerId,
sourceCurrency: 'USD',
targetCurrency: 'ETH',
sourceAmount: amount,
network: 'ethereum'
})
});
return response.json();
}
// Handle quote with expiry tracking
async function handleQuoteWithExpiry(customerId, amount) {
const { data: quote } = await getQuote(customerId, amount);
// Check if quote is already expired
if (quote.isExpired) {
console.log('Quote already expired, fetching new quote...');
return handleQuoteWithExpiry(customerId, amount);
}
// Set up expiry warning (10 seconds before expiration)
const warningTimeout = setTimeout(() => {
console.log('Quote expiring soon! Refresh recommended.');
onQuoteExpiringSoon(quote);
}, (quote.expiresInSeconds - 10) * 1000);
// Set up auto-refresh on expiry
const expiryTimeout = setTimeout(() => {
console.log('Quote expired, fetching new quote...');
onQuoteExpired(quote);
}, quote.expiresInSeconds * 1000);
// Return quote with cleanup function
return {
quote,
cleanup: () => {
clearTimeout(warningTimeout);
clearTimeout(expiryTimeout);
}
};
}
// Create order before quote expires
async function createOrderFromQuote(quoteId) {
// First, verify quote is still valid
const { data: quote } = await fetch(
`https://api.nowramp.com/v1/quotes/${quoteId}`,
{ headers: { 'X-API-Key': 'your_api_key' } }
).then(r => r.json());
if (quote.isExpired) {
throw new Error('Quote has expired. Please request a new quote.');
}
// Proceed with order creation
const response = await fetch('https://api.nowramp.com/v1/orders', {
method: 'POST',
headers: {
'X-API-Key': 'your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({ quoteId })
});
return response.json();
}
Example: React Hook for Quote Expiry
import { useState, useEffect, useCallback } from 'react';
interface Quote {
id: string;
expiresAt: string;
expiresInSeconds: number;
isExpired: boolean;
// ... other fields
}
function useQuoteWithExpiry(customerId: string, amount: string) {
const [quote, setQuote] = useState<Quote | null>(null);
const [secondsRemaining, setSecondsRemaining] = useState(0);
const [isExpired, setIsExpired] = useState(false);
const fetchQuote = useCallback(async () => {
const response = await fetch('https://api.nowramp.com/v1/quotes', {
method: 'POST',
headers: {
'X-API-Key': 'your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
customerId,
sourceCurrency: 'USD',
targetCurrency: 'ETH',
sourceAmount: amount
})
});
const { data } = await response.json();
setQuote(data);
setSecondsRemaining(data.expiresInSeconds);
setIsExpired(false);
}, [customerId, amount]);
// Countdown timer
useEffect(() => {
if (secondsRemaining <= 0) {
setIsExpired(true);
return;
}
const timer = setInterval(() => {
setSecondsRemaining(prev => {
if (prev <= 1) {
setIsExpired(true);
return 0;
}
return prev - 1;
});
}, 1000);
return () => clearInterval(timer);
}, [secondsRemaining]);
return {
quote,
secondsRemaining,
isExpired,
refreshQuote: fetchQuote
};
}
Quote Statuses
| Status | Description |
|---|
active | Quote is valid and can be used to create an order |
expired | Quote has passed its expiration time |
used | Quote has been used to create an order |
Supported Currencies
Fiat Currencies
| Code | Name |
|---|
USD | US Dollar |
EUR | Euro |
GBP | British Pound |
Cryptocurrencies
| Code | Name | Supported Networks |
|---|
BTC | Bitcoin | bitcoin |
ETH | Ethereum | ethereum, arbitrum, optimism, base |
USDT | Tether | ethereum, polygon, arbitrum, optimism |
USDC | USD Coin | ethereum, polygon, arbitrum, optimism, base |
Available currencies and networks depend on your project configuration. Contact support to enable additional currencies or networks.
Error Responses
Quote Expired
{
"success": false,
"error": {
"code": "QUOTE_EXPIRED",
"message": "Quote has expired. Please request a new quote."
}
}
Invalid Network
{
"success": false,
"error": {
"code": "INVALID_NETWORK",
"message": "The specified network is not supported for this currency."
}
}
Rate Limiting
Quote generation is limited to 60 requests per minute to prevent abuse.