Sample code for 30+ languages & platforms
PowerBuilder

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 PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Http
oleobject loo_Req
oleobject loo_Resp
oleobject loo_JResp
integer li_RespStatusCode
string ls_ReportedAt
string ls_Comment
integer li_ReporterId
string ls_ReporterCountryCode
string ls_ReporterCountryName
integer j
integer li_Count_j
integer li_IntVal
string ls_DataIpAddress
integer li_DataIsPublic
integer li_DataIpVersion
integer li_DataIsWhitelisted
integer li_DataAbuseConfidenceScore
string ls_DataCountryCode
string ls_DataUsageType
string ls_DataIsp
string ls_DataDomain
string ls_DataCountryName
integer li_DataTotalReports
integer li_DataNumDistinctUsers
string ls_DataLastReportedAt
integer i
integer li_Count_i

li_Success = 0

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

loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

// 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

loo_Req = create oleobject
li_rc = loo_Req.ConnectToNewObject("Chilkat.HttpRequest")

loo_Req.HttpVerb = "GET"
loo_Req.Path = "/api/v2/check"
loo_Req.ContentType = "application/x-www-form-urlencoded"
loo_Req.AddParam("maxAgeInDays","90")
loo_Req.AddParam("verbose","")
loo_Req.AddParam("ipAddress","118.25.6.39")

loo_Req.AddHeader("Key","$YOUR_API_KEY")
loo_Req.AddHeader("Accept","application/json")

loo_Resp = create oleobject
li_rc = loo_Resp.ConnectToNewObject("Chilkat.HttpResponse")

li_Success = loo_Http.HttpSReq("api.abuseipdb.com",443,1,loo_Req,loo_Resp)
if li_Success = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_Req
    destroy loo_Resp
    return
end if

loo_JResp = create oleobject
li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject")

loo_JResp.Load(loo_Resp.BodyStr)
loo_JResp.EmitCompact = 0

Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()

li_RespStatusCode = loo_Resp.StatusCode
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Resp.Header
    Write-Debug "Failed."
    destroy loo_Http
    destroy loo_Req
    destroy loo_Resp
    destroy loo_JResp
    return
end if

// 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

ls_DataIpAddress = loo_JResp.StringOf("data.ipAddress")
li_DataIsPublic = loo_JResp.BoolOf("data.isPublic")
li_DataIpVersion = loo_JResp.IntOf("data.ipVersion")
li_DataIsWhitelisted = loo_JResp.BoolOf("data.isWhitelisted")
li_DataAbuseConfidenceScore = loo_JResp.IntOf("data.abuseConfidenceScore")
ls_DataCountryCode = loo_JResp.StringOf("data.countryCode")
ls_DataUsageType = loo_JResp.StringOf("data.usageType")
ls_DataIsp = loo_JResp.StringOf("data.isp")
ls_DataDomain = loo_JResp.StringOf("data.domain")
ls_DataCountryName = loo_JResp.StringOf("data.countryName")
li_DataTotalReports = loo_JResp.IntOf("data.totalReports")
li_DataNumDistinctUsers = loo_JResp.IntOf("data.numDistinctUsers")
ls_DataLastReportedAt = loo_JResp.StringOf("data.lastReportedAt")
i = 0
li_Count_i = loo_JResp.SizeOfArray("data.hostnames")
do while i < li_Count_i
    loo_JResp.I = i
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("data.reports")
do while i < li_Count_i
    loo_JResp.I = i
    ls_ReportedAt = loo_JResp.StringOf("data.reports[i].reportedAt")
    ls_Comment = loo_JResp.StringOf("data.reports[i].comment")
    li_ReporterId = loo_JResp.IntOf("data.reports[i].reporterId")
    ls_ReporterCountryCode = loo_JResp.StringOf("data.reports[i].reporterCountryCode")
    ls_ReporterCountryName = loo_JResp.StringOf("data.reports[i].reporterCountryName")
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("data.reports[i].categories")
    do while j < li_Count_j
        loo_JResp.J = j
        li_IntVal = loo_JResp.IntOf("data.reports[i].categories[j]")
        j = j + 1
    loop
    i = i + 1
loop


destroy loo_Http
destroy loo_Req
destroy loo_Resp
destroy loo_JResp