> For the complete documentation index, see [llms.txt](https://synconics.gitbook.io/rest-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://synconics.gitbook.io/rest-api/calling-methods/count-records.md).

# Count Records

Rather than retrieve a possibly gigantic list of records and count them, [search\_count()](https://www.odoo.com/documentation/16.0/developer/reference/backend/orm.html?highlight=search_count#odoo.models.Model.search_count) can be used to retrieve only the number of records matching the query. It takes the same [domain](https://www.odoo.com/documentation/16.0/developer/reference/backend/orm.html?highlight=search_count#reference-orm-domains) filter as [search()](https://www.odoo.com/documentation/16.0/developer/reference/backend/orm.html#odoo.models.Model.search) and no other parameter.

**Warning**

<mark style="background-color:orange;">calling</mark> <mark style="background-color:orange;"></mark><mark style="background-color:orange;">`restapi/1.0/object/{object_name}/search`</mark> <mark style="background-color:orange;"></mark><mark style="background-color:orange;">then</mark> <mark style="background-color:orange;"></mark><mark style="background-color:orange;">`restapi/1.0/object/{object_name}/search_count`</mark> <mark style="background-color:orange;"></mark><mark style="background-color:orange;">(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</mark>

**`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}
```

**JSON Response:**

```
HTTP/1.1 200 OK

{
  'count': 19
}
```

**XML Response:**

```
HTTP/1.1 200 OK

<count>19</count>
```

**Query Parameters:**

| <ul><li><strong>domain</strong> – A <a href="https://www.odoo.com/documentation/16.0/developer/reference/backend/orm.html?highlight=search_count#reference-orm-domains">search domain</a>. Use an empty list to match all records.</li></ul> |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

| Headers and Status Codes | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Request Headers          | <ul><li><a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-accept">Accept</a> – the response content type depends on <em>Accept</em> header</li><li><a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-authorization">Authorization</a> – The OAuth protocol parameters to authenticate.</li></ul>                                                                                                                                                                           |
| Response Headers         | <ul><li><a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-content-type">Content-Type</a> – this depends on <em>Accept</em> header of the request</li></ul>                                                                                                                                                                                                                                                                                                                         |
| Status Codes             | <ul><li><a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-200-ok">200 OK</a> – no error</li><li><a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-404-not-found">404 Not Found</a> – there’s no resource</li><li><a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2">401 Unauthorized</a> – authentication failed</li><li><a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-403-forbidden">403 Forbidden</a> – if any error raise</li></ul> |
