Sample code for 30+ languages & platforms
Xbase++

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 Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oHttp
LOCAL oReq
LOCAL oResp
LOCAL oJResp
LOCAL nRespStatusCode
LOCAL cReportedAt
LOCAL cComment
LOCAL nReporterId
LOCAL cReporterCountryCode
LOCAL cReporterCountryName
LOCAL j
LOCAL nCount_j
LOCAL nIntVal
LOCAL cDataIpAddress
LOCAL nDataIsPublic
LOCAL nDataIpVersion
LOCAL nDataIsWhitelisted
LOCAL nDataAbuseConfidenceScore
LOCAL cDataCountryCode
LOCAL cDataUsageType
LOCAL cDataIsp
LOCAL cDataDomain
LOCAL cDataCountryName
LOCAL nDataTotalReports
LOCAL nDataNumDistinctUsers
LOCAL cDataLastReportedAt
LOCAL i
LOCAL nCount_i

nSuccess := 0

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

oHttp := CreateObject("Chilkat.Http")

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

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

oReq:AddHeader("Key", "$YOUR_API_KEY")
oReq:AddHeader("Accept", "application/json")

oResp := CreateObject("Chilkat.HttpResponse")
nSuccess := oHttp:HttpSReq("api.abuseipdb.com", 443, 1, oReq, oResp)
IF (nSuccess == 0)
    ? oHttp:LastErrorText
    oHttp:destroy()
    oReq:destroy()
    oResp:destroy()
    RETURN
ENDIF

oJResp := CreateObject("Chilkat.JsonObject")
oJResp:Load(oResp:BodyStr)
oJResp:EmitCompact := 0

? "Response Body:"
? oJResp:Emit()

nRespStatusCode := oResp:StatusCode
? "Response Status Code = " + Str(nRespStatusCode)
IF (nRespStatusCode >= 400)
    ? "Response Header:"
    ? oResp:Header
    ? "Failed."
    oHttp:destroy()
    oReq:destroy()
    oResp:destroy()
    oJResp:destroy()
    RETURN
ENDIF

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

cDataIpAddress := oJResp:StringOf("data.ipAddress")
nDataIsPublic := oJResp:BoolOf("data.isPublic")
nDataIpVersion := oJResp:IntOf("data.ipVersion")
nDataIsWhitelisted := oJResp:BoolOf("data.isWhitelisted")
nDataAbuseConfidenceScore := oJResp:IntOf("data.abuseConfidenceScore")
cDataCountryCode := oJResp:StringOf("data.countryCode")
cDataUsageType := oJResp:StringOf("data.usageType")
cDataIsp := oJResp:StringOf("data.isp")
cDataDomain := oJResp:StringOf("data.domain")
cDataCountryName := oJResp:StringOf("data.countryName")
nDataTotalReports := oJResp:IntOf("data.totalReports")
nDataNumDistinctUsers := oJResp:IntOf("data.numDistinctUsers")
cDataLastReportedAt := oJResp:StringOf("data.lastReportedAt")
i := 0
nCount_i := oJResp:SizeOfArray("data.hostnames")
DO WHILE i < nCount_i
    oJResp:I := i
    i := i + 1
ENDDO
i := 0
nCount_i := oJResp:SizeOfArray("data.reports")
DO WHILE i < nCount_i
    oJResp:I := i
    cReportedAt := oJResp:StringOf("data.reports[i].reportedAt")
    cComment := oJResp:StringOf("data.reports[i].comment")
    nReporterId := oJResp:IntOf("data.reports[i].reporterId")
    cReporterCountryCode := oJResp:StringOf("data.reports[i].reporterCountryCode")
    cReporterCountryName := oJResp:StringOf("data.reports[i].reporterCountryName")
    j := 0
    nCount_j := oJResp:SizeOfArray("data.reports[i].categories")
    DO WHILE j < nCount_j
        oJResp:J := j
        nIntVal := oJResp:IntOf("data.reports[i].categories[j]")
        j := j + 1
    ENDDO
    i := i + 1
ENDDO

oHttp:destroy()
oReq:destroy()
oResp:destroy()
oJResp:destroy()