API to retrieve record count?

Hi @charleslcso,

You haven’t mentioned the field name.

I haven’t any more idea but try and check it.

import requests

response = requests.get('https://your-erpnext-instance.com/api/resource/User?fields=["name"]&filters=[["enabled", "=", "1"]]')
data = response.json()
record_count = len(data['data'])

print("Total Record:", record_count)

[EDIT]

Otherwise, check it.

/api/resource/User?fields=["count(name)"]&filters=[["enabled", "=", "1"]]

I hope this helps.

Thank You!

5 Likes