{
  "openapi": "3.1.0",
  "info": {
    "title": "The BTC Portal public API",
    "version": "1.0.0",
    "summary": "Euro-denominated crypto prices and newsletter signup for the European edition.",
    "description": "Read-only market data and one write endpoint, served by The BTC Portal,\na European crypto and digital-asset news publication.\n\nAll monetary values are in euros (EUR). No API key is required for the\nread endpoints and there is no per-caller quota beyond ordinary rate\nlimiting; responses are cached at the edge, so a polling client should\nnot query prices more than once per minute.\n\nEditorial content is not exposed through this API. Articles are\npublished as HTML pages, as RSS at /feed/{locale}, as Markdown through\nAccept-header content negotiation on any article URL, and are indexed\nin /sitemap.xml and /llms.txt.",
    "contact": {
      "name": "The BTC Portal newsroom",
      "url": "https://thebtcportal.com/en/developers"
    },
    "license": {
      "name": "Data provided as-is, for informational purposes only. Not investment advice.",
      "url": "https://thebtcportal.com/en/privacy"
    }
  },
  "servers": [
    {
      "url": "https://thebtcportal.com",
      "description": "Production"
    }
  ],
  "tags": [
    {
      "name": "market-data",
      "description": "Crypto prices in euros."
    },
    {
      "name": "newsletter",
      "description": "Email subscription for the newsletter."
    }
  ],
  "paths": {
    "/api/prices": {
      "get": {
        "operationId": "listPrices",
        "tags": [
          "market-data"
        ],
        "summary": "List current crypto prices in euros",
        "description": "Returns up to 100 crypto assets priced in EUR, ordered by market\nrelevance (the same order used by the site's ticker and price\ntable). Includes the 24-hour percentage change and a 7-point daily\nseries suitable for a sparkline.\n\nUse this when a user asks for the current euro price of a crypto\nasset, or to compare several assets in euros. Values are refreshed\nat most once per minute; do not poll faster.",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Current prices.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PriceList"
                }
              }
            }
          }
        }
      }
    },
    "/api/history": {
      "get": {
        "operationId": "getHistoricalPrice",
        "tags": [
          "market-data"
        ],
        "summary": "Get the bitcoin closing price in euros for one date",
        "description": "Returns the BTC/EUR daily close for a single calendar date, taken\nfrom European exchange daily candles.\nThe series starts on 2020-01-01; earlier dates are\nrejected rather than approximated.\n\nUse this to answer 'what would X euros invested in bitcoin on DATE\nbe worth today', combined with listPrices for the current price.",
        "parameters": [
          {
            "name": "date",
            "in": "query",
            "required": true,
            "description": "Calendar date in ISO format (YYYY-MM-DD), from 2020-01-01 up to today, interpreted in UTC.",
            "schema": {
              "type": "string",
              "format": "date",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "examples": [
                "2021-11-09"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Closing price for the requested date.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HistoricalPrice"
                }
              }
            }
          },
          "400": {
            "description": "Missing, malformed, future, or pre-series date. `code` is one of `missing_date`, `invalid_date`, `date_out_of_range`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "No upstream source returned a price for that date.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/subscribe": {
      "post": {
        "operationId": "subscribeToNewsletter",
        "tags": [
          "newsletter"
        ],
        "summary": "Subscribe an email address to the newsletter",
        "description": "Registers an email address for the newsletter of one language\nedition. Idempotent: subscribing an address that is already on the\nlist succeeds without creating a duplicate.\n\nOnly call this on the explicit request of the person who owns the\naddress. Consent is recorded with the request (source page, consent\nversion, timestamp), so a subscription made without the reader\nasking for it is a false consent record, not just spam.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubscribeRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Subscription accepted (or already present).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubscribeResponse"
                }
              }
            }
          },
          "400": {
            "description": "Body is not valid JSON or carries no email. `code` is `invalid_body` or `missing_email`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded for the caller's network address.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "The subscription could not be stored.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Subscription collection is disabled on this deployment.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error",
          "code",
          "message",
          "hint",
          "status"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Stable error code. Same value as `code`; kept for backwards compatibility."
          },
          "code": {
            "type": "string",
            "description": "Stable, machine-readable error code in snake_case."
          },
          "message": {
            "type": "string",
            "description": "Human-readable description of what went wrong."
          },
          "hint": {
            "type": "string",
            "description": "What the caller should do next to recover."
          },
          "status": {
            "type": "integer",
            "description": "HTTP status code, repeated in the body."
          },
          "docs": {
            "type": "string",
            "format": "uri",
            "description": "URL of this specification."
          }
        }
      },
      "Coin": {
        "type": "object",
        "required": [
          "symbol",
          "name",
          "eur",
          "change24h",
          "series7d",
          "provider"
        ],
        "properties": {
          "symbol": {
            "type": "string",
            "description": "Ticker in uppercase.",
            "examples": [
              "BTC"
            ]
          },
          "name": {
            "type": "string",
            "description": "Display name.",
            "examples": [
              "Bitcoin"
            ]
          },
          "eur": {
            "type": "number",
            "description": "Current price in euros."
          },
          "change24h": {
            "type": [
              "number",
              "null"
            ],
            "description": "Percentage change over the last 24 hours; null when unknown."
          },
          "series7d": {
            "type": "array",
            "items": {
              "type": "number"
            },
            "description": "Daily closing prices in euros for the last 7 days, oldest first."
          },
          "provider": {
            "type": "string",
            "enum": [
              "mb-europe",
              "coingecko"
            ],
            "description": "Upstream that supplied this quote."
          }
        }
      },
      "PriceList": {
        "type": "object",
        "required": [
          "currency",
          "count",
          "prices"
        ],
        "properties": {
          "currency": {
            "type": "string",
            "enum": [
              "EUR"
            ],
            "description": "Currency of every price."
          },
          "count": {
            "type": "integer",
            "description": "Number of assets available upstream."
          },
          "prices": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/Coin"
            }
          }
        }
      },
      "HistoricalPrice": {
        "type": "object",
        "required": [
          "date",
          "eur",
          "source"
        ],
        "properties": {
          "date": {
            "type": "string",
            "format": "date",
            "description": "Date that was queried."
          },
          "eur": {
            "type": "number",
            "description": "BTC closing price in euros on that date."
          },
          "source": {
            "type": "string",
            "example": "btc-history",
            "description": "Identifier of the upstream chain that supplied the close."
          }
        }
      },
      "SubscribeRequest": {
        "type": "object",
        "required": [
          "email"
        ],
        "properties": {
          "email": {
            "type": "string",
            "format": "email",
            "maxLength": 320,
            "description": "Email address of the person who asked to subscribe."
          },
          "locale": {
            "type": "string",
            "enum": [
              "en",
              "pt",
              "es"
            ],
            "description": "Language edition to subscribe to. Defaults to `en`."
          },
          "sourceUrl": {
            "type": "string",
            "maxLength": 500,
            "description": "Page the subscription was made from; stored as proof of consent."
          },
          "website": {
            "type": "string",
            "description": "Honeypot field. Leave absent or empty; a filled value is treated as automated abuse."
          }
        }
      },
      "SubscribeResponse": {
        "type": "object",
        "required": [
          "ok"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "enum": [
              true
            ]
          }
        }
      }
    }
  },
  "externalDocs": {
    "description": "Developer overview, editorial policy and machine-readable entry points.",
    "url": "https://thebtcportal.com/en/developers"
  }
}