{
    "swagger": "2.0",
    "info": {
        "title": "Rate-API",
        "description": "Live and historical foreign-exchange rates for 160+ currencies, plus conversion. Authenticate with your API key from the Rate-API dashboard.",
        "version": "1.0",
        "contact": {
            "name": "Rate-API",
            "url": "https://rate-api.com"
        }
    },
    "host": "rate-api.com",
    "basePath": "/api/v1",
    "schemes": [
        "https"
    ],
    "consumes": [
        "application/json"
    ],
    "produces": [
        "application/json"
    ],
    "securityDefinitions": {
        "api_key": {
            "type": "apiKey",
            "in": "header",
            "name": "X-API-Key",
            "description": "Your Rate-API key (dashboard > API Keys)."
        }
    },
    "security": [
        {
            "api_key": []
        }
    ],
    "paths": {
        "/latest": {
            "get": {
                "summary": "Latest rates",
                "description": "Latest exchange rates for a base currency.",
                "operationId": "GetLatest",
                "parameters": [
                    {
                        "name": "base",
                        "in": "query",
                        "type": "string",
                        "required": false,
                        "description": "Base currency code, e.g. USD.",
                        "default": "USD"
                    },
                    {
                        "name": "symbols",
                        "in": "query",
                        "type": "string",
                        "required": false,
                        "description": "Comma-separated target codes to filter, e.g. EUR,GBP."
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "schema": {
                            "$ref": "#/definitions/LatestResponse"
                        }
                    },
                    "default": {
                        "description": "Error",
                        "schema": {
                            "$ref": "#/definitions/Error"
                        }
                    }
                }
            }
        },
        "/convert": {
            "get": {
                "summary": "Convert an amount",
                "description": "Convert an amount from one currency to another (Pro plan and up).",
                "operationId": "Convert",
                "parameters": [
                    {
                        "name": "from",
                        "in": "query",
                        "type": "string",
                        "required": true,
                        "description": "Source currency code.",
                        "default": "USD"
                    },
                    {
                        "name": "to",
                        "in": "query",
                        "type": "string",
                        "required": true,
                        "description": "Target currency code.",
                        "default": "EUR"
                    },
                    {
                        "name": "amount",
                        "in": "query",
                        "type": "string",
                        "required": true,
                        "description": "Amount to convert.",
                        "default": "100"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "schema": {
                            "$ref": "#/definitions/ConvertResponse"
                        }
                    },
                    "default": {
                        "description": "Error",
                        "schema": {
                            "$ref": "#/definitions/Error"
                        }
                    }
                }
            }
        },
        "/pair/{from}/{to}": {
            "get": {
                "summary": "Pair rate",
                "description": "Live rate for a currency pair.",
                "operationId": "GetPair",
                "parameters": [
                    {
                        "name": "from",
                        "in": "path",
                        "type": "string",
                        "required": true,
                        "description": "Source currency code."
                    },
                    {
                        "name": "to",
                        "in": "path",
                        "type": "string",
                        "required": true,
                        "description": "Target currency code."
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "schema": {
                            "$ref": "#/definitions/PairResponse"
                        }
                    },
                    "default": {
                        "description": "Error",
                        "schema": {
                            "$ref": "#/definitions/Error"
                        }
                    }
                }
            }
        },
        "/historical": {
            "get": {
                "summary": "Historical rates",
                "description": "Exchange rates for a past date (Pro plan and up).",
                "operationId": "GetHistorical",
                "parameters": [
                    {
                        "name": "date",
                        "in": "query",
                        "type": "string",
                        "required": true,
                        "description": "Date in YYYY-MM-DD format.",
                        "default": "2026-01-01"
                    },
                    {
                        "name": "base",
                        "in": "query",
                        "type": "string",
                        "required": false,
                        "description": "Base currency code.",
                        "default": "USD"
                    },
                    {
                        "name": "symbols",
                        "in": "query",
                        "type": "string",
                        "required": false,
                        "description": "Comma-separated target codes."
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "schema": {
                            "$ref": "#/definitions/LatestResponse"
                        }
                    },
                    "default": {
                        "description": "Error",
                        "schema": {
                            "$ref": "#/definitions/Error"
                        }
                    }
                }
            }
        },
        "/crypto": {
            "get": {
                "summary": "Crypto rates",
                "description": "Top cryptocurrency prices in USD (Pro plan and up).",
                "operationId": "GetCrypto",
                "parameters": [
                    {
                        "name": "symbols",
                        "in": "query",
                        "type": "string",
                        "required": false,
                        "description": "Comma-separated crypto symbols, e.g. BTC,ETH."
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "schema": {
                            "$ref": "#/definitions/GenericResponse"
                        }
                    },
                    "default": {
                        "description": "Error",
                        "schema": {
                            "$ref": "#/definitions/Error"
                        }
                    }
                }
            }
        },
        "/currencies": {
            "get": {
                "summary": "List currencies",
                "description": "All supported currencies with names and symbols.",
                "operationId": "ListCurrencies",
                "parameters": [],
                "responses": {
                    "200": {
                        "description": "Success",
                        "schema": {
                            "$ref": "#/definitions/CurrenciesResponse"
                        }
                    },
                    "default": {
                        "description": "Error",
                        "schema": {
                            "$ref": "#/definitions/Error"
                        }
                    }
                }
            }
        },
        "/usage": {
            "get": {
                "summary": "Usage",
                "description": "Request counts for the current key.",
                "operationId": "GetUsage",
                "parameters": [],
                "responses": {
                    "200": {
                        "description": "Success",
                        "schema": {
                            "$ref": "#/definitions/GenericResponse"
                        }
                    },
                    "default": {
                        "description": "Error",
                        "schema": {
                            "$ref": "#/definitions/Error"
                        }
                    }
                }
            }
        },
        "/quota": {
            "get": {
                "summary": "Quota",
                "description": "Plan quota and remaining requests for the current key.",
                "operationId": "GetQuota",
                "parameters": [],
                "responses": {
                    "200": {
                        "description": "Success",
                        "schema": {
                            "$ref": "#/definitions/GenericResponse"
                        }
                    },
                    "default": {
                        "description": "Error",
                        "schema": {
                            "$ref": "#/definitions/Error"
                        }
                    }
                }
            }
        }
    },
    "definitions": {
        "LatestResponse": {
            "type": "object",
            "properties": {
                "success": {
                    "type": "boolean"
                },
                "timestamp": {
                    "type": "integer"
                },
                "base": {
                    "type": "string",
                    "example": "USD"
                },
                "date": {
                    "type": "string",
                    "example": "2026-06-27"
                },
                "rates": {
                    "type": "object",
                    "additionalProperties": {
                        "type": "number"
                    },
                    "description": "Currency code to rate."
                }
            }
        },
        "ConvertResponse": {
            "type": "object",
            "properties": {
                "success": {
                    "type": "boolean"
                },
                "query": {
                    "type": "object",
                    "properties": {
                        "from": {
                            "type": "string"
                        },
                        "to": {
                            "type": "string"
                        },
                        "amount": {
                            "type": "number"
                        }
                    }
                },
                "info": {
                    "type": "object",
                    "properties": {
                        "timestamp": {
                            "type": "integer"
                        },
                        "rate": {
                            "type": "number"
                        }
                    }
                },
                "date": {
                    "type": "string"
                },
                "result": {
                    "type": "number"
                }
            }
        },
        "PairResponse": {
            "type": "object",
            "properties": {
                "success": {
                    "type": "boolean"
                },
                "pair": {
                    "type": "object",
                    "properties": {
                        "from": {
                            "type": "string"
                        },
                        "to": {
                            "type": "string"
                        }
                    }
                },
                "rate": {
                    "type": "number"
                },
                "timestamp": {
                    "type": "integer"
                },
                "date": {
                    "type": "string"
                }
            }
        },
        "CurrenciesResponse": {
            "type": "object",
            "properties": {
                "success": {
                    "type": "boolean"
                },
                "currencies": {
                    "type": "object",
                    "description": "Currency code to metadata."
                },
                "total": {
                    "type": "integer"
                },
                "timestamp": {
                    "type": "integer"
                }
            }
        },
        "GenericResponse": {
            "type": "object",
            "properties": {
                "success": {
                    "type": "boolean"
                }
            }
        },
        "Error": {
            "type": "object",
            "properties": {
                "success": {
                    "type": "boolean",
                    "example": false
                },
                "error": {
                    "type": "object",
                    "properties": {
                        "code": {
                            "type": "integer"
                        },
                        "type": {
                            "type": "string"
                        },
                        "message": {
                            "type": "string"
                        }
                    }
                }
            }
        }
    }
}