How to find the total number of records in a table?

Is there a way using the Data Fetch Endpoint to find the total number of records in a table? I tried to use /v2/data/{table}:count but it returns the first 10000 with a moreRecords to indicate that there are more to come:

{
    "Data": {
        "pageData": {
            "total": 10000,
            "pageDataExtras": {
                "moreRecords": true
            }
        }
    },
    "ErrorMessages": []
}

You might want to look into the nwSkipTotal parameter which gets discussed here: nwSkipTotal = false is limiting out at 100,000 when true result is higher

However even it has limitations (if higher) on how many records it will say exists. For an unbounded count, you should use the /v2/aggregate endpoint. There is no official documentation that I’m aware of right now for that endpoint, but here’s an example of how you can call it:

curl --request POST \
  --url {baseurl}/v2/aggregate \
  --header 'Authorization: Bearer xxx' \
  --header 'Content-Type: application/json' \
  --data ' {
  "nwTable": "Directory",
  "nwFilter": {
    "ContactRoleGrouping": {
      "$multi": [
        "SUPP"
      ]
    }
  },
  "nwAggregate": [
    {
      "nwFields": "@count:nwId",
      "nwGroupBy": ""
    }
  ]
}'
1 Like

@ian.p , that endpoint works for me where I have > 100K customers. Thanks a lot for your help.

2 Likes