![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java JavaScript Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Lianja) Finnhub API - Get Stock QuoteSee more AI ExamplesDemonstrates how to get a stock quote from the Finnhub API.Note: This example requires Chilkat v11.4.0 or greater.
llSuccess = .F. // Replace with your actual Finnhub API key. lcApiKey = "YOUR_FINNHUB_API_KEY" lcSymbol = "AAPL" loHttp = createobject("CkHttp") // This is the URL without params. lcUrlWithoutParams = "https://finnhub.io/api/v1/quote" loReq = createobject("CkHttpRequest") // Add params that will be sent in the URL. loReq.AddParam("symbol",lcSymbol) loReq.AddParam("token",lcApiKey) loReq.HttpVerb = "GET" // Send the request to get the JSON response. loResp = createobject("CkHttpResponse") llSuccess = loHttp.HttpReq(lcUrlWithoutParams,loReq,loResp) if (llSuccess = .F.) then ? loHttp.LastErrorText release loHttp release loReq release loResp return endif loJson = createobject("CkJsonObject") loResp.GetBodyJson(loJson) lnStatusCode = loResp.StatusCode ? "response status code: " + str(lnStatusCode) loJson.EmitCompact = .F. ? loJson.Emit() // Sample result: // { // "c": 248.8, // "d": -4.09, // "dp": -1.6173, // "h": 255.493, // "l": 248.07, // "o": 253.9, // "pc": 252.89, // "t": 1774641600 // } if (lnStatusCode = 200) then // Add the symbol to the top of the result. loJson.AddStringAt(0,"symbol",lcSymbol) // Rename members for clarification. loJson.Rename("c","currentPrice") loJson.Rename("d","change") loJson.Rename("dp","percentChange") loJson.Rename("h","high") loJson.Rename("l","low") loJson.Rename("o","open") loJson.Rename("pc","prevClose") loJson.Rename("t","unixTime") ? loJson.Emit() else ? "Failed" endif release loHttp release loReq release loResp release loJson |
||||
© 2000-2026 Chilkat Software, Inc. All Rights Reserved.