openapi: 3.0.3
info:
  title: Divisas.lat API
  description: High-performance REST API to consolidate and serve official exchange rates from central banks. Import this collection to Apidog to test the endpoints.
  version: 1.0.0
servers:
  - url: https://api.divisas.lat
    description: Production Server
  - url: http://localhost:8787
    description: Local Development Server
components:
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
security:
  - ApiKeyAuth: []
paths:
  /v1/countries:
    get:
      summary: Get supported countries
      description: Returns the list of supported countries in the current API.
      responses:
        '200':
          description: List of countries
  /v1/{country}/currencies:
    get:
      summary: Get currencies
      description: Returns the catalog of supported currencies for a specific country.
      parameters:
        - in: path
          name: country
          required: true
          schema:
            type: string
          description: ISO Country Code (e.g., GT)
      responses:
        '200':
          description: Currency catalog
  /v1/{country}/rates:
    get:
      summary: Today's exchange rates
      description: Current day's exchange rates (based on local time zone).
      parameters:
        - in: path
          name: country
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Current exchange rates
  /v1/{country}/rates/{currencyId}:
    get:
      summary: Specific currency exchange rate
      description: Current day's exchange rate for a specific currency.
      parameters:
        - in: path
          name: country
          required: true
          schema:
            type: string
        - in: path
          name: currencyId
          required: true
          schema:
            type: string
          description: Currency Code (e.g., USD)
      responses:
        '200':
          description: Specific exchange rate
  /v1/{country}/rates/history:
    get:
      summary: Historical rates
      description: Historical exchange rates (up to 366 days).
      parameters:
        - in: path
          name: country
          required: true
          schema:
            type: string
        - in: query
          name: from
          schema:
            type: string
            format: date
          description: Start date (YYYY-MM-DD)
        - in: query
          name: to
          schema:
            type: string
            format: date
          description: End date (YYYY-MM-DD)
      responses:
        '200':
          description: Historical data
  /v1/{country}/rates/stats:
    get:
      summary: Statistics
      description: Advanced statistical summary.
      parameters:
        - in: path
          name: country
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Statistical summary
  /v1/{country}/rates/convert:
    get:
      summary: Convert currencies
      description: Direct conversion between two currencies using a pivot currency.
      parameters:
        - in: path
          name: country
          required: true
          schema:
            type: string
        - in: query
          name: amount
          schema:
            type: number
        - in: query
          name: from
          schema:
            type: string
        - in: query
          name: to
          schema:
            type: string
      responses:
        '200':
          description: Conversion result
  /v1/{country}/rates/forecast:
    get:
      summary: Rate forecast
      description: Future projection using linear regression.
      parameters:
        - in: path
          name: country
          required: true
          schema:
            type: string
        - in: query
          name: days
          schema:
            type: integer
          description: Number of days to forecast
      responses:
        '200':
          description: Forecasted data
  /v1/{country}/rates/percentile:
    get:
      summary: Historical percentile
      description: Context of the current price compared to its historical percentage behavior.
      parameters:
        - in: path
          name: country
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Percentile data
  /v1/auth/register:
    post:
      summary: Register API Key
      description: Generate a new API_KEY.
      security: []
      responses:
        '200':
          description: API Key successfully generated
