DataFlex
DataFlex
AbuseIPDB Check Endpoint
See more _Miscellaneous_ Examples
The check endpoint accepts a single IP address (v4 or v6). Optionally you may set the maxAgeInDays parameter to only return reports within the last x amount of days.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoHttp
Variant vReq
Handle hoReq
Variant vResp
Handle hoResp
Handle hoJResp
Integer iRespStatusCode
String sReportedAt
String sComment
Integer iReporterId
String sReporterCountryCode
String sReporterCountryName
Integer j
Integer iCount_j
Integer iIntVal
String sDataIpAddress
Boolean iDataIsPublic
Integer iDataIpVersion
Boolean iDataIsWhitelisted
Integer iDataAbuseConfidenceScore
String sDataCountryCode
String sDataUsageType
String sDataIsp
String sDataDomain
String sDataCountryName
Integer iDataTotalReports
Integer iDataNumDistinctUsers
String sDataLastReportedAt
Integer i
Integer iCount_i
String sTemp1
Move False To iSuccess
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
// Implements the following CURL command:
// curl -G https://api.abuseipdb.com/api/v2/check \
// --data-urlencode "ipAddress=118.25.6.39" \
// -d maxAgeInDays=90 \
// -d verbose \
// -H "Key: $YOUR_API_KEY" \
// -H "Accept: application/json"
// Use the following online tool to generate HTTP code from a CURL command
// Convert a cURL Command to HTTP Source Code
Get Create (RefClass(cComChilkatHttpRequest)) To hoReq
If (Not(IsComObjectCreated(hoReq))) Begin
Send CreateComObject of hoReq
End
Set ComHttpVerb Of hoReq To "GET"
Set ComPath Of hoReq To "/api/v2/check"
Set ComContentType Of hoReq To "application/x-www-form-urlencoded"
Send ComAddParam To hoReq "maxAgeInDays" "90"
Send ComAddParam To hoReq "verbose" ""
Send ComAddParam To hoReq "ipAddress" "118.25.6.39"
Send ComAddHeader To hoReq "Key" "$YOUR_API_KEY"
Send ComAddHeader To hoReq "Accept" "application/json"
Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
If (Not(IsComObjectCreated(hoResp))) Begin
Send CreateComObject of hoResp
End
Get pvComObject of hoReq to vReq
Get pvComObject of hoResp to vResp
Get ComHttpSReq Of hoHttp "api.abuseipdb.com" 443 True vReq vResp To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoHttp To sTemp1
Showln sTemp1
Procedure_Return
End
Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
If (Not(IsComObjectCreated(hoJResp))) Begin
Send CreateComObject of hoJResp
End
Get ComBodyStr Of hoResp To sTemp1
Get ComLoad Of hoJResp sTemp1 To iSuccess
Set ComEmitCompact Of hoJResp To False
Showln "Response Body:"
Get ComEmit Of hoJResp To sTemp1
Showln sTemp1
Get ComStatusCode Of hoResp To iRespStatusCode
Showln "Response Status Code = " iRespStatusCode
If (iRespStatusCode >= 400) Begin
Showln "Response Header:"
Get ComHeader Of hoResp To sTemp1
Showln sTemp1
Showln "Failed."
Procedure_Return
End
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "data": {
// "ipAddress": "118.25.6.39",
// "isPublic": true,
// "ipVersion": 4,
// "isWhitelisted": false,
// "abuseConfidenceScore": 1,
// "countryCode": "CN",
// "usageType": "Data Center\/Web Hosting\/Transit",
// "isp": "Tencent Cloud Computing (Beijing) Co. Ltd",
// "domain": "tencent.com",
// "hostnames": [
// ],
// "countryName": "China",
// "totalReports": 2,
// "numDistinctUsers": 1,
// "lastReportedAt": "2021-04-03T18:55:00+00:00",
// "reports": [
// {
// "reportedAt": "2021-03-10T10:07:53+00:00",
// "comment": "SSH login attempts with user root.",
// "categories": [
// 18,
// 22
// ],
// "reporterId": 54484,
// "reporterCountryCode": "CN",
// "reporterCountryName": "China"
// },
// {
// "reportedAt": "2021-03-09T09:47:57+00:00",
// "comment": "SSH login attempts with user root.",
// "categories": [
// 18,
// 22
// ],
// "reporterId": 54484,
// "reporterCountryCode": "CN",
// "reporterCountryName": "China"
// }
// ]
// }
// }
// Sample code for parsing the JSON response...
// Use the following online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
Get ComStringOf Of hoJResp "data.ipAddress" To sDataIpAddress
Get ComBoolOf Of hoJResp "data.isPublic" To iDataIsPublic
Get ComIntOf Of hoJResp "data.ipVersion" To iDataIpVersion
Get ComBoolOf Of hoJResp "data.isWhitelisted" To iDataIsWhitelisted
Get ComIntOf Of hoJResp "data.abuseConfidenceScore" To iDataAbuseConfidenceScore
Get ComStringOf Of hoJResp "data.countryCode" To sDataCountryCode
Get ComStringOf Of hoJResp "data.usageType" To sDataUsageType
Get ComStringOf Of hoJResp "data.isp" To sDataIsp
Get ComStringOf Of hoJResp "data.domain" To sDataDomain
Get ComStringOf Of hoJResp "data.countryName" To sDataCountryName
Get ComIntOf Of hoJResp "data.totalReports" To iDataTotalReports
Get ComIntOf Of hoJResp "data.numDistinctUsers" To iDataNumDistinctUsers
Get ComStringOf Of hoJResp "data.lastReportedAt" To sDataLastReportedAt
Move 0 To i
Get ComSizeOfArray Of hoJResp "data.hostnames" To iCount_i
While (i < iCount_i)
Set ComI Of hoJResp To i
Move (i + 1) To i
Loop
Move 0 To i
Get ComSizeOfArray Of hoJResp "data.reports" To iCount_i
While (i < iCount_i)
Set ComI Of hoJResp To i
Get ComStringOf Of hoJResp "data.reports[i].reportedAt" To sReportedAt
Get ComStringOf Of hoJResp "data.reports[i].comment" To sComment
Get ComIntOf Of hoJResp "data.reports[i].reporterId" To iReporterId
Get ComStringOf Of hoJResp "data.reports[i].reporterCountryCode" To sReporterCountryCode
Get ComStringOf Of hoJResp "data.reports[i].reporterCountryName" To sReporterCountryName
Move 0 To j
Get ComSizeOfArray Of hoJResp "data.reports[i].categories" To iCount_j
While (j < iCount_j)
Set ComJ Of hoJResp To j
Get ComIntOf Of hoJResp "data.reports[i].categories[j]" To iIntVal
Move (j + 1) To j
Loop
Move (i + 1) To i
Loop
End_Procedure