API call response does not contain all records

Getting records via the API GET …/dns_records does not return all records that I can see in the web-ui and get via an export. I’ve just noticed it for A-records (might be because that’s what I have most of e.g. if a certain amount of records triggers some bug) but not checked other record types.


% /usr/bin/curl -s -H "Authorization: Bearer MYAPITOKEN" -H "Content-Type: application/json" -X GET "https://api.cloudflare.com/client/v4/zones/MYZONEID/dns_records/export" | grep -E 'kia.*\sIN\s+A'

kia-apinet.axnet.nu.	3600	IN	A
kia.axnet.nu.			1		IN	A	somepublicipaddr
kia-int.axnet.nu.		3600	IN	A
kia-mc.axnet.nu.		3600	IN	A
kia-unity.axnet.nu.		3600	IN	A
kia-vr.axnet.nu.		3600	IN	A
kia-wg.axnet.nu.		3600	IN	A
kia-wifi.axnet.nu.		3600	IN	A

whilst a successful response for

/usr/bin/curl -s -H "Authorization: Bearer MYAPITOKEN" -H "Content-Type: application/json" -X GET "https://api.cloudflare.com/client/v4/zones/MYZONEID/dns_records?type=A"

does not contain any of the above listed A-records, grepping for kia in the JSON output there isn’t one single instance containing that … but other A-records defined the same way, just with a different name are in there …

You see them in the actual Cloudflare Dashboard under DNS Records as normal A records I assume? They could be flattened CNAME records if you have that enabled.

The export endpoint is also always a full export, but the /dns_records endpoint is paginated by default only showing 100, you could increase the per_page count up to 50,000, ex dns_records?type=A&per_page=50000. Check out the List DNS Records Docs for more info: Cloudflare API Documentation


It’s not flattened CNAMES, but thank you, yes I have more than 100 A-records so that’s probably the issue, missed that in the doc … will read the doc more carefully before howling the nexct tyime … thx again :slight_smile:

1 Like

works perfectly fine increasing the per_page, thx

1 Like