To pull the existing address lists via the Microtik API, you can use the following GET request:
GET /rest/ip/firewall/address-list
This request will return a list of all address lists on the router.
To match the existing address list against some other data, you can use the filter parameter. For example, the following request will return all address lists with a name that contains the string "my_address_list":
GET /rest/ip/firewall/address-list?filter=name~my_address_list
To add, update, or delete entries in an address list, you can use the POST request for /rest/ip/firewall/address-list/print. The JSON body for this request should contain the following parameters:
name: The name of the address list.
add: A list of entries to add to the address list.
remove: A list of entries to remove from the address list.
set: A list of entries to update in the address list.
For example, the following request will add a new entry to the address list my_address_list:
POST /rest/ip/firewall/address-list/print
{
"name": "my_address_list",
"add": [
{
"address": "192.168.1.100/24",
"comment": "This is a new entry."
}
]
}
You can use Postman for interactive queries and n8n to create a processing flow that automates your address list management tasks.
Here is an example of a n8n flow that pulls the existing address lists from the Microtik API and then matches them against some other data:
Start --> HTTP Request (GET) --> Finish
HTTP Request (GET)
URL:
http://ip/rest/ip/firewall/address-list
Method: GET
Headers:
Authorization: Bearer YOUR_API_TOKEN
Finish
Condition:
Expression: {{data.length > 0}}
Then:
- Set Data:
Variable: addressLists
Value: {{data}}
Else:
- Throw Error:
Message: No address lists found.
You can then add additional nodes to the flow to match the address lists against some other data and to add, update, or delete entries in the address lists.
I hope this helps!