# Tryton API: Getting nested objects using fields

**URL:** https://discuss.tryton.org/t/tryton-api-getting-nested-objects-using-fields/6171
**Category:** Developer
**Tags:** party
**Created:** [May 23, 2023, 2:39pm UTC](https://discuss.tryton.org/t/tryton-api-getting-nested-objects-using-fields/6171 "2023-05-23T14:39:19Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![meadev](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/meadev/32/2317_2.png) [@meadev](https://discuss.tryton.org/u/meadev)
#### Post date: [May 23, 2023, 2:39pm UTC](https://discuss.tryton.org/t/tryton-api-getting-nested-objects-using-fields/6171/1 "2023-05-23T14:39:19Z")

</div>

Hello,  
We are consuming our client’s API (base on Tryton), but there custom modules are not documented. I would like if know if there any possible optimisation in the folowing calls:  
the need: given a **party\_id** , we need to fin all the **covered\_elements** data related to the party contracts.  
Current solution:  
Call 1: {{WEB\_URL}}/party/ **89** /?\_fields=contracts  
Result:

```auto
{
    "_": "party.party",
    "id": 89,
    "siren": null,
    "ssn": "123",
    "death_date": null,
    "forced_claim_bank_account": {
        "_": "bank.account",
        "id": null
    },
    "gender": "female",
    "commercial_name": null,
    "contracts": [
        {
            "_": "contract",
            "id": 121253,
            "signature_date": "2020-10-02",
            "subscriber": {
                "_": "party.party",
                "id": 89
            },
            "rec_name": "CT8901"
        }
    ]
}

```

Call 2: {{WEB\_URL}}/contract/121253/?\_fields= covered\_elements  
Result:

```auto
{
    "_": "contract",
    "id": 121253,
    "signature_date": "2020-10-02",
    "contract_number": "CT8901",
      "covered_elements": [
          {
              "_": "contract.covered_element",
              "id": 79221,
              "write_date": "2022-08-23 19:17:42.174",
              "party": {
                  "_": "party.party",
                  "id": 89
              },
          {
              "_": "contract.covered_element",
              "id": 79222,
              "write_date": "2022-08-23 19:19:27.114",
              "party": {
                  "_": "party.party",
                  "id": 90
              },
          }
      ],
}

```

The question: is there any way to reach Contract.covered\_elements directly from the 1st call ?  
something like:  
{{WEB\_URL}}/party/ **89** /?\_fields=contracts,contracts.covered\_elements  
{{WEB\_URL}}/party/ **89** /?\_fields=contracts,contracts:covered\_elements  
…  
Needed result:

```auto
{
    "_": "party.party",
    "id": 89,
    "siren": null,
    "ssn": "123",
    "death_date": null,
    "forced_claim_bank_account": {
        "_": "bank.account",
        "id": null
    },
    "gender": "female",
    "commercial_name": null,
    "contracts": [
        {
            "_": "contract",
            "id": 121253,
            "signature_date": "2020-10-02",
            "subscriber": {
                "_": "party.party",
                "id": 89
            },
            "rec_name": "CT8901",
        "covered_elements": [
            {
                "_": "contract.covered_element",
                "id": 79221,
                "write_date": "2022-08-23 19:17:42.174",
                "party": {
                    "_": "party.party",
                    "id": 89
                },
            {
                "_": "contract.covered_element",
                "id": 79222,
                "write_date": "2022-08-23 19:19:27.114",
                "party": {
                    "_": "party.party",
                    "id": 90
                },
            }
        ],
        }
    ]
}

```

Thanks.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [May 23, 2023, 3:56pm UTC](https://discuss.tryton.org/t/tryton-api-getting-nested-objects-using-fields/6171/2 "2023-05-23T15:56:28Z")

</div>

Which API are you talking because it does not look like the [RPC](https://docs.tryton.org/projects/server/en/latest/ref/rpc.html) api of Tryton?

---

<div class="post-metadata">

### Author: ![meadev](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/meadev/32/2317_2.png) [@meadev](https://discuss.tryton.org/u/meadev)
#### Post date: [May 24, 2023, 9:45am UTC](https://discuss.tryton.org/t/tryton-api-getting-nested-objects-using-fields/6171/3 "2023-05-24T09:45:51Z")

</div>

Our client claim it’s a custom solution based on Tryton, i searched on the tryton documentation about API but fount nothing similar to what we are consuming.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [May 24, 2023, 11:54am UTC](https://discuss.tryton.org/t/tryton-api-getting-nested-objects-using-fields/6171/4 "2023-05-24T11:54:44Z")

</div>

So it is probably a custom API developed by the client. You should ask for their documentation.
