GetExchanges
Retrieve a list of stock and ETF exchanges from Twelve Data, filterable by asset type, country, or market code to identify trading venues.
Instructions
This API call returns an array of stock or ETF exchanges available at Twelve Data API. This list is updated daily.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| params | Yes |
Implementation Reference
- The core execution logic for all endpoint tools, including GetExchanges. It resolves path params, adds API key, makes HTTP GET to https://api.twelvedata.com/{endpoint} ("/exchanges" for GetExchanges), parses JSON, and validates with Pydantic response model.
async def _call_endpoint( endpoint: str, params: P, response_model: Type[R], ctx: Context ) -> R: params.apikey = extract_twelve_data_apikey( twelve_data_apikey=twelve_data_apikey, transport=transport, ctx=ctx ) params_dict = params.model_dump(exclude_none=True) resolved_endpoint = resolve_path_params(endpoint, params_dict) async with httpx.AsyncClient( trust_env=False, headers={ "accept": "application/json", "user-agent": "python-httpx/0.24.0" }, ) as client: resp = await client.get( f"{api_base}/{resolved_endpoint}", params=params_dict ) resp.raise_for_status() resp_json = resp.json() if isinstance(resp_json, dict): status = resp_json.get("status") if status == "error": code = resp_json.get('code') raise HTTPException( status_code=code, detail=f"Failed to perform request," f" code = {code}, message = {resp_json.get('message')}" ) return response_model.model_validate(resp_json) - src/mcp_server_twelve_data/server.py:87-89 (registration)Registers all tools (including GetExchanges) using register_all_tools when vector DB exists, before registering u_tool and doc_tool.
if vector_db_exists(): register_all_tools(server=server, _call_endpoint=_call_endpoint) u_tool = register_u_tool( - src/mcp_server_twelve_data/server.py:124-124 (registration)Registers all tools (including GetExchanges) and limits to first N tools when no u_tool OpenAI config.
register_all_tools(server=server, _call_endpoint=_call_endpoint) - Extracts and injects the Twelve Data API key into params for authentication.
params.apikey = extract_twelve_data_apikey( twelve_data_apikey=twelve_data_apikey, transport=transport, ctx=ctx )