API Documentation

Learn how to use our exchange rate API

GET Get All Exchange Rates
https://www.tipodecambio.cr/api/rates

Returns the latest exchange rates for all institutions, including BCCR and Monex rates.

Response Example:

{
  "timestamp": 1700000000,
  "rates": [
    {
      "entidad": "Banco Nacional",
      "compra": 520.50,
      "venta": 525.00,
      "actualizacion": "2024-01-15",
      "institution_id": 1
    }
  ],
  "bccr_rate": {
    "compra": 520.00,
    "venta": 525.00,
    "fecha": "2024-01-15"
  },
  "monex_rate": {
    "promedio": 522.50,
    "fecha": "2024-01-15"
  }
}
GET Get Exchange Rate History
https://www.tipodecambio.cr/api/rates/history?institution_id={id}&limit={limit}

Returns historical exchange rate data.

Query Parameters:

Parameter Type Required Description
institution_id integer No Filter by institution ID. If omitted, returns all institutions.
limit integer No Maximum number of records to return (default: 100)

Response Example:

{
  "history": [
    {
      "fecha": "2024-01-15",
      "compra": 520.50,
      "venta": 525.00,
      "institution": {
        "id": 1,
        "name": "Banco Nacional"
      }
    }
  ]
}
GET Get Institution History
https://www.tipodecambio.cr/api/rates/institution/{id}?limit={limit}

Returns historical exchange rate data for a specific institution.

URL Parameters:

Parameter Type Required Description
id integer Yes Institution ID

Query Parameters:

Parameter Type Required Description
limit integer No Maximum number of records to return (default: 100)

Response Example:

{
  "institution": {
    "id": 1,
    "name": "Banco Nacional",
    "logo_url": "https://example.com/logo.png",
    "website_url": "https://www.bncr.fi.cr"
  },
  "history": [
    {
      "fecha": "2024-01-15",
      "compra": 520.50,
      "venta": 525.00
    }
  ]
}
GET Get Rates for Chrome Extension
https://www.tipodecambio.cr/api/extension/rates

Returns exchange rates formatted for Chrome extension use.

Response Example:

{
  "timestamp": 1700000000,
  "rates": [
    {
      "entidad": "Banco Nacional",
      "compra": 520.50,
      "venta": 525.00,
      "actualizacion": "2024-01-15"
    }
  ],
  "bccr_rate": {
    "compra": 520.00,
    "venta": 525.00,
    "fecha": "2024-01-15"
  },
  "monex_rate": {
    "promedio": 522.50,
    "fecha": "2024-01-15"
  }
}
Rate Limiting

All API endpoints are protected by rate limiting to ensure fair usage and system stability. Rate limits are applied per IP address.

Rate Limit Policies:

Endpoint Limit Window
GET /api/rates 100 requests 1 minute
GET /api/rates/history 100 requests 1 minute
GET /api/rates/institution/{id} 100 requests 1 minute
GET /api/extension/rates 100 requests 1 minute

Rate Limit Exceeded Response:

When the rate limit is exceeded, the API will return a 429 Too Many Requests status code with the following response:

{
  "error": "Too many requests. Please try again later."
}

The response will also include a Retry-After header indicating the number of seconds to wait before making another request.

Best Practices:

  • Implement exponential backoff when receiving 429 responses
  • Cache responses on the client side to reduce API calls
  • Monitor the Retry-After header for optimal retry timing

General Notes

  • All API endpoints return JSON responses
  • All dates are in YYYY-MM-DD format
  • Exchange rates are returned as floating-point numbers
  • The API does not require authentication for public endpoints
  • Rate limiting is applied per IP address