Sample code for 30+ languages & platforms
Tcl

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

Tcl

load ./chilkat.dll

set success 0

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

set http [new_CkHttp]

# 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

set req [new_CkHttpRequest]

CkHttpRequest_put_HttpVerb $req "GET"
CkHttpRequest_put_Path $req "/api/v2/check"
CkHttpRequest_put_ContentType $req "application/x-www-form-urlencoded"
CkHttpRequest_AddParam $req "maxAgeInDays" "90"
CkHttpRequest_AddParam $req "verbose" ""
CkHttpRequest_AddParam $req "ipAddress" "118.25.6.39"

CkHttpRequest_AddHeader $req "Key" "$YOUR_API_KEY"
CkHttpRequest_AddHeader $req "Accept" "application/json"

set resp [new_CkHttpResponse]

set success [CkHttp_HttpSReq $http "api.abuseipdb.com" 443 1 $req $resp]
if {$success == 0} then {
    puts [CkHttp_lastErrorText $http]
    delete_CkHttp $http
    delete_CkHttpRequest $req
    delete_CkHttpResponse $resp
    exit
}

set jResp [new_CkJsonObject]

CkJsonObject_Load $jResp [CkHttpResponse_bodyStr $resp]
CkJsonObject_put_EmitCompact $jResp 0

puts "Response Body:"
puts [CkJsonObject_emit $jResp]

set respStatusCode [CkHttpResponse_get_StatusCode $resp]
puts "Response Status Code = $respStatusCode"
if {$respStatusCode >= 400} then {
    puts "Response Header:"
    puts [CkHttpResponse_header $resp]
    puts "Failed."
    delete_CkHttp $http
    delete_CkHttpRequest $req
    delete_CkHttpResponse $resp
    delete_CkJsonObject $jResp
    exit
}

# 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

set dataIpAddress [CkJsonObject_stringOf $jResp "data.ipAddress"]
set dataIsPublic [CkJsonObject_BoolOf $jResp "data.isPublic"]
set dataIpVersion [CkJsonObject_IntOf $jResp "data.ipVersion"]
set dataIsWhitelisted [CkJsonObject_BoolOf $jResp "data.isWhitelisted"]
set dataAbuseConfidenceScore [CkJsonObject_IntOf $jResp "data.abuseConfidenceScore"]
set dataCountryCode [CkJsonObject_stringOf $jResp "data.countryCode"]
set dataUsageType [CkJsonObject_stringOf $jResp "data.usageType"]
set dataIsp [CkJsonObject_stringOf $jResp "data.isp"]
set dataDomain [CkJsonObject_stringOf $jResp "data.domain"]
set dataCountryName [CkJsonObject_stringOf $jResp "data.countryName"]
set dataTotalReports [CkJsonObject_IntOf $jResp "data.totalReports"]
set dataNumDistinctUsers [CkJsonObject_IntOf $jResp "data.numDistinctUsers"]
set dataLastReportedAt [CkJsonObject_stringOf $jResp "data.lastReportedAt"]
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "data.hostnames"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "data.reports"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set reportedAt [CkJsonObject_stringOf $jResp "data.reports[i].reportedAt"]
    set comment [CkJsonObject_stringOf $jResp "data.reports[i].comment"]
    set reporterId [CkJsonObject_IntOf $jResp "data.reports[i].reporterId"]
    set reporterCountryCode [CkJsonObject_stringOf $jResp "data.reports[i].reporterCountryCode"]
    set reporterCountryName [CkJsonObject_stringOf $jResp "data.reports[i].reporterCountryName"]
    set j 0
    set count_j [CkJsonObject_SizeOfArray $jResp "data.reports[i].categories"]
    while {$j < $count_j} {
        CkJsonObject_put_J $jResp $j
        set intVal [CkJsonObject_IntOf $jResp "data.reports[i].categories[j]"]
        set j [expr $j + 1]
    }
    set i [expr $i + 1]
}

delete_CkHttp $http
delete_CkHttpRequest $req
delete_CkHttpResponse $resp
delete_CkJsonObject $jResp