Skip to main content

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

POST /v1/quotes

Request Body

ParameterTypeRequiredDescription
customerIdstringYesCustomer ID
sourceCurrencystringYesFiat currency code (e.g., “USD”, “EUR”)
targetCurrencystringYesCrypto currency code (e.g., “BTC”, “ETH”)
sourceAmountstringNo*Amount in source currency
targetAmountstringNo*Amount in target currency
networkstringNoTarget blockchain network (e.g., “ethereum”, “polygon”, “arbitrum”)
walletIdstringNoTarget 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.
NetworkDescriptionTypical Fee
ethereumEthereum mainnetHigher fees, widest compatibility
polygonPolygon PoSLower fees, fast confirmation
arbitrumArbitrum OneLower fees, Ethereum security
optimismOptimismLower fees, Ethereum security
baseBaseLower 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

FieldTypeDescription
idstringUnique quote identifier
customerIdstringCustomer ID
sourceCurrencystringFiat currency code
targetCurrencystringCrypto currency code
sourceAmountstringAmount in fiat currency
targetAmountstringAmount in crypto currency (after fees)
exchangeRatestringExchange rate used
networkstringTarget blockchain network
feesobjectDetailed fee breakdown
fees.networkstringNetwork/gas fees for the transaction
fees.servicestringNowRamp service fee
fees.totalstringTotal fees (network + service)
expiresAtstringISO 8601 timestamp when quote expires
expiresInSecondsnumberSeconds remaining until expiration
isExpiredbooleanWhether the quote has expired
createdAtstringISO 8601 timestamp when quote was created

Get Quote

Retrieve an existing quote by ID.

Endpoint

GET /v1/quotes/{quoteId}

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

StatusDescription
activeQuote is valid and can be used to create an order
expiredQuote has passed its expiration time
usedQuote has been used to create an order

Supported Currencies

Fiat Currencies

CodeName
USDUS Dollar
EUREuro
GBPBritish Pound

Cryptocurrencies

CodeNameSupported Networks
BTCBitcoinbitcoin
ETHEthereumethereum, arbitrum, optimism, base
USDTTetherethereum, polygon, arbitrum, optimism
USDCUSD Coinethereum, 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.