Is there any mysqli_num_rows() like API call I can make to receive the number of my entries?
I decided to check if $elements = cockpit(‘collections’)->count(‘elements’); will work… and it works!
Where can I find the full REST API documentation? I cant work blindly with your product! Very little information you gave.
If you send a request to example.com/api/collections/get/elements?token=xxtokenxx
, the response should look like this:
{
"fields": {...},
"entries": [...],
"total": 5
}
The total
is your count.
If you want a smaller size of the response, use the fields filter, so the entries object only contains the _id
.
If you want a rest api endpoint, that only counts, you have to create your own:
/config/api/collections/count/elements.php
:
<?php
// check filters
$options = [];
return ['total' => cockpit('collections')->count('elements', $options)];
Have a look at the RestApi controller to see how the core filtering works:
1 Like