Community discussions

MikroTik App
 
howdey57
Member Candidate
Member Candidate
Topic Author
Posts: 122
Joined: Wed Dec 31, 2014 2:36 pm

Using the CHECK Endpoint API on AbuseIPDB

Sat Aug 28, 2021 7:07 pm

Has anyone got a ROS script they could share that checks IP addresses against APIv2 on AbuseIPDB?
The documentation is here: https://docs.abuseipdb.com/#check-endpoint
and I need to write a fetch command to mimic this 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"
So far, I have:
/tool fetch mode=https http-method=get http-header-field="Accept: application/json ; Key: xxxx" url="https://api.abuseipdb.com/api/v2/check\?ipAddress=183.136.226.2" output=file dst-path=mydata.txt 

but it doesn't work.
TIA
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Using the CHECK Endpoint API on AbuseIPDB

Sun Aug 29, 2021 1:57 am

Too much.

\ before ? for test on terminal
/tool fetch http-header-field="Accept: application/json,Key: xxxxxxx" url="https://api.abuseipdb.com/api/v2/check\?ipAddress=183.136.226.2" dst-path=mydata.txt

for put the results on one variable:
(remember to remove \ before ? on scripts)
:global thisvar ([/tool fetch http-header-field="Accept: application/json,Key: xxxxxxx" url="https://api.abuseipdb.com/api/v2/check\?ipAddress=183.136.226.2" as-value output=user]->"data")

for example if you do that query on the variable go:
{
"data":
    {
    "ipAddress":"183.136.226.2",
    "isPublic":true,
    "ipVersion":4,
    "isWhitelisted":false,
    "abuseConfidenceScore":100,
    "countryCode":"CN",
    "usageType":null,
    "isp":"ChinaNet Zhejiang Province Network",
    "domain":"chinatelecom.com.cn",
    "hostnames":[],
    "totalReports":850,
    "numDistinctUsers":82,
    "lastReportedAt":"2021-08-28T22:07:36+00:00"
    }
}


for read for example the country code result from memorized result on memory
:global fromthis "\"countryCode\":"
:global tothis   ","
:global offset [:len $fromthis]
:global varpos [:find $thisvar $fromthis -1]
:global value [:pick $thisvar ($varpos + $offset) [:find $thisvar $tothis $varpos]]
:put $value
 
howdey57
Member Candidate
Member Candidate
Topic Author
Posts: 122
Joined: Wed Dec 31, 2014 2:36 pm

Re: Using the CHECK Endpoint API on AbuseIPDB

Sun Aug 29, 2021 2:07 pm

Thank you. That works very well.

Once I've done my whole script, l'll share it here.

Charles
 
Sela69
just joined
Posts: 9
Joined: Mon Sep 27, 2021 11:19 pm

Re: Using the CHECK Endpoint API on AbuseIPDB

Fri Mar 04, 2022 3:57 pm

Thank you. That works very well.

Once I've done my whole script, l'll share it here.

Charles
Hi Charles,

could you kindly share your script ?

Who is online

Users browsing this forum: andrejtom and 28 guests