Delphi DLL
Delphi DLL
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 Delphi DLL Downloads
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Http, HttpRequest, HttpResponse, JsonObject;
...
procedure TForm1.Button1Click(Sender: TObject);
var
success: Boolean;
http: HCkHttp;
req: HCkHttpRequest;
resp: HCkHttpResponse;
jResp: HCkJsonObject;
respStatusCode: Integer;
reportedAt: PWideChar;
comment: PWideChar;
reporterId: Integer;
reporterCountryCode: PWideChar;
reporterCountryName: PWideChar;
j: Integer;
count_j: Integer;
intVal: Integer;
dataIpAddress: PWideChar;
dataIsPublic: Boolean;
dataIpVersion: Integer;
dataIsWhitelisted: Boolean;
dataAbuseConfidenceScore: Integer;
dataCountryCode: PWideChar;
dataUsageType: PWideChar;
dataIsp: PWideChar;
dataDomain: PWideChar;
dataCountryName: PWideChar;
dataTotalReports: Integer;
dataNumDistinctUsers: Integer;
dataLastReportedAt: PWideChar;
i: Integer;
count_i: Integer;
begin
success := False;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http := CkHttp_Create();
// 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
req := CkHttpRequest_Create();
CkHttpRequest_putHttpVerb(req,'GET');
CkHttpRequest_putPath(req,'/api/v2/check');
CkHttpRequest_putContentType(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');
resp := CkHttpResponse_Create();
success := CkHttp_HttpSReq(http,'api.abuseipdb.com',443,True,req,resp);
if (success = False) then
begin
Memo1.Lines.Add(CkHttp__lastErrorText(http));
Exit;
end;
jResp := CkJsonObject_Create();
CkJsonObject_Load(jResp,CkHttpResponse__bodyStr(resp));
CkJsonObject_putEmitCompact(jResp,False);
Memo1.Lines.Add('Response Body:');
Memo1.Lines.Add(CkJsonObject__emit(jResp));
respStatusCode := CkHttpResponse_getStatusCode(resp);
Memo1.Lines.Add('Response Status Code = ' + IntToStr(respStatusCode));
if (respStatusCode >= 400) then
begin
Memo1.Lines.Add('Response Header:');
Memo1.Lines.Add(CkHttpResponse__header(resp));
Memo1.Lines.Add('Failed.');
Exit;
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
dataIpAddress := CkJsonObject__stringOf(jResp,'data.ipAddress');
dataIsPublic := CkJsonObject_BoolOf(jResp,'data.isPublic');
dataIpVersion := CkJsonObject_IntOf(jResp,'data.ipVersion');
dataIsWhitelisted := CkJsonObject_BoolOf(jResp,'data.isWhitelisted');
dataAbuseConfidenceScore := CkJsonObject_IntOf(jResp,'data.abuseConfidenceScore');
dataCountryCode := CkJsonObject__stringOf(jResp,'data.countryCode');
dataUsageType := CkJsonObject__stringOf(jResp,'data.usageType');
dataIsp := CkJsonObject__stringOf(jResp,'data.isp');
dataDomain := CkJsonObject__stringOf(jResp,'data.domain');
dataCountryName := CkJsonObject__stringOf(jResp,'data.countryName');
dataTotalReports := CkJsonObject_IntOf(jResp,'data.totalReports');
dataNumDistinctUsers := CkJsonObject_IntOf(jResp,'data.numDistinctUsers');
dataLastReportedAt := CkJsonObject__stringOf(jResp,'data.lastReportedAt');
i := 0;
count_i := CkJsonObject_SizeOfArray(jResp,'data.hostnames');
while i < count_i do
begin
CkJsonObject_putI(jResp,i);
i := i + 1;
end;
i := 0;
count_i := CkJsonObject_SizeOfArray(jResp,'data.reports');
while i < count_i do
begin
CkJsonObject_putI(jResp,i);
reportedAt := CkJsonObject__stringOf(jResp,'data.reports[i].reportedAt');
comment := CkJsonObject__stringOf(jResp,'data.reports[i].comment');
reporterId := CkJsonObject_IntOf(jResp,'data.reports[i].reporterId');
reporterCountryCode := CkJsonObject__stringOf(jResp,'data.reports[i].reporterCountryCode');
reporterCountryName := CkJsonObject__stringOf(jResp,'data.reports[i].reporterCountryName');
j := 0;
count_j := CkJsonObject_SizeOfArray(jResp,'data.reports[i].categories');
while j < count_j do
begin
CkJsonObject_putJ(jResp,j);
intVal := CkJsonObject_IntOf(jResp,'data.reports[i].categories[j]');
j := j + 1;
end;
i := i + 1;
end;
CkHttp_Dispose(http);
CkHttpRequest_Dispose(req);
CkHttpResponse_Dispose(resp);
CkJsonObject_Dispose(jResp);
end;