CURL GET displays not all of the dns records

Dear users.
I have this script.
$curl = curl_init();

curl_setopt_array($curl, [
	CURLOPT_URL => "https://api.cloudflare.com/client/v4/zones/".$z_id."/dns_records",
	CURLOPT_RETURNTRANSFER => true,
	CURLOPT_ENCODING => "",
	CURLOPT_MAXREDIRS => 10,
	CURLOPT_TIMEOUT => 30,
	CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
	CURLOPT_CUSTOMREQUEST => "GET",
	CURLOPT_HTTPHEADER => [
		"Content-Type: application/json",
		"X-Auth-Email: ".$z_email,
		"X-Auth-Key: ".$z_key
		],
]);

$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);

I have 220 dns records in my domain, but with that script i can see only 100 of them. how can i see the other records?

PS: the result shows that i have 220 records and there are 3 pages, only 1 page is shown to me, what about 2 other pages?
[result_info] => Array
(
[page] => 1
[per_page] => 100
[count] => 100
[total_count] => 220
[total_pages] => 3
)

Add ?page=2, etc. to your API request. You can also increase the per_page option up to 5000.

See Cloudflare API v4 Documentation for details.

1 Like

where should i add this - ?page=2

It’s a URL query parameter. So for example, you would hit https://api.cloudflare.com/client/v4/zones/[id]/dns_records, and then https://api.cloudflare.com/client/v4/zones/[id]/dns_records?page=2, etc.

You will need to write your code to handle pagination if there are additional pages, and/or increase your per_page to a higher value if you want this to be returned in a single request.

ok, thanks, i got it

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.