{
  "openapi": "3.1.0",
  "info": {
    "title": "Stock Market Mock API",
    "version": "1.0",
    "description": "Deterministic quotes and daily OHLCV candles for fictional tickers in USD, New York market hours, batch quotes and a 5-per-minute history limit that answers 429 with Retry-After. Not market data."
  },
  "servers": [
    {
      "url": "https://funapi.dev/api/stocks/v1"
    }
  ],
  "tags": [
    {
      "name": "reference",
      "description": "symbols and hours"
    },
    {
      "name": "quotes",
      "description": "latest prices"
    },
    {
      "name": "history",
      "description": "daily candles"
    }
  ],
  "paths": {
    "/symbols": {
      "get": {
        "tags": [
          "reference"
        ],
        "summary": "Fictional tickers you can query",
        "operationId": "sk-symbols",
        "responses": {
          "200": {
            "description": "Symbols",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "symbol": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "sector": {
                            "type": "string"
                          },
                          "exchange": {
                            "type": "string"
                          },
                          "currency": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "note": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/market-status": {
      "get": {
        "tags": [
          "reference"
        ],
        "summary": "Open or closed, by New York trading hours",
        "operationId": "sk-market",
        "responses": {
          "200": {
            "description": "Market status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "asOf": {
                      "type": "string"
                    },
                    "open": {
                      "type": "boolean"
                    },
                    "session": {
                      "type": "string"
                    },
                    "timeZone": {
                      "type": "string"
                    },
                    "regularHours": {
                      "type": "string"
                    },
                    "holidaysModelled": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/quote/{symbol}": {
      "get": {
        "tags": [
          "quotes"
        ],
        "summary": "Latest quote — deterministic per minute",
        "operationId": "sk-quote",
        "responses": {
          "200": {
            "description": "Quote",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "symbol": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "sector": {
                      "type": "string"
                    },
                    "currency": {
                      "type": "string"
                    },
                    "price": {
                      "type": "number"
                    },
                    "previousClose": {
                      "type": "number"
                    },
                    "change": {
                      "type": "number"
                    },
                    "changePercent": {
                      "type": "number"
                    },
                    "asOf": {
                      "type": "string"
                    },
                    "market": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Unknown symbol",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "symbol",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "ZBLU"
          }
        ]
      }
    },
    "/quotes": {
      "get": {
        "tags": [
          "quotes"
        ],
        "summary": "Batch quotes for up to 10 symbols",
        "operationId": "sk-quotes",
        "responses": {
          "200": {
            "description": "Quotes",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "symbol": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "sector": {
                            "type": "string"
                          },
                          "currency": {
                            "type": "string"
                          },
                          "price": {
                            "type": "number"
                          },
                          "previousClose": {
                            "type": "number"
                          },
                          "change": {
                            "type": "number"
                          },
                          "changePercent": {
                            "type": "number"
                          },
                          "asOf": {
                            "type": "string"
                          },
                          "market": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing, too many or unknown symbols",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "symbols",
            "in": "query",
            "required": true,
            "description": "Comma-separated, max 10",
            "schema": {
              "type": "string"
            },
            "example": "ZBLU,ZQAT"
          }
        ]
      }
    },
    "/history/{symbol}": {
      "get": {
        "tags": [
          "history"
        ],
        "summary": "Daily OHLCV candles — limited to 5 requests a minute, like a free tier",
        "operationId": "sk-history",
        "responses": {
          "200": {
            "description": "Candles",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "symbol": {
                      "type": "string"
                    },
                    "interval": {
                      "type": "string"
                    },
                    "currency": {
                      "type": "string"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "date": {
                            "type": "string"
                          },
                          "open": {
                            "type": "number"
                          },
                          "high": {
                            "type": "number"
                          },
                          "low": {
                            "type": "number"
                          },
                          "close": {
                            "type": "number"
                          },
                          "volume": {
                            "type": "number"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid days",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Unknown symbol",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "More than 5 a minute, with Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "symbol",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "ZBLU"
          },
          {
            "name": "days",
            "in": "query",
            "required": false,
            "description": "1–365, default 30",
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "example": 10
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Use qa-admin-token / qa-viewer-token, or a JWT from POST /auth/v1/login."
      },
      "apiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "Cargo demo key: cargo-key-123."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error",
          "message"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "requestId": {
            "type": "string"
          }
        },
        "additionalProperties": true
      }
    }
  }
}
