// Market Data API for Excel (Power Query), version 1.0.0. Two queries: latest prices and candles. // // 1. Put your API key in a cell and name it ApiKey (Formulas › Define Name). Use a key of its own for the workbook: // anyone with the file can read the key from that cell. // 2. Data › Get Data › From Other Sources › Blank Query › Advanced Editor › paste ONE of the queries below › Done. // When Excel asks how to connect, choose Anonymous (the key travels in the request, not as a login). // 3. Close & Load. Data › Refresh All fetches new data (each refresh uses credits like any other API call). // ---------------------------------------------------------------- query 1: latest prices // Tickers come from a table named Tickers with one column "Symbol" (Insert › Table, then name it Tickers). let ApiKey = Excel.CurrentWorkbook(){[Name = "ApiKey"]}[Content]{0}[Column1], Symbols = Text.Combine(List.Select(List.Transform(Excel.CurrentWorkbook(){[Name = "Tickers"]}[Content][Symbol], each Text.Trim(Text.From(_))), each _ <> ""), ","), Answer = Json.Document(Web.Contents("https://api.marketapi.app/v1", [RelativePath = "prices/latest", Query = [symbols = Symbols], Headers = [Authorization = "Bearer " & ApiKey, Accept = "application/json"]])), Table = Table.FromRecords(Answer[data], {"symbol", "bid", "ask", "last", "time", "status"}, MissingField.UseNull), Typed = Table.TransformColumnTypes(Table, {{"bid", type number}, {"ask", type number}, {"last", type number}, {"time", type datetimezone}}, "en-US") in Typed // ---------------------------------------------------------------- query 2: candles (every page) let ApiKey = Excel.CurrentWorkbook(){[Name = "ApiKey"]}[Content]{0}[Column1], Symbol = "EURUSD", Timeframe = "D1", From = "2026-01-01", To = "2026-03-31", GetPage = (cursor as nullable text) => let Q = [symbol = Symbol, timeframe = Timeframe, from = From & "T00:00:00Z", to = To & "T23:59:59Z", limit = "5000"], Q2 = if cursor = null then Q else Record.AddField(Q, "cursor", cursor) in Json.Document(Web.Contents("https://api.marketapi.app/v1", [RelativePath = "bars", Query = Q2, Headers = [Authorization = "Bearer " & ApiKey, Accept = "application/json"]])), Pages = List.Generate(() => GetPage(null), each _ <> null, each if Record.FieldOrDefault(_, "next_cursor", null) = null then null else GetPage(Record.Field(_, "next_cursor"))), Rows = List.Combine(List.Transform(Pages, each _[data])), Table = Table.FromRecords(Rows, {"time", "open", "high", "low", "close", "tick_volume"}, MissingField.UseNull), Typed = Table.TransformColumnTypes(Table, {{"time", type datetimezone}, {"open", type number}, {"high", type number}, {"low", type number}, {"close", type number}, {"tick_volume", Int64.Type}}, "en-US") in Typed