# Bulk Data API

## Bulk Data API with Latitude & Longitude

<mark style="color:green;">`POST`</mark> `https://dataserving-in.geoiq.io/production/v1.0/getvariablesbulk`

#### Headers

| Name                                           | Type   | Description        |
| ---------------------------------------------- | ------ | ------------------ |
| x-api-key<mark style="color:red;">\*</mark>    | String | Authentication key |
| Content-Type<mark style="color:red;">\*</mark> | String | application/json   |

#### Request Body

| Name                                        | Type   | Description                                                                                           |
| ------------------------------------------- | ------ | ----------------------------------------------------------------------------------------------------- |
| lat<mark style="color:red;">\*</mark>       | Float  | Latitude co-ordinates should be between -90 to 90                                                     |
| lng<mark style="color:red;">\*</mark>       | Float  | Longitude co-ordinates should be between -180 to 180                                                  |
| variables<mark style="color:red;">\*</mark> | String | Comma separated list of variables to be fetched. Maximum 50 variables can be fetched in a single call |

{% tabs %}
{% tab title="200: OK Success" %}

```json
{
    "status": 200,
    "body": {
        "data": {
            "w_pop_tt": 27950,
            "p_health_hp_np": 0.25045,
            "p_restaurant_rt_np": 1.39535,
            "p_retail_gc_np": 0.93023
        },
        "status": 200
    }
}
```

{% endtab %}

{% tab title="400: Bad Request Invalid input, object invalid" %}

{% endtab %}

{% tab title="403: Forbidden Authorization Failure. Invalid key." %}

{% endtab %}
{% endtabs %}

#### Sample Request

```json
headers = {
    "x-api-key": "Authentication key",
    "Content-Type": "application/json"
}
```

```json
body = {
    "lat": 24.966130,
    "lng": 77.592247,
    "variables": "p_education_cc_np_pincode,w_pop_tt_200,w_pop_tt_500,w_pop_tt_1000"
}
```

#### Sample Response

```json
{
    "data": {
        "w_pop_tt_200": 27950,
        "w_pop_tt_500": 29950,
        "w_pop_tt_1000": 279505,
        "p_education_cc_np_pincode": 0.93023
    },
    "status": 200
}
```

```python
""" Sample Python Code """

import json
import requests

url = "https://dataserving-in.geoiq.io/production/v1.0/getvariablesbulk"

payload = json.dumps({
  "lat": 12.909151,
  "lng": 77.6371584,
  "variables": "p_education_cc_np_pincode,w_pop_tt_200,w_pop_tt_500,w_pop_tt_1000"
})

headers = {
  'x-api-key': '<Authentication key>',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
```

## Bulk Data API with Address

<mark style="color:green;">`POST`</mark> `https://dataserving-in.geoiq.io/production/v1.0/getvariablesbulk`

#### Headers

| Name                                           | Type   | Description        |
| ---------------------------------------------- | ------ | ------------------ |
| x-api-key<mark style="color:red;">\*</mark>    | String | Authentication key |
| Content-Type<mark style="color:red;">\*</mark> | String | application/json   |

#### Request Body

| Name                                        | Type   | Description                                                                                           |
| ------------------------------------------- | ------ | ----------------------------------------------------------------------------------------------------- |
| address<mark style="color:red;">\*</mark>   | String | address of the place                                                                                  |
| pincode                                     | String | pincode of the place                                                                                  |
| variables<mark style="color:red;">\*</mark> | String | Comma separated list of variables to be fetched. Maximum 50 variables can be fetched in a single call |

{% tabs %}
{% tab title="200: OK Success" %}

```javascript
{
    "status": 200,
    "body": {
        "data": {
            "w_pop_tt": 27950,
            "p_health_hp_np": 0.25045,
            "p_restaurant_rt_np": 1.39535,
            "p_retail_gc_np": 0.93023
        },
        "status": 200
    }
}
```

{% endtab %}

{% tab title="400: Bad Request Invalid input, object invalid." %}

```javascript
{
    // Response
}
```

{% endtab %}

{% tab title="403: Forbidden Authorization failure. Invalid key." %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

#### Sample Request

```json
headers = {
    "x-api-key": "Authentication key",
    "Content-Type": "application/json"
}
```

<pre class="language-json"><code class="lang-json"><strong>body = {
</strong>    "address": "35, Vajarahalli, 9th Mile, Kanakapura Road, Bangalore",
    "pincode": "560062",
    "variables": "p_education_cc_np_pincode,w_pop_tt_200,w_pop_tt_500,w_pop_tt_1000"
}
</code></pre>

#### Sample Response

```json
{
    "data": {
        "w_pop_tt_200": 27950,
        "w_pop_tt_500": 29950,
        "w_pop_tt_1000": 279505,
        "p_education_cc_np_pincode": 0.93023
    },
    "status": 200
}
```

```python
""" Sample Python Code """

import json
import requests

url = "https://dataserving-in.geoiq.io/production/v1.0/getvariablesbulk"

payload = json.dumps({
  "address": "GeoIQ,Urbanvault 591, GF, 22nd cross, 15th Main Rd, HSR Layout, Bengaluru",
  "pincode": "560102",
  "variables": "p_education_cc_np_pincode,w_pop_tt_200,w_pop_tt_500,w_pop_tt_1000"
})

headers = {
  'x-api-key': '<Authentication key>',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
```
