Chilkat Examples

ChilkatHOMEAndroid™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi DLLGoJavaJavaScriptNode.jsObjective-CPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwiftTclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

Visual Basic 6.0 Examples
Web API Categories

AI
ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Box
CAdES
CSR
CSV
Cert Store
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP
HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
JavaScript
MHT / HTML Email
MIME
Markdown
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
Regular Expressions
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
Secrets
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
X
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(Visual Basic 6.0) Finnhub API - Get Stock Quote

See more AI Examples
Demonstrates how to get a stock quote from the Finnhub API.

Note: This example requires Chilkat v11.4.0 or greater.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Dim success As Long
success = 0

' Replace with your actual Finnhub API key.
Dim apiKey As String
apiKey = "YOUR_FINNHUB_API_KEY"
Dim symbol As String
symbol = "AAPL"

Dim http As New ChilkatHttp

' This is the URL without params.
Dim urlWithoutParams As String
urlWithoutParams = "https://finnhub.io/api/v1/quote"

Dim req As New ChilkatHttpRequest

' Add params that will be sent in the URL.
req.AddParam "symbol",symbol
req.AddParam "token",apiKey

req.HttpVerb = "GET"

' Send the request to get the JSON response.
Dim resp As New ChilkatHttpResponse
success = http.HttpReq(urlWithoutParams,req,resp)
If (success = 0) Then
    Debug.Print http.LastErrorText
    Exit Sub
End If

Dim json As New ChilkatJsonObject
success = resp.GetBodyJson(json)

Dim statusCode As Long
statusCode = resp.StatusCode
Debug.Print "response status code: " & statusCode

json.EmitCompact = 0
Debug.Print json.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 (statusCode = 200) Then
    ' Add the symbol to the top of the result.
    success = json.AddStringAt(0,"symbol",symbol)

    ' Rename members for clarification.
    success = json.Rename("c","currentPrice")
    success = json.Rename("d","change")
    success = json.Rename("dp","percentChange")
    success = json.Rename("h","high")
    success = json.Rename("l","low")
    success = json.Rename("o","open")
    success = json.Rename("pc","prevClose")
    success = json.Rename("t","unixTime")

    Debug.Print json.Emit()

Else
    Debug.Print "Failed"
End If


 

© 2000-2026 Chilkat Software, Inc. All Rights Reserved.