# Places quickstart

Places near a name, then near a point, then what comes back.

## 1. Find places near a name

```bash
curl https://api.millionshort.com/v1/places \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "coffee",
    "near": "Leslieville, Toronto",
    "limit": 5
  }'
```

```python
from millionshort import MillionShort

client = MillionShort(api_key=os.environ["MILLIONSHORT_API_KEY"])

r = client.places("coffee", near="Leslieville, Toronto", limit=5)
for place in r.results:
    print(place["name"], place["address"]["formatted"], place["phone"])
print(r.usage.credits, r.request_id)
```

```ts
import { MillionShort } from 'millionshort';

const client = new MillionShort({ apiKey: process.env.MILLIONSHORT_API_KEY });

const r = await client.places({ query: 'coffee', near: 'Leslieville, Toronto', limit: 5 });
for (const place of r.results) {
  console.log(place.name, place.address.formatted, place.phone);
}
console.log(r.usage?.credits, r.requestId);
```

`query` says what you are looking for: a kind of place, a name or a brand. `near` says where, as a name. The two are separate on purpose: nothing in `query` is read as a location.

## 2. Or around a point

When you already have coordinates, send them. This is the most reliable way to say where, in any country.

```bash
curl https://api.millionshort.com/v1/places \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "pharmacy",
    "lat": 43.6532,
    "lng": -79.3832,
    "radius_m": 1000
  }'
```

```python
import os

import requests

r = requests.post(
    "https://api.millionshort.com/v1/places",
    headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
    json={
        "query": "pharmacy",
        "lat": 43.6532,
        "lng": -79.3832,
        "radius_m": 1000
    },
    timeout=30,
)
r.raise_for_status()
print(r.json()["data"])
```

```ts
const res = await fetch('https://api.millionshort.com/v1/places', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "query": "pharmacy",
    "lat": 43.6532,
    "lng": -79.3832,
    "radius_m": 1000
  }),
});
if (!res.ok) throw new Error(`POST /v1/places failed: ${res.status}`);
const { data } = (await res.json()) as { data: unknown };
console.log(data);
```

Where to look is one of `near`, `lat` with `lng`, `bbox`, `ip`, `near_me` or `neighbourhood`. Send one. The address your request comes from is used only when you send `"near_me": true`. [Parameters](https://millionshort.com/docs/places/parameters#request) has every field with an example, including the filters (`category`, `brand`, `has_phone`, `open_now` and the rest), `sort` and `fields`.

## 3. Read the answer

```json
{
  "data": {
    "resolved": {
      "name": "Leslieville",
      "region": "ON",
      "country": "CA",
      "lat": 43.66883,
      "lng": -79.3267,
      "kind": "point",
      "accuracy": null,
      "alternatives": []
    },
    "results": [
      {
        "id": "pawx2ncgk7b6wsi3t",
        "name": "Harbour Lane Coffee",
        "category": { "id": "cafe", "label": "Cafe" },
        "categories": ["food_and_drink", "casual_eatery", "cafe"],
        "address": {
          "street": "1180 Queen St E",
          "unit": null,
          "city": "Toronto",
          "region": "ON",
          "postcode": "M4M 1L4",
          "country": "CA",
          "formatted": "1180 Queen St E, Toronto, ON M4M 1L4, CA"
        },
        "lat": 43.662514,
        "lng": -79.333905,
        "distance_m": 912,
        "phone": "+14165550142",
        "website": "https://harbourlanecoffee.example/",
        "brand": null,
        "hours": null,
        "open_now": null,
        "last_seen": "2026-11-02",
        "popularity": 46
      }
    ],
    "attribution": {
      "text": "Place data from open data sources. Credits and licences: https://millionshort.com/credits#places",
      "url": "https://millionshort.com/credits#places"
    }
  },
  "request_id": "req_01JD0PLACES7Q2M4T8V",
  "usage": { "credits": 1, "cost_usd": 0.001, "breakdown": { "places": 1 } },
  "warnings": []
}
```

- `resolved` says what `near` was taken to mean. Check it: "Springfield" is many places. `alternatives` lists other places of that name.
- A field we do not know is `null`. Here the opening hours are not known, so `hours` and `open_now` are both `null`. That is the usual case.
- `last_seen` is the day the place was last confirmed, not an edit by its owner.
- `popularity` (0 to 100) says how well known and well attested the place is. See [How popularity is scored](https://millionshort.com/docs/places/guides#how-popularity-is-scored).

## 4. Show the credit line

If you show these places to people, you must show `data.attribution.text`, or a link to `data.attribution.url`, with them. Every answer carries it, and no parameter removes it. See [Attribution](https://millionshort.com/docs/places/parameters#attribution), and the [data notices](https://millionshort.com/docs/places/parameters#data-notices) that go with the data. Places asked for with `"layer": "osm"` or `"layer": "both"` are a separate list under their own licence, and each carries its own credit: see [Data sources and licences](https://millionshort.com/docs/places/parameters#data-sources-and-licences).

## Next

- [Parameters](https://millionshort.com/docs/places/parameters): every field of the request and the answer.
- [Guides](https://millionshort.com/docs/places/guides): searching around a point, near an IP address, how `near` is read, finding the right category, and opening hours.
- [Pricing and limits](https://millionshort.com/docs/places/pricing): 1 credit for up to 10 places.
