# 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> |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://synconics.gitbook.io/rest-api/calling-methods/count-records.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
