Places
Places guides
The jobs Places is built for, each as the requests that do it.
Copy as MarkdownOpen in ChatGPT (opens in a new tab)Open in Claude (opens in a new tab)
Find places near a point
When you have coordinates (a device's position that the user shared, a place from an earlier answer, a geocoder of your own), send them. A point works the same in every country, and nothing has to be read from a name.
curl https://api.millionshort.com/v1/places \
-H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "bike repair",
"lat": 45.5231,
"lng": -73.5817,
"radius_m": 2000,
"limit": 10
}'import os
import requests
r = requests.post(
"https://api.millionshort.com/v1/places",
headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
json={
"query": "bike repair",
"lat": 45.5231,
"lng": -73.5817,
"radius_m": 2000,
"limit": 10
},
timeout=30,
)
r.raise_for_status()
print(r.json()["data"])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": "bike repair",
"lat": 45.5231,
"lng": -73.5817,
"radius_m": 2000,
"limit": 10
}),
});
if (!res.ok) throw new Error(`POST /v1/places failed: ${res.status}`);
const { data } = (await res.json()) as { data: unknown };
console.log(data);- Without
radius_mthe radius fits the search: it starts small and widens until there is enough to return. Withradius_mit is fixed, and a quiet area can return fewer places thanlimit, or none. - Every result carries
distance_mfrom the point. - To cover what a map shows, send its corners as
bbox,[south, west, north, east].distance_mis then measured from the middle of the box.
"sort": "distance"puts the nearest first. The default order is relevance.
Unless you ask with near_me, we never work out where a caller is. A position the user shared is always better than a guess from an address.
Search near an IP address or near the caller
When there are no coordinates, an IP address gives a rough answer: the city its network is in.
curl https://api.millionshort.com/v1/places -H "Authorization: Bearer $MILLIONSHORT_API_KEY" -H "Content-Type: application/json" -d '{
"query": "coffee",
"ip": "203.0.113.24",
"radius_m": 2000
}'import os
import requests
r = requests.post(
"https://api.millionshort.com/v1/places",
headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
json={
"query": "coffee",
"ip": "203.0.113.24",
"radius_m": 2000
},
timeout=30,
)
r.raise_for_status()
print(r.json()["data"])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": "coffee",
"ip": "203.0.113.24",
"radius_m": 2000
}),
});
if (!res.ok) throw new Error(`POST /v1/places failed: ${res.status}`);
const { data } = (await res.json()) as { data: unknown };
console.log(data);"resolved": { "name": "Toronto", "region": "ON", "country": "CA", "lat": 43.71, "lng": -79.4,
"kind": "ip", "accuracy": "city", "alternatives": [] }- Read
resolvedand say what was used. The answer names the city the address was placed in. Tell the user ("showing coffee near Toronto"), so a wrong guess is easy to correct. - It is a city, not a street. The search runs around the city's point. A mobile network or a VPN can be placed in another city altogether.
"near_me": trueuses the address the call itself comes from. From a browser extension or a desktop agent that is the user. From a server it is the server: there, send the user's own address asip, or their shared position aslatwithlng.- The address is not kept. It is used to look up a city and then dropped: not written to the request log, not kept, not returned. It goes no further than our own search service, which does the lookup and keeps nothing of it.
- An address we cannot place is a
location_not_foundwithdetails.paramofipornear_me. Fall back to asking the user where they are. - Placing an address works worldwide, more reliably in Canada and the United States.
How near is read
near takes a place by name. These are read:
| Kind | Examples |
|---|---|
| A city or town | Toronto, Denver, CO, Paris, France |
| A neighbourhood, with its city when the name is common | Leslieville, Toronto, Capitol Hill, Seattle |
| A postcode | M4M 1L4, 10001, SW1A 1AA |
| A street address | 100 Queen St W, Toronto |
| An intersection | Yonge and Eglinton |
| An airport code | YYZ |
What to know:
- Check
resolved. The answer says which placenearwas taken to mean, and lists others of that name inalternatives. "Cambridge" alone is a guess between several; "Cambridge, MA" and "Cambridge, UK" are not. - Add the state, province or country when a name is common. A name qualified that way is taken only when the place found is really there. Otherwise the answer is
location_not_found, never a different place. - A city is an area; a neighbourhood or a postcode is a point. Around a point, results carry
distance_mand can takeradius_m. Inside an area they carry no distance, because a city has no one point to measure from. - Names are read best in Canada and the United States. Neighbourhoods, postcodes, intersections and everyday trade words ("plumber", "dentist") are strongest there. Elsewhere, a plain city name usually works, and
latwithlngalways does. queryis never read as a location."query": "sushi leslieville"is a search for that name. Send"query": "sushi", "near": "Leslieville, Toronto".
When a name is not found, fall back in this order: add or correct the qualifier, try the city alone, then send coordinates.
Finding the right category
A query word is matched as well as we can read it; a category is exact. When the kind of place matters, look the category up once and send its id.
curl "https://api.millionshort.com/v1/places/categories?q=dental" -H "Authorization: Bearer $MILLIONSHORT_API_KEY"import os
import requests
r = requests.get(
"https://api.millionshort.com/v1/places/categories?q=dental",
headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
timeout=30,
)
r.raise_for_status()
print(r.json()["data"])const res = await fetch('https://api.millionshort.com/v1/places/categories?q=dental', {
headers: { Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}` },
});
if (!res.ok) throw new Error(`GET /v1/places/categories failed: ${res.status}`);
const { data } = (await res.json()) as { data: unknown };
console.log(data);The list is free. ?q= keeps the categories whose id holds every word, and ?parent=italian_restaurant lists what is directly under a category. Then:
curl https://api.millionshort.com/v1/places -H "Authorization: Bearer $MILLIONSHORT_API_KEY" -H "Content-Type: application/json" -d '{
"category": ["dental_clinic", "general_dentistry"],
"exclude_category": ["b2b_dental_lab"],
"near": "Austin, TX",
"has_phone": true
}'import os
import requests
r = requests.post(
"https://api.millionshort.com/v1/places",
headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
json={
"category": [
"dental_clinic",
"general_dentistry"
],
"exclude_category": [
"b2b_dental_lab"
],
"near": "Austin, TX",
"has_phone": True
},
timeout=30,
)
r.raise_for_status()
print(r.json()["data"])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({
"category": [
"dental_clinic",
"general_dentistry"
],
"exclude_category": [
"b2b_dental_lab"
],
"near": "Austin, TX",
"has_phone": true
}),
});
if (!res.ok) throw new Error(`POST /v1/places failed: ${res.status}`);
const { data } = (await res.json()) as { data: unknown };
console.log(data);- A category covers everything below it:
restaurantincludessushi_restaurant. Cuisines are categories, not a field of their own. categorytakes the id or the name:"Coffee shop"is read ascoffee_shop. One we do not have is a400, so a typo is not a silent empty list.- Every place lists its own ids in
categories. A result that is nearly right shows you which id to ask for next. - For a chain,
brandis more exact than a name inquery:"brand": "Tim Hortons". - Outside Canada and the United States, a category id is a safer way to say what you want than an everyday trade word in
query.
Opening hours and open_now
Opening hours are known for a small share of places. Plan for that.
- A place with no hours on record has
"hours": nulland"open_now": null.nullmeans "not known". It does not mean closed. "open_now": trueon the request keeps only places whose hours we know and that are open at this moment. Every place with unknown hours is left out, so the list is short and is mostly chains. The answer carries anhours_coveragewarning to say so."has_hours": truekeeps the places whose hours we know, open or not. It is the way to get a list you can reason about hours on.- For "what is open near here", it is often better to search without
open_now, readopen_nowon each result, and tell the user which places are known to be open and which are not known.
curl https://api.millionshort.com/v1/places \
-H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "pharmacy",
"near": "M5B 2H1",
"open_now": true
}'import os
import requests
r = requests.post(
"https://api.millionshort.com/v1/places",
headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
json={
"query": "pharmacy",
"near": "M5B 2H1",
"open_now": True
},
timeout=30,
)
r.raise_for_status()
print(r.json()["data"])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",
"near": "M5B 2H1",
"open_now": true
}),
});
if (!res.ok) throw new Error(`POST /v1/places failed: ${res.status}`);
const { data } = (await res.json()) as { data: unknown };
console.log(data);hours.weekly is in the place's local time, and hours.timezone names its time zone, so you can work out later openings yourself.
Read what a place says about itself
A place carries no reviews or descriptions. Its website is the way to more: search inside it with include_domains, or read its pages with Extract.
curl https://api.millionshort.com/v1/search \
-H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "query": "opening hours menu", "include_domains": ["harbourlanecoffee.example"], "num_results": 5 }'import os
import requests
r = requests.post(
"https://api.millionshort.com/v1/search",
headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
json={
"query": "opening hours menu",
"include_domains": [
"harbourlanecoffee.example"
],
"num_results": 5
},
timeout=30,
)
r.raise_for_status()
for hit in r.json()["data"]["results"]:
print(hit["position"], hit["title"], hit["url"])const res = await fetch('https://api.millionshort.com/v1/search', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"query": "opening hours menu",
"include_domains": [
"harbourlanecoffee.example"
],
"num_results": 5
}),
});
if (!res.ok) throw new Error(`POST /v1/search failed: ${res.status}`);
const { data } = (await res.json()) as {
data: { results: { position: number; title: string; url: string }[] };
};
for (const hit of data.results) console.log(hit.position, hit.title, hit.url);The same call as a tool of the MCP server:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "search",
"arguments": {
"query": "opening hours menu",
"include_domains": [
"harbourlanecoffee.example"
],
"num_results": 5
}
}
}A stale listing
A business that has closed may still be listed. last_seen is the day a place was last confirmed. For a recommendation that matters, prefer places seen recently, and say when a listing is old.
How popularity is scored
Every place has a popularity, a whole number from 0 to 100. It is worked out from what we already hold about the place, not from visits or reviews, and it says how well known and well attested a place is. Two kinds of evidence go into it:
- Reach. How popular the place's own website is, and how many places carry the same brand. A website on a platform that many unrelated places share (a social network, a site builder, a listings or ordering site) counts as no website of the place's own.
- The place's own evidence. How many independent sources list it, how complete its listing is (a phone number, a website, opening hours, a street address), and how recently it was seen.
Reach is worth at most 45 points, and it is scaled by the place's own evidence: a branch of a famous chain with little evidence of its own gets at most 18 of them. So a chain's shared website never makes every one of its branches 100. The place's own evidence is worth up to 55 points, so a well-attested independent place scores well without any reach at all. More of any kind of evidence never lowers the score.
What the numbers look like in practice: a well-attested branch of a large chain is usually in the 80s or 90s, a well-attested independent place in the 30s to 60s, and a sparse or old listing below 20. A score is a guide for ordering and filtering, not a rating of quality.
Most popular coffee places around a point, leaving out sparse listings:
curl https://api.millionshort.com/v1/places \
-H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "coffee",
"lat": 39.7392,
"lng": -104.9903,
"radius_m": 3000,
"sort": "popularity",
"min_popularity": 30,
"fields": ["name", "address", "popularity"]
}'import os
import requests
r = requests.post(
"https://api.millionshort.com/v1/places",
headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
json={
"query": "coffee",
"lat": 39.7392,
"lng": -104.9903,
"radius_m": 3000,
"sort": "popularity",
"min_popularity": 30,
"fields": [
"name",
"address",
"popularity"
]
},
timeout=30,
)
r.raise_for_status()
print(r.json()["data"])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": "coffee",
"lat": 39.7392,
"lng": -104.9903,
"radius_m": 3000,
"sort": "popularity",
"min_popularity": 30,
"fields": [
"name",
"address",
"popularity"
]
}),
});
if (!res.ok) throw new Error(`POST /v1/places failed: ${res.status}`);
const { data } = (await res.json()) as { data: unknown };
console.log(data);sort: "popularity" and min_popularity work on the best matches for the search (up to 100 of them), then order or filter those. To tell independent places from chains, look at brand (null for a place with no brand), not at a low score.
Popularity on the OpenStreetMap layer
A place of the OpenStreetMap layer has a popularity too, on the same 0 to 100 scale, but it is a different score. It is worked out from that OpenStreetMap listing alone, never from our other places or anything looked up about them. Four equal parts go into it:
- how complete the listing is (a phone number, a website, opening hours, a street address);
- how recently a mapper edited or checked it;
- how many times mappers have edited it;
- whether the listing names its brand's own reference entry.
The two scores are never compared or ordered together. With "layer": "both", sort: "popularity" and min_popularity apply to each list on its own score.
Two lists: our places and the OpenStreetMap layer
The OpenStreetMap layer is being switched on; until it is, layer is refused as an unknown parameter (400 INVALID_PARAM, free). From then on, "layer": "both" returns two lists side by side: results, our combined list, and osm_results, the OpenStreetMap layer. Each list is the answer its layer gives alone to the same request. The two are never merged, de-duplicated or ranked together, so the same place can be in both. If you show them, show them as two lists, and show "© OpenStreetMap contributors", linked to https://www.openstreetmap.org/copyright, next to the places of the OpenStreetMap layer. Each list is priced on its own. Data sources and licences has the licence and the terms.
curl https://api.millionshort.com/v1/places \
-H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "bakery",
"near": "Leslieville, Toronto",
"layer": "both",
"limit": 5,
"fields": ["name", "address", "phone"]
}'import os
import requests
r = requests.post(
"https://api.millionshort.com/v1/places",
headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
json={
"query": "bakery",
"near": "Leslieville, Toronto",
"layer": "both",
"limit": 5,
"fields": [
"name",
"address",
"phone"
]
},
timeout=30,
)
r.raise_for_status()
print(r.json()["data"])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": "bakery",
"near": "Leslieville, Toronto",
"layer": "both",
"limit": 5,
"fields": [
"name",
"address",
"phone"
]
}),
});
if (!res.ok) throw new Error(`POST /v1/places failed: ${res.status}`);
const { data } = (await res.json()) as { data: unknown };
console.log(data);Every place in osm_results carries layer, licence and attribution, whatever fields asked for.