{
  "openapi": "3.0.0",
  "info": {
    "title": "Yadio.io API",
    "description": "# Introduction\n\nOur REST API provides easy, seamless integration of accurate, real-time exchange rates directly into your applications, delivering transparent data that reflects the true free-market value of currencies. This is a public API for real-time and historical cryptocurrency and fiat exchange rates.\n\n# API Conventions\n\n## Response Format\n\nAll API responses are in JSON format.\n\n## Timestamp Format\n\nAll timestamps are returned as Unix time in milliseconds.\n\n## Rate Limits\n\nThe API is rate-limited to 100 requests per minute. If you exceed this limit, the API will return a `429 Too Many Requests` status code.",
    "version": "1.0.0",
    "termsOfService": "https://yadio.io/terms.html",
    "contact": {
      "email": "info+api@yadio.io",
      "url": "https://yadio.io"
    },
    "x-logo": {
      "url": "https://yadio.io/img/logo.png",
      "altText": "Yadio.io Logo"
    }
  },
  "servers": [
    {
      "url": "https://api.yadio.io",
      "description": "Main production server"
    }
  ],
  "paths": {
    "/exrates": {
      "get": {
        "summary": "Get Latest Exchange Rates (USD)",
        "description": "Retrieves the current foreign exchange rates, using USD as the default base currency.",
        "tags": ["Rates"],
        "responses": {
          "200": {
            "description": "Successful response containing the exchange rates for the default currency (USD).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "base": { "type": "string", "example": "USD" },
                    "rates": { "type": "object" },
                    "timestamp": { "$ref": "#/components/schemas/timestamp" }
                  }
                },
                "examples": {
                  "successfulResponse": {
                    "summary": "A successful response for USD rates",
                    "value": {
                      "BTC": 102764.81,
                      "USD": {
                        "BTC": 0.000009730958,
                        "AED": 3.6725
                      },
                      "base": "USD",
                      "timestamp": 1750440302666
                    }
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/InvalidRequest" },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    },
    "/exrates/{currency}": {
      "get": {
        "summary": "Get Exchange Rates for a Specific Currency",
        "description": "Retrieves the current foreign exchange rates for a specified currency.",
        "tags": ["Rates"],
        "parameters": [
          {
            "name": "currency",
            "in": "path",
            "required": true,
            "description": "The base currency code (e.g., 'USD', 'EUR').",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response containing the exchange rates.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "base": { "type": "string" },
                    "rates": { "type": "object" },
                    "timestamp": { "$ref": "#/components/schemas/timestamp" }
                  }
                },
                "examples": {
                  "successfulResponse": {
                    "summary": "A successful response for EUR rates",
                    "value": {
                      "BTC": 89750.41,
                      "EUR": {
                        "BTC": 0.000011142011,
                        "AED": 4.229427,
                        "ALL": 103.056714
                      },
                      "base": "EUR",
                      "timestamp": 1750520402997
                    }
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/InvalidRequest" },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    },
    "/convert/{amount}/{from}/{to}": {
      "get": {
        "summary": "Convert Currency",
        "description": "Converts a specified amount from a source currency to a target currency.",
        "tags": ["Conversion"],
        "parameters": [
          {
            "name": "amount",
            "in": "path",
            "required": true,
            "description": "The amount of currency to convert.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "from",
            "in": "path",
            "required": true,
            "description": "The source currency code (e.g., 'BTC').",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "path",
            "required": true,
            "description": "The target currency code (e.g., 'USD').",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful conversion.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "request": {
                      "type": "object",
                      "properties": {
                        "amount": { "type": "number" },
                        "from": { "type": "string" },
                        "to": { "type": "string" }
                      }
                    },
                    "result": { "type": "number" },
                    "rate": { "type": "number" },
                    "timestamp": { "$ref": "#/components/schemas/timestamp" }
                  }
                },
                "examples": {
                  "successfulConversion": {
                    "summary": "A successful conversion from USD to ARS",
                    "value": {
                      "request": {
                        "amount": 100,
                        "from": "USD",
                        "to": "ARS"
                      },
                      "result": 118799.13,
                      "rate": 1187.99126,
                      "timestamp": 1750440602489
                    }
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/InvalidRequest" },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    },
    "/rate/{quote}/{base}": {
      "get": {
        "summary": "Get Specific Rate",
        "description": "Returns the current exchange rate for a specific currency pair.",
        "tags": ["Rates"],
        "parameters": [
          {
            "name": "quote",
            "in": "path",
            "required": true,
            "description": "The quote currency code (e.g., 'BTC').",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "base",
            "in": "path",
            "required": true,
            "description": "The base currency code (e.g., 'USD').",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with the rate.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "rate": { "type": "number" },
                    "timestamp": { "$ref": "#/components/schemas/timestamp" },
                    "request": { "type": "string" }
                  }
                },
                "examples": {
                  "successfulRateResponse": {
                    "summary": "A successful rate response for ARS/USD",
                    "value": {
                      "rate": 1187.44774,
                      "timestamp": 1750440902351,
                      "request": "rate:ARS/USD"
                    }
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/InvalidRequest" },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    },
    "/currencies": {
      "get": {
        "summary": "List Currencies",
        "description": "Returns a list of all available currencies.",
        "tags": ["Metadata"],
        "responses": {
          "200": {
            "description": "A list of available currencies.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "string"
                  }
                },
                "examples": {
                  "successfulResponse": {
                    "summary": "A successful response listing available currencies",
                    "value": {
                      "AED": "United Arab Emirates Dirham",
                      "ALL": "Albanian Lek",
                      "ANG": "Netherlands Antillean Guilder",
                      "USD": "United States Dollar"
                    }
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/InvalidRequest" },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    },
    "/exchanges": {
      "get": {
        "summary": "List Exchanges",
        "description": "Returns a list of active exchanges used for rate calculation.",
        "tags": ["Metadata"],
        "responses": {
          "200": {
            "description": "A list of active exchanges.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "examples": {
                  "successfulResponse": {
                    "summary": "A successful response listing active exchanges",
                    "value": [
                      "AltCoinTrader",
                      "AscendEx",
                      "BTC Markets",
                      "Binance",
                      "Kraken"
                    ]
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/InvalidRequest" },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    },
    "/today/{range}/{currency}": {
      "get": {
        "summary": "Get Today's Rate Information",
        "description": "Returns rate information for a specified currency and period.",
        "tags": ["Historical"],
        "parameters": [
          {
            "name": "range",
            "in": "path",
            "required": true,
            "description": "The time range in hours (e.g., '24' for the last 24 hours). Valid range: 1-24.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 24
            }
          },
          {
            "name": "currency",
            "in": "path",
            "required": true,
            "description": "The currency code to get information for.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with today's rate data.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "price": { "type": "number" },
                      "price_p2p": { "type": "number" },
                      "calc_std": { "type": "number" },
                      "avg24": { "type": "number" },
                      "usd": { "type": "number" },
                      "eur": { "type": "number" },
                      "volume": { "type": "number" },
                      "offers": { "type": "integer" },
                      "usdbtc": { "type": "number" },
                      "eurbtc": { "type": "number" },
                      "btc_avg24h": { "type": "number" },
                      "time": { "type": "string" }
                    }
                  }
                },
                "examples": {
                  "successfulResponse": {
                    "summary": "A successful response for today's data",
                    "value": [
                      {
                        "price": 121735226.05,
                        "price_p2p": 126151065.36,
                        "calc_std": 121735226.05,
                        "avg24": 124395920.84,
                        "usd": 1188.409962,
                        "eur": 1370.879508,
                        "volume": 0.01551371,
                        "offers": 291,
                        "usdbtc": 102435.38,
                        "eurbtc": 88763.26,
                        "btc_avg24h": 104895.39,
                        "time": "2:40 PM"
                      },
                      {
                        "price": 122044358.78,
                        "price_p2p": 126840355.72,
                        "calc_std": 122044358.78,
                        "avg24": 124398855.69,
                        "usd": 1187.44774,
                        "eur": 1370.120414,
                        "volume": 0.01551371,
                        "offers": 292,
                        "usdbtc": 102778.72,
                        "eurbtc": 89060.78,
                        "btc_avg24h": 104900.94,
                        "time": "2:35 PM"
                      }
                    ]
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/InvalidRequest" },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    },
    "/hist/{range}/{currency}": {
      "get": {
        "summary": "Get Historical Rates",
        "description": "Returns historical rate information for a specified currency and period.",
        "tags": ["Historical"],
        "parameters": [
          {
            "name": "range",
            "in": "path",
            "required": true,
            "description": "The time range in days (e.g., '30' for the last 30 days). Valid range: 1-365.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 365
            }
          },
          {
            "name": "currency",
            "in": "path",
            "required": true,
            "description": "The currency code to get historical data for.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with historical data.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/InvalidRequest" },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    },
    "/compare/{range}/{currency}": {
      "get": {
        "summary": "Get Comparison Information",
        "description": "Returns comparison information for a specified currency and period.",
        "tags": ["Historical"],
        "parameters": [
          {
            "name": "range",
            "in": "path",
            "required": true,
            "description": "The time range in days (e.g., '30' for the last 30 days). Valid range: 1-365.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 365
            }
          },
          {
            "name": "currency",
            "in": "path",
            "required": true,
            "description": "The currency code to get comparison information for.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with comparison data.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "date": { "type": "string", "format": "date" },
                      "avg24h": { "type": "number" },
                      "volume": { "type": "number" },
                      "usdbtc": { "type": "number" },
                      "official": { "type": "number" },
                      "usdt": { "type": "number" },
                      "cex": { "type": "number" },
                      "mep": { "type": "number" },
                      "ccl": { "type": "number" },
                      "dolarblue_buy": { "type": "integer" },
                      "dolarblue_sell": { "type": "integer" }
                    }
                  }
                },
                "examples": {
                  "successfulResponse": {
                    "summary": "A successful response for comparison data",
                    "value": [
                      {
                        "date": "06/19/2025",
                        "avg24h": 123537195.63,
                        "volume": 0.03047893,
                        "usdbtc": 104688.6,
                        "official": 1190,
                        "usdt": 1188.92,
                        "cex": 1184.337757,
                        "mep": 1174.03,
                        "ccl": 1157.71,
                        "dolarblue_buy": 1180,
                        "dolarblue_sell": 1200
                      },
                      {
                        "date": "06/18/2025",
                        "avg24h": 124174976.58,
                        "volume": 0.01783233,
                        "usdbtc": 104743.95,
                        "official": 1180,
                        "usdt": 1184.68,
                        "cex": 1179.638364,
                        "mep": 1167.07,
                        "ccl": 1172.16,
                        "dolarblue_buy": 1170,
                        "dolarblue_sell": 1190
                      }
                    ]
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/InvalidRequest" },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    },
    "/market/ads": {
      "get": {
        "summary": "Get P2P Market Ads",
        "description": "Returns P2P (peer-to-peer) market advertisements.",
        "tags": ["Market"],
        "parameters": [
          {
            "name": "currency",
            "in": "query",
            "required": true,
            "description": "The currency code.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "asset",
            "in": "query",
            "required": true,
            "description": "The crypto asset to get ads for.",
            "schema": {
              "type": "string",
              "enum": [
                "BTC",
                "USDT"
              ]
            }
          },
          {
            "name": "side",
            "in": "query",
            "required": true,
            "description": "Trade side: buy or sell",
            "schema": {
              "type": "string",
              "enum": ["buy", "sell"]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Number of ads to return (default=20)",
            "schema": {
              "type": "integer",
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A successful response containing a list of market ads.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "currency": { "type": "string" },
                    "asset": { "type": "string" },
                    "side": { "type": "string" },
                    "count": { "type": "integer" },
                    "total": { "type": "integer" },
                    "timestamp": { "$ref": "#/components/schemas/timestamp" },
                    "ads": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "price": { "type": "number" },
                          "ad_id": { "type": "string" },
                          "ad_url": { "type": "string", "format": "uri" },
                          "max_amount": { "type": "number" },
                          "min_amount": { "type": "number" },
                          "require_id": { "type": "boolean" },
                          "require_phone": { "type": "boolean" },
                          "username": { "type": "string" },
                          "feedback_score": { "type": "number" },
                          "payment_window": { "type": "integer" },
                          "trade_count": { "type": "integer" },
                          "last_online": { "$ref": "#/components/schemas/timestamp" },
                          "usd": { "type": "number" },
                          "eur": { "type": "number" },
                          "z_score": { "type": "number" },
                          "y_score": { "type": "integer" },
                          "exchange": { "type": "string" },
                          "payment_method": { "type": "string" }
                        }
                      }
                    }
                  }
                },
                "examples": {
                  "successfulResponse": {
                    "summary": "A successful response for market ads",
                    "value": {
                      "currency": "ARS",
                      "asset": "BTC",
                      "side": "buy",
                      "count": 5,
                      "total": 139,
                      "timestamp": 1750440965475,
                      "ads": [
                        {
                          "price": 117885205.54,
                          "ad_id": "3220172",
                          "ad_url": "https://www.bitget.com/en/p2p-trade?fiatName=ARS",
                          "max_amount": 4881764.88,
                          "min_amount": 50000,
                          "require_id": false,
                          "require_phone": false,
                          "username": "Bitget P2P User",
                          "feedback_score": 66,
                          "payment_window": 30,
                          "trade_count": 29,
                          "last_online": 1750440964208,
                          "usd": 1146.98,
                          "eur": 1323.43,
                          "z_score": -1.1807,
                          "y_score": 4,
                          "exchange": "Bitget P2P",
                          "payment_method": "Any Bank"
                        },
                        {
                          "price": 123839191.21,
                          "ad_id": "13735978607847718912",
                          "ad_url": "https://p2p.binance.com/en/advertiserDetail?advertiserNo=s8807df8a5ce4301abe1303c3296635b9",
                          "max_amount": 19600000,
                          "min_amount": 100000,
                          "require_id": false,
                          "require_phone": false,
                          "username": "BitArgExchange",
                          "feedback_score": 99.8,
                          "payment_window": 120,
                          "trade_count": 4411,
                          "last_online": 1750440964187,
                          "usd": 1204.91,
                          "eur": 1390.27,
                          "z_score": -0.9276,
                          "y_score": 4,
                          "exchange": "Binance P2P",
                          "payment_method": "Any Bank"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/InvalidRequest" },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    },
    "/market/stats": {
      "get": {
        "summary": "Get P2P Market Statistics",
        "description": "Returns statistics about the P2P (peer-to-peer) market.",
        "tags": ["Market"],
        "parameters": [
          {
            "name": "currency",
            "in": "query",
            "required": true,
            "description": "The currency code.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "asset",
            "in": "query",
            "required": true,
            "description": "The crypto asset to get stats for.",
            "schema": {
              "type": "string",
              "enum": [
                "BTC",
                "USDT"
              ]
            }
          },
          {
            "name": "side",
            "in": "query",
            "required": true,
            "description": "Trade side: buy or sell",
            "schema": {
              "type": "string",
              "enum": ["buy", "sell"]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A successful response containing market statistics.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "currency": { "type": "string" },
                    "asset": { "type": "string" },
                    "side": { "type": "string" },
                    "stats": {
                      "type": "object",
                      "properties": {
                        "mean": { "type": "number" },
                        "median": { "type": "number" },
                        "sigma": { "type": "number" },
                        "total": { "type": "integer" },
                        "ads_count": {
                          "type": "object",
                          "additionalProperties": { "type": "integer" }
                        },
                        "y_score_freq": {
                          "type": "object",
                          "additionalProperties": { "type": "integer" }
                        },
                        "top_payment_methods": {
                          "type": "object",
                          "additionalProperties": { "type": "integer" }
                        }
                      }
                    },
                    "timestamp": { "$ref": "#/components/schemas/timestamp" }
                  }
                },
                "examples": {
                  "successfulResponse": {
                    "summary": "A successful response for market statistics",
                    "value": {
                      "currency": "ARS",
                      "asset": "BTC",
                      "side": "buy",
                      "stats": {
                        "mean": 145659595.85,
                        "median": 140084473.9,
                        "sigma": 23524133.08,
                        "total": 139,
                        "ads_count": {
                          "Paxful": 52,
                          "Binance P2P": 39
                        },
                        "y_score_freq": {
                          "1": 10,
                          "4": 59
                        },
                        "top_payment_methods": {
                          "Any Bank": 93,
                          "Mercado Pago": 23
                        }
                      },
                      "timestamp": 1750440965475
                    }
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/InvalidRequest" },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    },
    "/ping": {
      "get": {
        "summary": "Ping Server",
        "description": "Checks the server status.",
        "tags": ["Utilities"],
        "responses": {
          "200": {
            "description": "Server is up and running.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    }
                  }
                },
                "examples": {
                  "successfulPing": {
                    "summary": "A successful ping response",
                    "value": {
                      "status": "ok"
                    }
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/InvalidRequest" },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "timestamp": {
        "type": "integer",
        "format": "int64",
        "description": "A Unix timestamp in milliseconds."
      }
    },
    "responses": {
      "InvalidRequest": {
        "description": "Invalid request. This can be due to a missing or invalid parameter."
      },
      "TooManyRequests": {
        "description": "Rate limit exceeded. The API is limited to 100 requests per minute."
      },
      "InternalServerError": {
        "description": "A generic internal server error occurred."
      }
    }
  },
  "tags": [
    {
      "name": "Rates",
      "description": "Endpoints for retrieving exchange rates."
    },
    {
      "name": "Conversion",
      "description": "Endpoint for currency conversion."
    },
    {
      "name": "Historical",
      "description": "Endpoints for retrieving historical, daily, and comparison data."
    },
    {
      "name": "Market",
      "description": "Endpoints related to the P2P market."
    },
    {
      "name": "Metadata",
      "description": "Endpoints for retrieving API metadata like available currencies."
    },
    {
      "name": "Utilities",
      "description": "Utility endpoints."
    }
  ]
}
