openapi: 3.1.0

info:
  title: Open Exchange Rate API
  description: >
    Free, ungated exchange rate API provided by ExchangeRate-API.
    Returns the latest exchange rates for a given base currency against
    all supported currencies. No authentication required.
  version: "6.0"
  contact:
    url: https://www.exchangerate-api.com
  license:
    name: Terms of Use
    url: https://www.exchangerate-api.com/terms

servers:
  - url: https://open.er-api.com/v6
    description: Production server

paths:
  /latest/{baseCurrency}:
    get:
      summary: Get latest exchange rates
      description: >
        Returns the latest exchange rates for the specified base currency.
        Rates are updated approximately once every 24 hours.
      operationId: getLatestRates
      parameters:
        - name: baseCurrency
          in: path
          required: true
          description: >
            ISO 4217 three-letter currency code to use as the base currency
            (e.g., USD, EUR, GBP).
          schema:
            type: string
            pattern: "^[A-Z]{3}$"
            example: USD
      responses:
        "200":
          description: Successful response containing exchange rates.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ExchangeRateResponse"
              example:
                result: success
                provider: https://www.exchangerate-api.com
                documentation: https://www.exchangerate-api.com/docs/free
                terms_of_use: https://www.exchangerate-api.com/terms
                time_last_update_unix: 1773878552
                time_last_update_utc: "Thu, 19 Mar 2026 00:02:32 +0000"
                time_next_update_unix: 1773965342
                time_next_update_utc: "Fri, 20 Mar 2026 00:09:02 +0000"
                time_eol_unix: 0
                base_code: USD
                rates:
                  USD: 1
                  EUR: 0.870198
                  GBP: 0.751954
                  JPY: 159.530519
                  CAD: 1.371798
                  AUD: 1.41783
        "404":
          description: >
            The specified base currency code is not recognized or not supported.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"

components:
  schemas:

    ExchangeRateResponse:
      type: object
      required:
        - result
        - provider
        - documentation
        - terms_of_use
        - time_last_update_unix
        - time_last_update_utc
        - time_next_update_unix
        - time_next_update_utc
        - time_eol_unix
        - base_code
        - rates
      properties:
        result:
          type: string
          description: >
            Outcome of the request. "success" indicates a valid response.
          enum:
            - success
            - error
          example: success

        provider:
          type: string
          format: uri
          description: URL of the data provider.
          example: https://www.exchangerate-api.com

        documentation:
          type: string
          format: uri
          description: URL of the API documentation.
          example: https://www.exchangerate-api.com/docs/free

        terms_of_use:
          type: string
          format: uri
          description: URL of the terms of use for this API.
          example: https://www.exchangerate-api.com/terms

        time_last_update_unix:
          type: integer
          format: int64
          description: Unix timestamp (seconds) of when the rates were last updated.
          example: 1773878552

        time_last_update_utc:
          type: string
          description: Human-readable UTC datetime string of when the rates were last updated.
          example: "Thu, 19 Mar 2026 00:02:32 +0000"

        time_next_update_unix:
          type: integer
          format: int64
          description: Unix timestamp (seconds) of when the next rate update is expected.
          example: 1773965342

        time_next_update_utc:
          type: string
          description: Human-readable UTC datetime string of when the next update is expected.
          example: "Fri, 20 Mar 2026 00:09:02 +0000"

        time_eol_unix:
          type: integer
          format: int64
          description: >
            Unix timestamp of the end-of-life for this API version.
            A value of 0 indicates no scheduled end-of-life.
          example: 0

        base_code:
          type: string
          pattern: "^[A-Z]{3}$"
          description: ISO 4217 three-letter code of the base currency used for this response.
          example: USD

        rates:
          $ref: "#/components/schemas/RatesMap"

    RatesMap:
      type: object
      description: >
        A map of ISO 4217 currency codes to their exchange rate relative to
        the base currency. The base currency always has a rate of 1.
      additionalProperties:
        type: number
        format: double
        description: Exchange rate relative to the base currency.
      example:
        USD: 1
        AED: 3.6725
        EUR: 0.870198
        GBP: 0.751954
        JPY: 159.530519
        CAD: 1.371798
        AUD: 1.41783
        CHF: 0.79082
        CNY: 6.88917
        INR: 92.947622

    ErrorResponse:
      type: object
      properties:
        result:
          type: string
          enum:
            - error
          example: error
        error-type:
          type: string
          description: Machine-readable error code describing the failure reason.
          example: unsupported-code
