Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

DataFlex Examples

Web API Categories

ASN.1
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
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)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
NTLM
OAuth1
OAuth2
Office365
OneDrive
OpenSSL
Outlook
PEM
PFX/P12
POP3
PRNG
REST
REST Misc
RSA
SCP
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
SharePoint
Socket/SSL/TLS
Spider
Stream
Tar Archive
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl

 

 

 

(DataFlex) UK Vehicle Data VRM Lookup

Demonstrates how to query the UK Vehicle Data VRM online API's. (See https://ukvehicledata.co.uk/)

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoRest
    Boolean iBAutoReconnect
    Boolean iSuccess
    String sJsonResponseStr
    Handle hoJson
    Integer iNumBatteries
    Integer i
    String sTemp1
    Integer iTemp1
    Boolean bTemp1

    //  This example requires the Chilkat API to have been previously unlocked.
    //  See Global Unlock Sample for sample code.

    Get Create (RefClass(cComChilkatRest)) To hoRest
    If (Not(IsComObjectCreated(hoRest))) Begin
        Send CreateComObject of hoRest
    End

    //  Connect using TLS.
    Move True To iBAutoReconnect
    Get ComConnect Of hoRest "uk1.ukvehicledata.co.uk" 443 True iBAutoReconnect To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    //  Replace UKVD-API-KEY with your actual API KEY,
    //  which looks something like "abcdb1234-0abc-1235-abcf-1234c3d1abcd"
    Set ComAuthorization Of hoRest To "ukvd-ipwhitelist UKVD-API-KEY"

    //  Replace "ABCDE" with a real VRM...
    Get ComAddQueryParam Of hoRest "key_vrm" "ABCDE" To iSuccess

    //  Add the Content-Type HTTP request header.
    // success = rest.AddHeader("Content-Type","application/json; charset=UTF-8");

    //  This request gets vehicle data.
    //  See below for a request to get battery data.
    Get ComFullRequestNoBody Of hoRest "GET" "/api/datapackage/vehicledata" To sJsonResponseStr
    Get ComLastMethodSuccess Of hoRest To bTemp1
    If (bTemp1 <> True) Begin
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComResponseStatusCode Of hoRest To iTemp1
    If (iTemp1 <> 200) Begin
        Get ComResponseStatusCode Of hoRest To iTemp1
        Showln "Response Status Code = " iTemp1
        Showln sJsonResponseStr
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComLoad Of hoJson sJsonResponseStr To iSuccess
    Set ComEmitCompact Of hoJson To False

    //  Show the JSON response.
    Get ComEmit Of hoJson To sTemp1
    Showln sTemp1

    //  A sample vehicledata response will be as shown below.
    //  To get a few bits of data from the response:
    Get ComStringOf Of hoJson "RequestGuid" To sTemp1
    Showln "RequestGuid: " sTemp1
    Get ComStringOf Of hoJson "DataItems.EngineNumber" To sTemp1
    Showln "EngineNumber: " sTemp1
    Get ComStringOf Of hoJson "DataKeys.Vrm" To sTemp1
    Showln "Vrm: " sTemp1

    //  {
//   "RequestGuid": "xxxxxxxx-cc72-4b63-xxxxxxxxxxxx",
    //    "StatusCode": 0,
    //    "StatusMessage": "Success",
    //    "PackageId": "xxxxxxxx-a4bc-4a84-af22-xxxxxxxxxxxx",
    //    "PackageVersion": 1,
    //    "DataKeys": {
//     "Vrm": "ABCDE"
    //    },
    //    "DataItems": {
//     "DriveAxle": "4x2",
    //      "Exported": "False",
    //      "DriverSeatPosition": "RHD",
    //      "EngineNumber": "LN910940728622",
    //      "Class": "Sport",
    //      "ImportedNorthernIreland": "False",
    //      "HistoryPreviousKeeperAcquisitionDate": "2013-01-12",
    //      "RoadFundLicenseSixMonth": "?126.50",
    //      "EnginePowerBhp": "262",
    //      "SpecDateRangeFrom": "1987-10-01",
    //      "RegistrationDateUK": "1994-08-03",
    //      "SoundLevelDriveBy": "0",
    //      "RoadFundLicenseTwelveMonth": "?235.00",
    //      "RoadFundLicenseBand": "Not available",
    //      "Vrm": "J5YVK",
    //      "TrimCode": "BA",
    //      "Derivative": "S4",
    //      "EngineSizeCc": "2174",
    //      "EngineCylinderCount": "4",
    //      "HistoryLatestV5cIssueDate": "2015-05-12",
    //      "Category": "Car",
    //      "HistoryPreviousKeeperCount": "9",
    //      "ConditionScrapped": "False",
    //      "EngineValveCount": "16",
    //      "WeightUnladen": "0",
    //      "RoadFundLicenseRenewalDate": "2017-04-01",
    //      "Model": "Esprit",
    //      "SpecDateRangeTo": "2003-06-01",
    //      "RoadFundLicenseCurrentStatus": "Tax not due",
    //      "BuildYear": "1994",
    //      "BuildDate": "1994-12-31",
    //      "VinLast4": "1448",
    //      "GearCount": "5",
    //      "SeatCount": "2",
    //      "Make": "Lotus",
    //      "Vin": "SCC082910RHA61448",
    //      "ColourChangeCount": "0",
    //      "DriveType": "Rear Wheel Drive",
    //      "WeightGross": "0",
    //      "EngineCode": "N/A",
    //      "EnginePowerKw": "193",
    //      "SoundLevelEngineSpeed": "0",
    //      "ConditionUnscrapped": "False",
    //      "HistoryPreviousKeeperDisposalDate": "2014-04-26",
    //      "EngineAlignment": "Longitudinal",
    //      "Imported": "False",
    //      "BodyType": "Coupe",
    //      "EnginePosition": "Mid",
    //      "TransmissionType": "Manual",
    //      "WeightFullyLaden": "0",
    //      "SoundLevelStationary": "0",
    //      "FuelType": "Petrol",
    //      "Colour": "YELLOW",
    //      "EngineSizeLitre": "2.2",
    //      "RegistrationDate": "1994-08-03",
    //      "Co2Emissions": "000",
    //      "WeightMaxTowingUnbraked": "0",
    //      "HistoryCurrentKeeperAcquisitionDate": "2015-04-25",
    //      "WeightMaxTowingBraked": "0",
    //      "DoorCount": "2",
    //      "EngineCylinderConfig": "Inline",
    //      "EngineFuelDelivery": "Turbo Injection"
    //    }
    //  }

    //  -----------------------------------------------------------------------------------
    //  Now get battery data...
    Get ComFullRequestNoBody Of hoRest "GET" "/api/datapackage/batterydata" To sJsonResponseStr
    Get ComLastMethodSuccess Of hoRest To bTemp1
    If (bTemp1 <> True) Begin
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComResponseStatusCode Of hoRest To iTemp1
    If (iTemp1 <> 200) Begin
        Get ComResponseStatusCode Of hoRest To iTemp1
        Showln "Response Status Code = " iTemp1
        Showln sJsonResponseStr
        Procedure_Return
    End

    Get ComLoad Of hoJson sJsonResponseStr To iSuccess

    //  Show the JSON response containing battery data.
    Get ComEmit Of hoJson To sTemp1
    Showln sTemp1

    //  To get a few pieces of information out of the response...
    Get ComSizeOfArray Of hoJson "DataItems.BatteryList" To iNumBatteries
    Move 0 To i
    While (i < iNumBatteries)
        Set ComI Of hoJson To i
        Showln "---- Battery " i ":"
        Get ComStringOf Of hoJson "DataItems.BatteryList[I].Type" To sTemp1
        Showln "  Type = " sTemp1
        Get ComStringOf Of hoJson "DataItems.BatteryList[I].LayoutImage" To sTemp1
        Showln "  LayoutImage = " sTemp1
        Get ComStringOf Of hoJson "DataItems.BatteryList[I].TerminalCode" To sTemp1
        Showln "  TerminalCode = " sTemp1
        Move i + 1 To i
    Loop

    //  The battery data looks like this:
    //  {
//   "RequestGuid": "xxxxxxxx-5030-4b3d-a2ed-xxxxxxxxxxxx",
    //    "StatusCode": 0,
    //    "StatusMessage": "Success",
    //    "PackageId": "xxxxxxxx-9ec2-4fd3-9247-xxxxxxxxxxxx",
    //    "PackageVersion": 1,
    //    "DataKeys": {
//     "Vrm": "ABCDE"
    //    },
    //    "DataItems": {
//     "BatteryList": [
    //        {
//         "Type": "Primary",
    //          "UkRef": "075",
    //          "LayoutCode": "0",
    //          "LayoutImage": "http://cdn.ukvehicledata.co.uk/battery/layout/0.png",
    //          "TerminalCode": "T1",
    //          "TerminalImage": "http://cdn.ukvehicledata.co.uk/battery/terminal/T1.png",
    //          "HoldDownCode": "B13",
    //          "HoldDownImage": "http://cdn.ukvehicledata.co.uk/battery/holddown/B13.png"
    //        }
    //      ],
    //      "BatteryCount": "1"
    //    }
    //  }


End_Procedure

 

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