{
  "openapi": "3.0.3",
  "info": {
    "title": "coinpay USDT P2P premium open data",
    "version": "1.0.0",
    "description": "Free USDT P2P premium history for Binance and OKX by fiat currency: daily and 30-minute data in CSV and JSON, documented columns, CC BY 4.0 license. Public HTTPS GET files: no API key, CORS enabled for every origin, refreshed every 30 minutes (UTC). Please credit coinpay.hk.",
    "license": {
      "name": "CC BY 4.0",
      "url": "https://creativecommons.org/licenses/by/4.0/"
    },
    "contact": {
      "name": "coinpay",
      "url": "https://coinpay.hk/en/data"
    }
  },
  "externalDocs": {
    "description": "Data catalog, column reference and methodology",
    "url": "https://coinpay.hk/en/data#api"
  },
  "servers": [
    {
      "url": "https://coinpay.hk"
    }
  ],
  "paths": {
    "/data/p2p/catalog.json": {
      "get": {
        "summary": "List every market with its coverage and file URLs",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Catalog"
                }
              }
            }
          },
          "404": {
            "description": "No data recorded for this fiat or month."
          }
        }
      }
    },
    "/data/p2p/{fiat}-daily.json": {
      "get": {
        "summary": "Daily statistics for one fiat (one row per UTC day, side and exchange)",
        "parameters": [
          {
            "name": "fiat",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "ves",
                "ars",
                "ngn",
                "idr",
                "aed",
                "aud",
                "bdt",
                "brl",
                "cad",
                "cny",
                "cop",
                "eur",
                "gbp",
                "hkd",
                "inr",
                "jpy",
                "khr",
                "krw",
                "lak",
                "lkr",
                "mxn",
                "myr",
                "pen",
                "php",
                "pkr",
                "try",
                "usd",
                "vnd",
                "zar"
              ]
            },
            "description": "Lower-case ISO 4217 code of the fiat currency."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "dataset": {
                      "type": "object",
                      "description": "Dataset description: name, license, source, methodology, columns and coverage.",
                      "additionalProperties": true
                    },
                    "rows": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/DailyRow"
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "No data recorded for this fiat or month."
          }
        }
      }
    },
    "/data/p2p/{fiat}-daily.csv": {
      "get": {
        "summary": "Daily statistics for one fiat, as CSV",
        "parameters": [
          {
            "name": "fiat",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "ves",
                "ars",
                "ngn",
                "idr",
                "aed",
                "aud",
                "bdt",
                "brl",
                "cad",
                "cny",
                "cop",
                "eur",
                "gbp",
                "hkd",
                "inr",
                "jpy",
                "khr",
                "krw",
                "lak",
                "lkr",
                "mxn",
                "myr",
                "pen",
                "php",
                "pkr",
                "try",
                "usd",
                "vnd",
                "zar"
              ]
            },
            "description": "Lower-case ISO 4217 code of the fiat currency."
          }
        ],
        "responses": {
          "200": {
            "description": "UTF-8 CSV with one header row; the columns match the JSON rows.",
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "No data recorded for this fiat or month."
          }
        }
      }
    },
    "/data/p2p/{fiat}-{month}.json": {
      "get": {
        "summary": "Every 30-minute sample of one fiat in one month",
        "parameters": [
          {
            "name": "fiat",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "ves",
                "ars",
                "ngn",
                "idr",
                "aed",
                "aud",
                "bdt",
                "brl",
                "cad",
                "cny",
                "cop",
                "eur",
                "gbp",
                "hkd",
                "inr",
                "jpy",
                "khr",
                "krw",
                "lak",
                "lkr",
                "mxn",
                "myr",
                "pen",
                "php",
                "pkr",
                "try",
                "usd",
                "vnd",
                "zar"
              ]
            },
            "description": "Lower-case ISO 4217 code of the fiat currency."
          },
          {
            "name": "month",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^\\d{4}-(0[1-9]|1[0-2])$",
              "example": "2026-09"
            },
            "description": "UTC month, YYYY-MM."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "dataset": {
                      "type": "object",
                      "description": "Dataset description: name, license, source, methodology, columns and coverage.",
                      "additionalProperties": true
                    },
                    "rows": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/SampleRow"
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "No data recorded for this fiat or month."
          }
        }
      }
    },
    "/data/p2p/{fiat}-{month}.csv": {
      "get": {
        "summary": "Every 30-minute sample of one fiat in one month, as CSV",
        "parameters": [
          {
            "name": "fiat",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "ves",
                "ars",
                "ngn",
                "idr",
                "aed",
                "aud",
                "bdt",
                "brl",
                "cad",
                "cny",
                "cop",
                "eur",
                "gbp",
                "hkd",
                "inr",
                "jpy",
                "khr",
                "krw",
                "lak",
                "lkr",
                "mxn",
                "myr",
                "pen",
                "php",
                "pkr",
                "try",
                "usd",
                "vnd",
                "zar"
              ]
            },
            "description": "Lower-case ISO 4217 code of the fiat currency."
          },
          {
            "name": "month",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^\\d{4}-(0[1-9]|1[0-2])$",
              "example": "2026-09"
            },
            "description": "UTC month, YYYY-MM."
          }
        ],
        "responses": {
          "200": {
            "description": "UTF-8 CSV with one header row; the columns match the JSON rows.",
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "No data recorded for this fiat or month."
          }
        }
      }
    },
    "/embed/p2p/{fiat}-history.png": {
      "get": {
        "summary": "Embeddable premium history chart (PNG)",
        "parameters": [
          {
            "name": "fiat",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "ves",
                "ars",
                "ngn",
                "idr",
                "aed",
                "aud",
                "bdt",
                "brl",
                "cad",
                "cny",
                "cop",
                "eur",
                "gbp",
                "hkd",
                "inr",
                "jpy",
                "khr",
                "krw",
                "lak",
                "lkr",
                "mxn",
                "myr",
                "pen",
                "php",
                "pkr",
                "try",
                "usd",
                "vnd",
                "zar"
              ]
            },
            "description": "Lower-case ISO 4217 code of the fiat currency."
          }
        ],
        "responses": {
          "200": {
            "description": "Chart image",
            "content": {
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "404": {
            "description": "No data recorded for this fiat or month."
          }
        }
      }
    },
    "/embed/p2p/{fiat}-history.svg": {
      "get": {
        "summary": "Embeddable premium history chart (SVG)",
        "parameters": [
          {
            "name": "fiat",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "ves",
                "ars",
                "ngn",
                "idr",
                "aed",
                "aud",
                "bdt",
                "brl",
                "cad",
                "cny",
                "cop",
                "eur",
                "gbp",
                "hkd",
                "inr",
                "jpy",
                "khr",
                "krw",
                "lak",
                "lkr",
                "mxn",
                "myr",
                "pen",
                "php",
                "pkr",
                "try",
                "usd",
                "vnd",
                "zar"
              ]
            },
            "description": "Lower-case ISO 4217 code of the fiat currency."
          }
        ],
        "responses": {
          "200": {
            "description": "Chart image",
            "content": {
              "image/svg+xml": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "No data recorded for this fiat or month."
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "DailyRow": {
        "type": "object",
        "properties": {
          "date": {
            "type": "string",
            "format": "date",
            "description": "UTC calendar day (YYYY-MM-DD)."
          },
          "fiat": {
            "type": "string",
            "example": "VES",
            "description": "ISO 4217 code of the fiat currency."
          },
          "side": {
            "type": "string",
            "enum": [
              "buy",
              "sell"
            ],
            "description": "buy = ads where users buy USDT; sell = ads where users sell USDT."
          },
          "exchange": {
            "type": "string",
            "enum": [
              "binance",
              "okx",
              "bithumb"
            ],
            "description": "binance or okx (P2P ads), or bithumb (Bithumb Spot, KRW only)."
          },
          "samples": {
            "type": "integer",
            "description": "30-minute samples recorded that day for this side and exchange."
          },
          "ok_samples": {
            "type": "integer",
            "description": "Samples that returned a valid premium, outliers not counted."
          },
          "premium_avg_pct": {
            "type": "number",
            "nullable": true,
            "description": "Mean premium (highest of the first 5 ads) of the successful samples, outliers excluded, in percent."
          },
          "premium_min_pct": {
            "type": "number",
            "nullable": true,
            "description": "Lowest premium of the day, outliers excluded, in percent."
          },
          "premium_max_pct": {
            "type": "number",
            "nullable": true,
            "description": "Highest premium of the day, outliers excluded, in percent."
          },
          "premium_close_pct": {
            "type": "number",
            "nullable": true,
            "description": "Premium of the day's last successful sample that is not an outlier, in percent."
          },
          "median_price": {
            "type": "number",
            "nullable": true,
            "description": "Mean of the per-sample median prices (median of up to 10 ads), in fiat per USDT, outliers excluded (newer samples only)."
          },
          "median_premium_pct": {
            "type": "number",
            "nullable": true,
            "description": "Mean premium of the median price (median of up to 10 ads) vs the FX reference, in percent, outliers excluded (newer samples only)."
          },
          "top_price": {
            "type": "number",
            "nullable": true,
            "description": "Mean price of the first-ranked ad, in fiat per USDT, outliers excluded (newer samples only)."
          },
          "fx_reference": {
            "type": "number",
            "nullable": true,
            "description": "Mean FX reference rate of the day, in fiat per USD (newer samples only)."
          },
          "outlier_samples": {
            "type": "integer",
            "description": "Samples flagged as outliers on the long-term or the median premium and left out of the matching statistics in this row (see the methodology); they stay in the 30-minute files with outlier=true."
          }
        }
      },
      "SampleRow": {
        "type": "object",
        "properties": {
          "slot_utc": {
            "type": "string",
            "example": "2026-10-01T12:30",
            "description": "30-minute UTC slot (YYYY-MM-DDTHH:MM)."
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "description": "Exact time the sample was taken (ISO 8601, UTC)."
          },
          "fiat": {
            "type": "string",
            "example": "VES",
            "description": "ISO 4217 code of the fiat currency."
          },
          "side": {
            "type": "string",
            "enum": [
              "buy",
              "sell"
            ],
            "description": "buy = ads where users buy USDT; sell = ads where users sell USDT."
          },
          "exchange": {
            "type": "string",
            "enum": [
              "binance",
              "okx",
              "bithumb"
            ],
            "description": "binance or okx (P2P ads), or bithumb (Bithumb Spot, KRW only)."
          },
          "status": {
            "type": "string",
            "description": "ok, or why no valid quote was recorded (for example empty or error)."
          },
          "premium_pct": {
            "type": "number",
            "nullable": true,
            "description": "Highest premium among the first five ads vs the FX reference, in percent."
          },
          "top_price": {
            "type": "number",
            "nullable": true,
            "description": "Price of the first-ranked ad, in fiat per USDT."
          },
          "median_price": {
            "type": "number",
            "nullable": true,
            "description": "Median price of up to 10 sampled ads, in fiat per USDT."
          },
          "average_price": {
            "type": "number",
            "nullable": true,
            "description": "Mean price of the sampled ads, in fiat per USDT."
          },
          "median_premium_pct": {
            "type": "number",
            "nullable": true,
            "description": "Premium of the median price (median of up to 10 ads) vs the FX reference, in percent."
          },
          "sampled_ads": {
            "type": "integer",
            "nullable": true,
            "description": "Number of ads in the sample: up to 10 per side; the earliest samples with this field used 5."
          },
          "fx_reference": {
            "type": "number",
            "nullable": true,
            "description": "FX reference rate used, in fiat per USD."
          },
          "fx_source": {
            "type": "string",
            "nullable": true,
            "description": "Provider of the FX reference, when recorded."
          },
          "origin": {
            "type": "string",
            "enum": [
              "live",
              "legacy"
            ],
            "description": "live = recorded by the archive; legacy = imported from the earlier 30-minute history store."
          },
          "outlier": {
            "type": "string",
            "enum": [
              "true",
              ""
            ],
            "description": "true when the sample's long-term or median premium is flagged as an outlier and left out of the matching daily statistics; empty otherwise."
          }
        }
      },
      "Catalog": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "license": {
            "type": "string"
          },
          "licenseUrl": {
            "type": "string"
          },
          "generatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "datasets": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "fiat": {
                  "type": "string"
                },
                "country": {
                  "type": "string"
                },
                "exchanges": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "from": {
                  "type": "string",
                  "format": "date"
                },
                "to": {
                  "type": "string",
                  "format": "date"
                },
                "days": {
                  "type": "integer"
                },
                "samples": {
                  "type": "integer"
                },
                "historyPage": {
                  "type": "string"
                },
                "daily": {
                  "type": "object",
                  "properties": {
                    "csv": {
                      "type": "string"
                    },
                    "json": {
                      "type": "string"
                    }
                  }
                },
                "months": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "month": {
                        "type": "string"
                      },
                      "csv": {
                        "type": "string"
                      },
                      "json": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}