{
  "openapi": "3.1.0",
  "info": {
    "title": "EGX Live Real-Time Market Data API",
    "description": "High-performance, institutional-grade real-time market data feed for the Egyptian Exchange (EGX). Provides live quotes, Level 2 order book depth (5-level & 40-level queues), market movers, indices, and comprehensive company profiles.",
    "version": "2.0.0",
    "contact": {
      "name": "EGX.news Developer Support",
      "url": "https://egx.news/en/our-data",
      "email": "support@egx.news"
    }
  },
  "servers": [
    {
      "url": "https://egx-live.p.rapidapi.com",
      "description": "Official RapidAPI Production Gateway"
    }
  ],
  "security": [
    {
      "RapidAPIKey": [],
      "RapidAPIHost": []
    }
  ],
  "paths": {
    "/symbols": {
      "get": {
        "summary": "List all listed EGX securities",
        "description": "Returns the complete catalog of active EGX-listed equities, tickers, ISIN codes, sector classifications, and English/Arabic company names.",
        "operationId": "getSymbols",
        "responses": {
          "200": {
            "description": "Full directory of listed symbols",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": { "type": "integer", "example": 240 },
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "symbol": { "type": "string", "example": "COMI" },
                          "nameEn": { "type": "string", "example": "Commercial International Bank (Egypt)" },
                          "nameAr": { "type": "string", "example": "البنك التجاري الدولي - مصر" },
                          "isin": { "type": "string", "example": "EGS60121C018" },
                          "sector": { "type": "string", "example": "Banks" }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/price/{symbol}": {
      "get": {
        "summary": "Get real-time stock quote",
        "description": "Fetches tick-by-tick real-time quote data including latest execution price, bid/ask, percentage change, day open/high/low, session volume, and value traded.",
        "operationId": "getPrice",
        "parameters": [
          {
            "name": "symbol",
            "in": "path",
            "required": true,
            "description": "Stock ticker symbol (e.g. COMI, EAST, SWDY)",
            "schema": { "type": "string", "example": "COMI" }
          }
        ],
        "responses": {
          "200": {
            "description": "Real-time stock price payload",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "symbol": { "type": "string", "example": "COMI" },
                    "price": { "type": "number", "example": 84.50 },
                    "change": { "type": "number", "example": 1.25 },
                    "changePercent": { "type": "number", "example": 1.50 },
                    "open": { "type": "number", "example": 83.25 },
                    "high": { "type": "number", "example": 85.00 },
                    "low": { "type": "number", "example": 83.00 },
                    "volume": { "type": "integer", "example": 3200150 },
                    "turnover": { "type": "number", "example": 270412675.00 },
                    "bid": { "type": "number", "example": 84.45 },
                    "ask": { "type": "number", "example": 84.50 },
                    "lastTradeTime": { "type": "string", "example": "14:28:15" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/depth_5/{symbol}": {
      "get": {
        "summary": "Get 5-level order book depth",
        "description": "Returns top 5 queued bid and ask price levels with aggregated order volumes.",
        "operationId": "getDepth5",
        "parameters": [
          {
            "name": "symbol",
            "in": "path",
            "required": true,
            "description": "Stock ticker symbol",
            "schema": { "type": "string", "example": "COMI" }
          }
        ],
        "responses": {
          "200": {
            "description": "Top 5 order book queues",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "symbol": { "type": "string", "example": "COMI" },
                    "bids": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "level": { "type": "integer" },
                          "price": { "type": "number" },
                          "volume": { "type": "integer" },
                          "orders": { "type": "integer" }
                        }
                      }
                    },
                    "asks": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "level": { "type": "integer" },
                          "price": { "type": "number" },
                          "volume": { "type": "integer" },
                          "orders": { "type": "integer" }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/depth_40/{symbol}": {
      "get": {
        "summary": "Get 40-level deep order book depth",
        "description": "Returns comprehensive institutional 40-level cumulative Level 2 order book for institutional liquidity analysis.",
        "operationId": "getDepth40",
        "parameters": [
          {
            "name": "symbol",
            "in": "path",
            "required": true,
            "description": "Stock ticker symbol",
            "schema": { "type": "string", "example": "COMI" }
          }
        ],
        "responses": {
          "200": {
            "description": "Full 40-level order depth",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "symbol": { "type": "string" },
                    "bids": { "type": "array", "items": { "type": "object" } },
                    "asks": { "type": "array", "items": { "type": "object" } }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/stock/{symbol}": {
      "get": {
        "summary": "Unified stock bundle (Profile + Quote + 40-Depth)",
        "description": "Comprehensive unified stock bundle containing fundamental profile, real-time quote, session metrics, and full 40-depth order queues in a single low-latency call.",
        "operationId": "getStockBundle",
        "parameters": [
          {
            "name": "symbol",
            "in": "path",
            "required": true,
            "description": "Stock ticker symbol",
            "schema": { "type": "string", "example": "COMI" }
          }
        ],
        "responses": {
          "200": {
            "description": "Unified stock bundle",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "symbol": { "type": "string" },
                    "profile": { "type": "object" },
                    "quote": { "type": "object" },
                    "depth": { "type": "object" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/summary": {
      "get": {
        "summary": "Market-wide summary and indices",
        "description": "Snapshot of total market session turnover, aggregate shares traded, total transactions, and benchmark indices (EGX 30, EGX 70, EGX 100).",
        "operationId": "getMarketSummary",
        "responses": {
          "200": {
            "description": "Market summary payload",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "marketStatus": { "type": "string", "example": "OPEN" },
                    "turnoverEgp": { "type": "number", "example": 4512300000.00 },
                    "volumeShares": { "type": "integer", "example": 890120400 },
                    "tradesCount": { "type": "integer", "example": 105430 },
                    "egx30": {
                      "type": "object",
                      "properties": {
                        "value": { "type": "number", "example": 31450.25 },
                        "change": { "type": "number", "example": 185.30 },
                        "changePercent": { "type": "number", "example": 0.59 }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/movers": {
      "get": {
        "summary": "Top market movers (gainers, losers, active)",
        "description": "Real-time ranking of top 10 gaining stocks, top 10 losing stocks, and highest turnover stocks.",
        "operationId": "getTopMovers",
        "responses": {
          "200": {
            "description": "Ranked market movers",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "gainers": { "type": "array", "items": { "type": "object" } },
                    "losers": { "type": "array", "items": { "type": "object" } },
                    "mostActiveByValue": { "type": "array", "items": { "type": "object" } },
                    "mostActiveByVolume": { "type": "array", "items": { "type": "object" } }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "RapidAPIKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-RapidAPI-Key",
        "description": "Your RapidAPI Developer API Key. Obtainable instantly at https://rapidapi.com/manwilbahaa/api/egx-live"
      },
      "RapidAPIHost": {
        "type": "apiKey",
        "in": "header",
        "name": "X-RapidAPI-Host",
        "description": "RapidAPI Gateway Host: egx-live.p.rapidapi.com"
      }
    }
  }
}
