# A store finder on your own data, scoped to your key

`PUT /places` stores up to 10,000 of your own places against your API key, and from that moment `GET /places/search` runs ranked full-text search over them while `GET /places/nearest` returns the closest N by straight line. No other key can ever read, search or delete your dataset, and every request is one metered Standard call at 0.05p on the entry band. It is a store-finder API built on the one dataset you hold with more certainty than any map provider: your own locations.

## The store finder problem is a data problem, not a search problem

Most store finders bolt a generic POI database onto a search box and then fight the database. The world index knows a version of your estate: the branch that rebranded last year under its old name, the store that closed in March still open, the franchise site missing entirely. You end up writing correction layers over data you never controlled in the first place. `/places` inverts that. You upload the authoritative list, because you are the authority on it, and search runs over exactly that list and nothing else.

This is the opposite end of the spectrum from [our first-party geocoding engine](/news/geocoding), which searches a world index built from OpenStreetMap and answers "where is Buckingham Palace". `/places/search` answers "which of my branches matches Croydon", it consults only what you uploaded, and it uses the same ranking engine that powers the territory geocode indexes. Same machinery, disjoint data, and the disjointness is the feature.

## What do the five routes do?

Upload, fetch, delete, search, nearest. The full contract is in the [API reference](/docs/api-reference); the shape of it:

| Method | Path | What it does |
|---|---|---|
| PUT | `/places` | Replace your dataset: body `{"places": [{"id", "name", "lat", "lon", ...}]}`, up to 10,000 places, returns `{"count", "updated_at"}` |
| GET | `/places` | Fetch your full dataset plus meta; 404 before the first upload |
| DELETE | `/places` | Remove dataset and index; 204, idempotent |
| GET | `/places/search` | Ranked full-text search: `q` (required), optional `lat`/`lon` proximity focus (both or neither), `limit` 1 to 50, `category` filter |
| GET | `/places/nearest` | Straight-line nearest-N: `lat`, `lon`, `limit` |

```bash
export BASE=https://api.mapmap.ai
export API_KEY=snk_...

curl -fsS -X PUT "$BASE/places" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"places": [{"id": "croydon-01", "name": "MyBrand Croydon", "lat": 51.3762,
       "lon": -0.0982, "locality": "Croydon", "categories": ["store"]}]}'

curl -fsS "$BASE/places/search?q=MyBrand+Croydon&lat=51.5&lon=-0.12" \
  -H "Authorization: Bearer $API_KEY"
```

Search hits come back ranked, each carrying the place exactly as you uploaded it, a relevance `score` (text match, importance weight and proximity decay multiplied together, comparable only within one response) and `distance_m` from your focus point when you gave one:

```json
{
  "query": "MyBrand Croydon",
  "count": 1,
  "results": [
    {
      "place": {
        "id": "croydon-01",
        "name": "MyBrand Croydon",
        "lat": 51.3762,
        "lon": -0.0982,
        "locality": "Croydon",
        "categories": ["store"]
      },
      "score": 14.2,
      "distance_m": 14520.0
    }
  ]
}
```

Each place record carries optional `alt_names` (at most 8), `categories` (at most 16, matched case-insensitively by the `category` filter), address parts (`street`, `locality`, `region`, `postcode`, `country_code`), an `importance` weight in [0, 1] and a free-form `properties` object of up to 2 KiB that round-trips untouched: opening hours, phone numbers, internal ids, whatever your front end needs back. More than 10,000 places is a 413 (`places-too-many`); per-field validation failures are a 422 (`invalid-places`) whose `problems` list names each offender, so a bad row in a 9,000-place upload tells you which row.

## How do you rank by drive time instead of straight line?

Feed the nearest candidates into `POST /matrix` as targets, which is the documented pattern, because `/places/nearest` is haversine distance and the nearest store as the crow flies is not always the nearest by road. A branch across the river can beat one three streets away on straight-line distance and lose badly once a vehicle has to find a bridge.

```bash
curl -fsS "$BASE/places/nearest?lat=51.5074&lon=-0.1278&limit=10" \
  -H "Authorization: Bearer $API_KEY"

curl -fsS -X POST "$BASE/matrix" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "sources": [{ "lat": 51.5074, "lon": -0.1278 }],
  "targets": [
    { "lat": 51.3762, "lon": -0.0982 },
    { "lat": 51.4613, "lon": -0.3037 }
  ],
  "costing": "auto"
}'
```

Take the candidates from the first call, pass their coordinates as `targets` in the second with the customer's position as the single source, and sort by the returned `durations[0][j]` (row-major, seconds). Swap `costing` for `truck` with a dimensioned profile and the ranking respects what an HGV can actually drive. Because [a matrix bills one call per started block of 25 elements](/news/matrix-api), a 1 x 10 matrix is a single call: the whole flow, nearest plus matrix, is two Standard calls, 0.1p.

## What it costs

All five routes are Standard class, one metered call per request, and there is no premium for searching your own data over anyone else's.

| Item | Value |
|---|---|
| Price class | Standard |
| Rate | 0.05p per call, 0.03p beyond 1M calls/month, 0.02p beyond 10M |
| Metering | One call per request, all five routes alike |
| Dataset cap | 10,000 places per key |
| Free tier | 50,000 included standard calls per month after email verification |

At the entry band, a store-finder page doing one search per visitor costs 0.05p per visitor, and the free tier absorbs the first 50,000 requests a month outright.

## What it does not do

It does not rank by drive time, hold more than 10,000 places or patch a dataset in place, and each of those is a deliberate boundary rather than a gap we forgot:

- `/places/nearest` is straight-line only. Drive-time ranking is the matrix pattern above, deliberately kept as a separate call so you choose the costing rather than inheriting ours.
- The cap is 10,000 places per key, enforced with a hard 413. This is a store-finder store, not a general POI warehouse.
- `PUT /places` replaces the whole dataset. There is no partial update; upload the full list each time and treat your source of truth as the master.
- `properties` is stored and returned, never indexed. You cannot search on the contents of that object; searchable text lives in `name`, `alt_names` and the address parts.
- Datasets are strictly per key. That is the isolation guarantee, and it also means a key rotation needs a re-upload under the new key.
- A self-hosted gateway without the customer-places store configured answers 404 on all five routes.

## Try it

Sign up for a [free key](/signup), `PUT` your branch list and point your store-finder page at `/places/search`; the hosted gateway serves all five routes today. On the client side, the web SDK's `PlacesLayer` draws the same list as pins on a MapMap map and its `nearestByDriveTime()` helper runs the matrix ranking above for you. It takes a places array from your own code rather than reading your uploaded dataset back out of the gateway, so hand it your source list or fetch it with `GET /places` first. The [store-finder guide](/docs/store-finder) walks the whole flow, and the [SDK docs](/docs/sdks) cover the layer.

Map tiles derive from OpenStreetMap, so credit "© OpenStreetMap contributors" when you render them.
