> For the complete documentation index, see [llms.txt](https://docs.geoiq.io/us-api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.geoiq.io/us-api-docs/reference/api-reference-usa/latest/data-api.md).

# Data API

## Data API with Latitude & Longitude

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

#### 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                                                  |
| radius<mark style="color:red;">\*</mark>    | Integer | (in meters) should be between 100 to 2000                                                             |
| 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":40.0300971,
    "lng":-75.648135,
    "variables": "cen_10_bk_demo_tot_pop,cen_10_bk_tot_urb,cen_10_bk_tot_rur,acs5_19_pop_wht_blockgroup",
    "radius": 500
}
```

#### Sample Response

```json
{
    "status": 200,
    "body": {
        "data": {
            "cen_10_bk_demo_tot_pop": 789,
            "cen_10_bk_tot_urb": 388,
            "cen_10_bk_tot_rur": 0,
            "acs5_19_pop_wht_blockgroup": 432
        },
        "status": 200
    }
}
```

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

import json
import requests

url = "https://dataserving-us.geoiq.io/production/v1.0/getvariables"

payload = json.dumps({
  "lat": 40.0300971,
  "lng": -75.648135,
  "radius": 500,
  "variables": "cen_10_bk_demo_tot_pop,cen_10_bk_tot_urb,cen_10_bk_tot_rur,acs5_19_pop_wht_blockgroup"
})

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

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

print(response.text)
```

## Data API with Address

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

#### 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                                                                                  |
| radius<mark style="color:red;">\*</mark>    | Integer | (in meters) should be between 100 to 2000                                                             |
| 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": "Manhattan, New York, NY, USA",
    "variables": "cen_10_bk_demo_tot_pop,cen_10_bk_tot_urb,cen_10_bk_tot_rur,acs5_19_pop_wht_blockgroup",
    "radius": 500
}
</code></pre>

#### Sample Response

```json
{
    "status": 200,
    "body": {
        "data": {
            "cen_10_bk_demo_tot_pop": 15930,
            "cen_10_bk_tot_urb": 9552,
            "cen_10_bk_tot_rur": 0,
            "acs5_19_pop_wht_blockgroup": 1565
        },
        "status": 200
    }
}
```

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

import json
import requests

url = "https://dataserving-us.geoiq.io/production/v1.0/getvariables"

payload = json.dumps({
  "address": "Manhattan, New York, NY, USA",
  "radius": 500,
  "variables": "cen_10_bk_demo_tot_pop,cen_10_bk_tot_urb,cen_10_bk_tot_rur,acs5_19_pop_wht_blockgroup"
})

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

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

print(response.text)
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.geoiq.io/us-api-docs/reference/api-reference-usa/latest/data-api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
