I need to lookup or delete Rules Lists items by IP address intead of item ID

Hi everyone
I’m using Cloudflare API in an application to add, delete, and lookup for IP addresses in Rules Lists. However, according to the Rules Lists section of the documentation, I can only do these operations using each list item’s ID. I tried to solve this problem by getting all of the list items, looking up the item with the required IP address, getting its ID, and then performing the needed operation, then I realized that Cloudflare only returns 25 items per call and I have to scroll through the items using cursors, which isn’t practical for big lists with thousands of items.

Is it possible to increase the number of the returned items to reduce the number of API calls? Is there any other way to make this possible? Am I missing something in the documentation?

Thanks in advance.

Cloudflare uses Pagination for returning a large number of results. You can change the options with query strings.

Docs: Cloudflare API v4 Documentation and CRL + F for Pagination.

1 Like

I tried to use pagination parameters like page number and the number of items per page but it didn’t work with Rules Lists. The only pagination method that works for Rules Lists is by using cursors, as per the List List Items section of the Documentation.

Ah, my bad. Played around with the API and it does not appear that you can get more than 25 at once. This also matches with the dashboard API

1 Like