> For the complete documentation index, see [llms.txt](https://alek-cora-glez.gitbook.io/odoo-generic-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://alek-cora-glez.gitbook.io/odoo-generic-api/search.md).

# Search

## **(Search) -- Using the API to get resources**

**\[GET]** *https\://\<server-url>/api/\<model\_name>*

```
curl --location --request GET 'https://<server_url>/api/hr.employee' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer <token>' \
    --data-raw '{}'
```

### Request Parameters

#### limit

*It defines the number of records to retrive, by default 80.*

#### **offset**

*Used for pagination, it defines the the number of records that need to be skipped.*

#### fields

*It defines the fields you want to retrieve, by default all attributes will be returned. Below you can find how to define the attributes you want to retrieve.*

| *Field type*         | How to request them                                                                                                                                                  |
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| basics fields        | *\['id', 'name', 'street']*                                                                                                                                          |
| Many2one             | *\['id', 'name', 'street', ('country\_id', \['id', 'name'])]*                                                                                                        |
| Many2many & One2many | *\['id', 'name', ('country\_id', \['id', 'name']), \['child\_ids', \['id', 'name', ('title', \['id', 'name', 'shortcut']), 'work\_email', 'work\_phone', 'notes']]]* |

**args**

*It defines the arguments to apply in the search.*

**count**

*If the value is **1** the number of records will be returned.*

**order**

*It defines the order to apply in the result to return.*

### **Examples...**

*Retrieving specific fields: \["id", "name", "work\_email", ("country\_of\_birth", \["id", "name"]), \["child\_ids", \["id", "name", "job\_title", "work\_email", "work\_phone", "notes", ("coach\_id", \["id", "name"])]]]*

{% tabs %}
{% tab title="Request" %}

```
curl --location -g --request GET 'https://<server_url>/api/hr.employee?fields=[%22id%22,%20%22name%22,%20%22work_email%22,%20(%22country_of_birth%22,%20[%22id%22,%20%22name%22]),%20[%22child_ids%22,%20[%22id%22,%20%22name%22,%20%22job_title%22,%20%22work_email%22,%20%22work_phone%22,%20%22notes%22,%20(%22coach_id%22,%20[%22id%22,%20%22name%22])]]]&order=%22name%20Asc%22' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer <token>' \
    --data-raw '{}'
```

{% endtab %}

{% tab title="Response" %}

```
{
    "jsonrpc": "2.0",
    "id": null,
    "result": {
        "status_code": 200,
        "data": [
            {
                "id": 20,
                "name": "Abigail Peterson",
                "work_email": "abigail.peterson39@example.com",
                "country_of_birth": {},
                "child_ids": []
            },
            {
                "id": 3,
                "name": "Anita Oliver",
                "work_email": "anita.oliver32@example.com",
                "country_of_birth": {},
                "child_ids": []
            },
            {
                "id": 9,
                "name": "Audrey Peterson",
                "work_email": "audrey.peterson25@example.com",
                "country_of_birth": {},
                "child_ids": []
            },
            {
                "id": 17,
                "name": "Beth Evans",
                "work_email": "beth.evans77@example.com",
                "country_of_birth": {},
                "child_ids": []
            },
            {
                "id": 15,
                "name": "Doris Cole",
                "work_email": "doris.cole31@example.com",
                "country_of_birth": {},
                "child_ids": []
            },
            {
                "id": 19,
                "name": "Eli Lambert",
                "work_email": "eli.lambert22@example.com",
                "country_of_birth": {},
                "child_ids": []
            },
            {
                "id": 18,
                "name": "Ernest Reed",
                "work_email": "ernest.reed47@example.com",
                "country_of_birth": {},
                "child_ids": []
            },
            {
                "id": 11,
                "name": "Jeffrey Kelly",
                "work_email": "jeffrey.kelly72@example.com",
                "country_of_birth": {},
                "child_ids": []
            },
            {
                "id": 6,
                "name": "Jennie Fletcher",
                "work_email": "jennie.fletcher76@example.com",
                "country_of_birth": {},
                "child_ids": []
            },
            {
                "id": 8,
                "name": "Keith Byrd",
                "work_email": "keith.byrd52@example.com",
                "country_of_birth": {},
                "child_ids": []
            },
            {
                "id": 7,
                "name": "Marc Demo",
                "work_email": "mark.brown23@example.com",
                "country_of_birth": {},
                "child_ids": []
            },
            {
                "id": 1,
                "name": "Mitchell Admin",
                "work_email": "aiden.hughes71@example.com",
                "country_of_birth": {},
                "child_ids": [
                    {
                        "id": 9,
                        "name": "Audrey Peterson",
                        "job_title": "Consultant",
                        "work_email": "audrey.peterson25@example.com",
                        "work_phone": "(203)-276-7903",
                        "notes": false,
                        "coach_id": {
                            "id": 1,
                            "name": "Mitchell Admin"
                        }
                    },
                    {
                        "id": 11,
                        "name": "Jeffrey Kelly",
                        "job_title": "Marketing and Community Manager",
                        "work_email": "jeffrey.kelly72@example.com",
                        "work_phone": "(916)-264-7362",
                        "notes": false,
                        "coach_id": {
                            "id": 1,
                            "name": "Mitchell Admin"
                        }
                    },
                    {
                        "id": 7,
                        "name": "Marc Demo",
                        "job_title": "Experienced Developer",
                        "work_email": "mark.brown23@example.com",
                        "work_phone": "+3281813700",
                        "notes": false,
                        "coach_id": {
                            "id": 1,
                            "name": "Mitchell Admin"
                        }
                    },
                    {
                        "id": 12,
                        "name": "Tina Williamson",
                        "job_title": "Human Resources Manager",
                        "work_email": "tina.williamson98@example.com",
                        "work_phone": "(360)-694-7266",
                        "notes": false,
                        "coach_id": {
                            "id": 1,
                            "name": "Mitchell Admin"
                        }
                    },
                    {
                        "id": 10,
                        "name": "Toni Jimenez",
                        "job_title": "Consultant",
                        "work_email": "toni.jimenez23@example.com",
                        "work_phone": "(663)-707-8451",
                        "notes": false,
                        "coach_id": {
                            "id": 1,
                            "name": "Mitchell Admin"
                        }
                    }
                ]
            },
            {
                "id": 14,
                "name": "Paul Williams",
                "work_email": "paul.williams59@example.com",
                "country_of_birth": {},
                "child_ids": []
            },
            {
                "id": 16,
                "name": "Rachel Perry",
                "work_email": "jod@odoo.com",
                "country_of_birth": {},
                "child_ids": []
            },
            {
                "id": 5,
                "name": "Randall Lewis",
                "work_email": "randall.lewis74@example.com",
                "country_of_birth": {},
                "child_ids": []
            },
            {
                "id": 2,
                "name": "Ronnie Hart",
                "work_email": "ronnie.hart87@example.com",
                "country_of_birth": {},
                "child_ids": [
                    {
                        "id": 3,
                        "name": "Anita Oliver",
                        "job_title": "Experienced Developer",
                        "work_email": "anita.oliver32@example.com",
                        "work_phone": "(538)-497-4804",
                        "notes": false,
                        "coach_id": {
                            "id": 2,
                            "name": "Ronnie Hart"
                        }
                    },
                    {
                        "id": 6,
                        "name": "Jennie Fletcher",
                        "job_title": "Experienced Developer",
                        "work_email": "jennie.fletcher76@example.com",
                        "work_phone": "(157)-363-8229",
                        "notes": false,
                        "coach_id": {
                            "id": 2,
                            "name": "Ronnie Hart"
                        }
                    },
                    {
                        "id": 8,
                        "name": "Keith Byrd",
                        "job_title": "Experienced Developer",
                        "work_email": "keith.byrd52@example.com",
                        "work_phone": "(449)-505-5146",
                        "notes": false,
                        "coach_id": {
                            "id": 2,
                            "name": "Ronnie Hart"
                        }
                    },
                    {
                        "id": 5,
                        "name": "Randall Lewis",
                        "job_title": "Experienced Developer",
                        "work_email": "randall.lewis74@example.com",
                        "work_phone": "(332)-775-6660",
                        "notes": false,
                        "coach_id": {
                            "id": 2,
                            "name": "Ronnie Hart"
                        }
                    },
                    {
                        "id": 4,
                        "name": "Sharlene Rhodes",
                        "job_title": "Experienced Developer",
                        "work_email": "sharlene.rhodes49@example.comcom",
                        "work_phone": "(450)-719-4182",
                        "notes": false,
                        "coach_id": {
                            "id": 2,
                            "name": "Ronnie Hart"
                        }
                    }
                ]
            },
            {
                "id": 4,
                "name": "Sharlene Rhodes",
                "work_email": "sharlene.rhodes49@example.comcom",
                "country_of_birth": {},
                "child_ids": []
            },
            {
                "id": 12,
                "name": "Tina Williamson",
                "work_email": "tina.williamson98@example.com",
                "country_of_birth": {},
                "child_ids": []
            },
            {
                "id": 10,
                "name": "Toni Jimenez",
                "work_email": "toni.jimenez23@example.com",
                "country_of_birth": {},
                "child_ids": []
            },
            {
                "id": 13,
                "name": "Walter Horton",
                "work_email": "walter.horton80@example.com",
                "country_of_birth": {},
                "child_ids": []
            }
        ]
    }
}
```

{% endtab %}
{% endtabs %}

*Looking for the number of records where name contains Walter...*

{% tabs %}
{% tab title="Request" %}

```
curl --location -g --request GET 'https://<server_url>/api/hr.employee?limit=2&count=1&args=[(%27name%27,%20%27like%27,%20%27Walter%27)]' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer <token>' \
    --data-raw '{}'
```

{% endtab %}

{% tab title="Response" %}

```
{
    "jsonrpc": "2.0",
    "id": null,
    "result": {
        "status_code": 200,
        "data": 1
    }
}
```

{% endtab %}
{% endtabs %}

*Retrieve specific record...*

{% tabs %}
{% tab title="Request" %}

```
curl --location -g --request GET 'https://<server_url>/api/hr.employee/3?fields=[%22id%22,%20%22name%22,%20%22work_email%22]' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer <token>' \
    --data-raw '{}'
```

{% endtab %}

{% tab title="Response" %}

```
{
    "jsonrpc": "2.0",
    "id": null,
    "result": {
        "status_code": 200,
        "data": {
            "id": 3,
            "name": "Anita Oliver",
            "work_email": "anita.oliver32@example.com"
        }
    }
}
```

{% endtab %}
{% endtabs %}

## **Get a specific resource**

{% tabs %}
{% tab title="Request" %}

```
curl --location -g --request GET 'https://<server_url>/api/hr.employee/<id>?fields=[%22id%22,%20%22name%22,%20%22work_email%22]' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer <token>' \
    --data-raw '{}'
```

{% endtab %}

{% tab title="Response" %}

```
{
    "jsonrpc": "2.0",
    "id": null,
    "result": {
        "status_code": 200,
        "data": {
            "id": <id>,
            "name": "...",
            "work_email": "..."
        }
    }
}
```

{% endtab %}
{% endtabs %}
