Get total response for all contacts (PHP get analytics data)

We are trying to setup an analytics dashboard for a client.

I need to grab some of the numbers that the Infusionsoft dashboard gives such as total amount of contacts, all email stats for past 30 days (just the total sends, unique opens with percent, clicks with percent, opt outs with percent, and bounces with percent).

I was told that finding the total response when I get contacts may be the best way to go. Currently we do have a check for contacts but I believe Infusionsoft API limits the get to 1000 (read this somewhere).

for ($i = 0; $i < 1000; $i++) {
	   $response = $infusionsoft->search()->getSavedSearchResultsAllFields(436, 4, $i);
	   if(!empty($response)) { array_push($contact_array, $response); } else { break; }
	}

I may be missing something but is there a simple way to get the total amount of contacts?
https://developer.infusionsoft.com/docs/rest/#!/Contact/listContactsUsingGET
Or would I have to do some kind of table query for that?
https://developer.infusionsoft.com/docs/xml-rpc/#data-query-a-data-table

It just seems that the Infusionsoft API isn’t built for analytics or I am completely missing something.

Thanks for the help!

The DataService.count API Function is what you can use to get the count of the records. You pass in the Data Query parameters for it to do the count on.

https://developer.infusionsoft.com/docs/xml-rpc/#data-count-a-data-table-s-records