> ## Documentation Index
> Fetch the complete documentation index at: https://docs.buntinglabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Population

> Calculate the number of people living in a radius around a point, according to US Census data.

This API endpoint estimates the population inside a circle from US Census data. You can provide either
a coordinate (latitude and longitude) or an address, plus a radius around the center.

### Request Parameters

<ParamField query="center" type="string" placeholder="-108.984,32.026">
  The center of the circle as a coordinate. Residents inside this circle will be counted in calculating
  the population count.

  The center coordinate is formatted as `longitude,latitude`. One of `center` or `address` is required.
</ParamField>

<ParamField query="address" type="string" placeholder="335 McAllister St, San Francisco, CA 94102">
  The center of the circle as an address. Residents inside this circle will be counted in calculating
  the population count.

  If the address is ambiguous, the best result will be chosen, which may or may not be the target address.
  To get the best results, provide the full address, including: building number, street name, city name,
  state, zip code, and country.

  An example address is `335 McAllister St, San Francisco, CA 94102`. One of `center` or `address` is required.
</ParamField>

<ParamField query="radius" type="number" placeholder="1000.0" required>
  The radius around the center, in meters. Maximum radius is 16,093 meters (10 miles).
</ParamField>

<ParamField query="api_key" type="string" placeholder="demo" required>
  Your account's API key. You can create an API key by
  [registering for an account](https://buntinglabs.com/account/register)
  and copy and paste it from your [account dashboard](https://buntinglabs.com/dashboard).
</ParamField>

### Response

When population is successfully calculated, a 200 OK response will be
issued, with `Content-Type: application/json`. The body will have a property `population`
which will be a number representing the number of residents in the circle,
estimated from US Census data.

<ResponseField name="population" type="number">
  The expected number of residents in the circle, based on US census data.
</ResponseField>

<ResponseField name="source" type="string">
  A descriptive source for the data, including the year the data was collected.
</ResponseField>

In the event of an error, an error response will be issued, usually with a 5xx error code.
The error will be JSON-formatted, with an `error` field describing the cause.

<ResponseField name="error" type="string">
  The error message if the extract request parameters were incorrectly formatted.

  This response field will not be present if the extract succeeds.
</ResponseField>

### Data License

This API serves data from the [US Census Bureau](https://www.census.gov), which is
freely available.

<RequestExample>
  ```bash cURL
  curl --get 'https://osm.buntinglabs.com/v1/census/population' \
       --data "center=-118.328228,33.342819" \
       --data "radius=1000.0" \
       --data "api_key=demo"
  ```

  ```javascript JavaScript
  const params = new URLSearchParams({
    center: "-118.328228,33.342819",
    radius: "1000.0",
    api_key: "demo"
  });

  fetch(`https://osm.buntinglabs.com/v1/census/population?${params}`)
    .then(response => response.json())
    .then(data => console.log(data));
  ```

  ```python Python
  import requests

  params = {
    "center": "-118.328228,33.342819",
    "radius": "1000.0",
    "api_key": "demo"
  }

  response = requests.get("https://osm.buntinglabs.com/v1/census/population", params=params)
  print(response.json())
  ```
</RequestExample>

<ResponseExample>
  ```json Response
  {
    "population": 3364,
    "source": "US Census Bureau"
  }
  ```
</ResponseExample>
