Count Records¶
Rather than retrieve a possibly gigantic list of records and count them, search_count() can be used to retrieve only the number of records matching the query. It takes the same domain filter as search() and no other parameter.
Warning
calling restapi/1.0/object/{object_name}/search
then restapi/1.0/object/{object_name}/search_count
(or the other way around) may not yield coherent results if other users are using the server: stored data could have changed between the calls
-
GET
/restapi/1.0/object/{object_name}/search_count
¶ Request:
GET /restapi/1.0/object/res.partner/search_count?domain=[('is_company','=',True),('customer','=',True)] HTTP/1.1 Host: {your_Odoo_server_url}
Response:
HTTP/1.1 200 OK { 'count': 19 }
Query Parameters: - domain – A search domain. Use an empty list to match all records.
Request Headers: - Accept – the response content type depends on Accept header
- Authorization – The OAuth protocol parameters to authenticate.
Response Headers: - Content-Type – this depends on Accept header of request
Status Codes: - 200 OK – no error
- 404 Not Found – there’s no resource
- 401 Unauthorized – authentication failed
- 403 Forbidden – if any error raise