🚀 Deep populate in API Maker
Tags: api, automation
Published: 2023-09-28 10:04:41

- Populate data from the multiple collection, databases or instances we use deep in the request payload.

- We can provide deep information at two places:
    - In collection [schema](https://docs.apimaker.dev/v1/docs/schema/schema.html#isautoincrementbydb)
    - In payload it self, [check more](https://docs.apimaker.dev/v1/docs/apis-all/schema-apis/auto-generated-schema-based-query-for-get-data-api.html#request-method-post)

### simple deep

Here,
- s_key = Source table field name
- t_col = Target table name
- t_key = Target table field name
- t_instance = The instance name in which target table is present.
- t_db = The database name in which the target table is present.

```json
{
    "find": {
        "owner_id": 1
    },
    "deep": [
        {
            "s_key": "owner_id",
            "t_instance": "mysql",
            "t_db": "inventory",
            "t_col": "customers",
            "t_key": "customer_id"
        }
    ]
} 
```


### Add deep information in schema

- Set instance, database, collection, and column in [schema](https://docs.apimaker.dev/v1/docs/schema/schema.html) of the collection and provide only 's_key'(source key) in the deep to get deep data.

Request Payload
```json
{
    "deep": [
        {
            "s_key": "owner_id"
        }
    ]
}
```


### Set deep for multiple fields

- You can set deep inheritance using dot.

Request Payload
```json
{
    "deep": [
        {
            "s_key": "owner_id"
        },
        {
            "s_key": "owner_id.shipping_id"
        }
    ]
}
```


### Deep inheritance

- Write 'deep' in to the 'deep' and you will get inherited data. 

Request Payload
```json
{
    "deep": [
        {
            "s_key": "price",
            "t_col": "orders",
            "t_key": "total",
            "select": "pincode",
            "deep": [
                {
                    "s_key": "shipping_id",
                    "t_col": "customers",
                    "t_key": "shipping_id",
                    "select": "phone"
                },
                {
                    "s_key": "shipping_id.pincode",
                    "t_col": "orders",
                    "t_key": "pincode"
                }
            ]
        }
    ]
}
```

### Circular dependency

- API Maker automatically handle the circular dependency so you do not need to take care of it.

Request Payload
```json
{
    "deep": [
        {
            "s_key": "owner_id",
            "t_col": "customers",
            "t_key": "customer_id",
            "deep": [
                {
                    "s_key": "customer_id",
                    "t_col": "products",
                    "t_key": "owner_id",
                    "select": "owner_id",
                    "deep": [
                        {
                            "s_key": "owner_id",
                            "t_col": "customers",
                            "t_key": "customer_id",
                            "select": "customer_id"
                        }
                    ]
                }
            ]
        }
    ]
}
```

To get more information about API Maker APIs please refer [API Maker documentation](https://docs.apimaker.dev/).

API Maker deep feature [video](https://youtu.be/ZvGmImAbaCA).

Websites
https://apimaker.dev

Follow on twitter
https://twitter.com/api_maker

Linked In
https://www.linkedin.com/company/api-maker

API Maker Youtube channel
https://www.youtube.com/@api_maker