Custom scores
Copy link

Score homes or H3 cells against your own rules, using our data. You define what matters in JSON: the checks, how much each one counts and which ones are must-haves. We then work out the result for every home or cell, and return every value, whether each check was met and your points.

Custom scores do not decide what makes a good place. There are no personas and no built-in model.

Each check reads one field from another dataset's row for the H3 cell (Proximity, Neighbourhood or Open spaces), so it is as up to date as that dataset. custom_scores.fields on /v1/catalog/{country} lists every field a check can read.

This page answers questions such as:

Request headers
Copy link

Required authentication header. Use the same application id as for the TravelTime API.

string

Required authentication header.

Score a list of homes
Copy link

POST /v1/custom-scores

Check a list of homes against a profile you define. The response has one row per home, in the order sent. There is no GET request, because the profile is sent as a JSON body.

Parameters
Copy link

ParameterType · defaultWhat it doesExample
homes[{id, lat, lng}] · —1 to 1,000 homes, all in the same country. id is your own identifier and is returned unchanged.{"id": "listing-1", "lat": 51.5288, "lng": -0.1309}
profile.checks{key: check} · —1 to 50 checks, each keyed by a name of your choice. Each row returns the check under the same name. One profile per request."quiet": {"field": "neighbourhood.noise.max_lden_db", "max": 55, "weight": 2}

Each check takes the following keys:

KeyType · defaultWhat it does
fieldfield · —The field to read, named exactly as it appears in the rows, as <dataset>.<path in the row> (for example proximity.walk_s.supermarket). A field that is not listed in custom_scores.fields on /catalog returns a 400 error.
minnumber · —The check is met when the value is at least this.
maxnumber · —The check is met when the value is at most this. Each check needs min, max or both.
weightwhole number 1–1000 · —The points given when the check is met. If you leave out every weight, the response shows only whether each check was met, with no score.
musttrue | false · falseMakes the check a must-have. If it fails, musts_met is false, and an area search leaves the H3 cell out.
labeltext · —A label for your own UI. It is not returned.

The endpoint also takes the Paging parameters limit and cursor in the body. A page has 100 rows by default. limit can be up to 10,000, or up to 100 when a check reads a proximity.bands. field.

Each row contains:

  • id
  • cell: the resolution-9 H3 cell that contains the home
  • checks: keyed as you keyed them, each {met, value}, with the value in the field's own unit (seconds, dB, a count or a share)
  • musts_met
  • score {points, out_of, share}: returned when any check has a weight, even when a must-have fails

A null value is never met. If the field's own row lists it in missing, the check also carries the reason given there (no_residents, over_900_s and so on).

CodeHTTPWhen
invalid_homes400No homes are sent, more than 1,000 are sent, or a lat or lng is out of range.
invalid_profile400The profile is outside one of the limits in the tables above.
unknown_check_field400A field that no row contains. The message suggests the closest match when there is one, and allowed lists every field.
out_of_coverage400A home is outside the countries we serve, or in a country that custom scores are not built for yet. param is homes.
mixed_countries400The homes are in more than one country. Send each country's homes in a separate request.
invalid_limit400limit is below 1 or over 10,000, or over 100 when a check reads a proximity.bands. field.
Any Paging error code
Examples

This example sends a buyer's own list in JSON: what they need, how much each item matters, and one must-have. The Euston flat gets 8 of 10 points but is noisy (81.3 dB). The Milton Keynes house gets 2 of 10. It has two parks of 5 ha or more within 15 minutes, but the nearest supermarket is a 12-minute walk, there is one gym within 10 minutes and the transit rating is 21. Both homes pass the must-have (not in a flood zone). Every value is returned, so your app can show why each home scored as it did.

Request

curl -X POST -H "X-Application-Id: YOUR_APP_ID" -H "X-Api-Key: YOUR_APP_KEY" -H "Content-Type: application/json" \
  -d '{
    "homes": [
      {"id": "listing-1", "lat": 51.5288, "lng": -0.1309},
      {"id": "listing-2", "lat": 52.023, "lng": -0.77}
    ],
    "profile": {
      "checks": {
        "supermarket": {"field": "proximity.walk_s.supermarket", "max": 600, "weight": 3, "label": "Supermarket in 10 min"},
        "quiet": {"field": "neighbourhood.noise.max_lden_db", "max": 55, "weight": 2, "label": "Quiet street"},
        "gyms": {"field": "proximity.bands.walk.600.category_counts.gym", "min": 3, "weight": 1, "label": "3+ gyms in 10 min"},
        "no_flood": {"field": "neighbourhood.flood.zone", "max": 1, "must": true, "label": "Not in a flood zone"},
        "transit": {"field": "proximity.ratings.transit", "min": 70, "weight": 2, "label": "Good public transport"},
        "big_park": {"field": "proximity.bands.walk.900.over_5ha_count", "min": 1, "weight": 2, "label": "A park of 5+ ha in 15 min"}
      }
    }
  }' \
  "https://data.traveltimeapp.com/v1/custom-scores"
200 · 2 homes

Shade = checks.supermarket.value2377422 H3 cells; click a cell to open its row.

If you leave out the weights, each check returns only whether it was met, with its value, and the row has no score.

H3 cells that pass your checks
Copy link

POST /v1/custom-scores/cells

Use the same profile to search for H3 cells.

An area search (near, bbox or country) returns only the H3 cells where every must-have is met, sorted by most points first, with ties broken by cell id. It stops at the top 10,000. next_cursor pages through them and is null at the end of the top 10,000.

With at or cells, every H3 cell you send is returned once, in the order sent, whether or not it meets the must-haves.

In a country that custom scores are not built for yet, a search returns no rows (matched 0).

Parameters
Copy link

ParameterType · defaultWhat it doesExample
profile{checks: …} · —The same profile as for POST /v1/custom-scores (see above).{"checks": {...}}

The endpoint also takes the Location parameters (near, radius_m, bbox, cells, at, country) and the Paging parameters (limit, cursor) in the body. Send cells as a JSON list of resolution-9 H3 cells, or as compacted ids of any resolution up to 9, which are read as the res-9 cells inside them, up to 200,000.

Each row contains cell, checks, musts_met and score, as above, except that only a null value from a proximity field carries a reason.

The top level of the response contains:

  • matched: the H3 cells that pass every must-have. With no must-haves, this is every cell we hold data for in the area, or every cell sent with at or cells
  • returned: the number of rows in all. For an area search, this is the smaller of matched and 10,000. With at or cells, it is the number of H3 cells sent
CodeHTTPWhen
invalid_limit400limit is below 1 or over 10,000 (allowed_max 10000).
invalid_profile400The profile is outside one of the limits in the tables above.
unknown_check_field400A field that no row contains. The message suggests the closest match when there is one, and allowed lists every field.
field_unindexed503The field is listed on /catalog, but this build cannot search H3 cells by it. You can still use it with POST /v1/custom-scores for a list of homes.
Any Location or Paging error code
Examples

This runs the same rules as a search over the whole country. 326,487 H3 cells pass the must-have, so the response returns the top 10,000 by points, 100 a page.

Request

curl -X POST -H "X-Application-Id: YOUR_APP_ID" -H "X-Api-Key: YOUR_APP_KEY" -H "Content-Type: application/json" \
  -d '{
    "country": "gb",
    "profile": {
      "checks": {
        "supermarket": {"field": "proximity.walk_s.supermarket", "max": 600, "weight": 3, "label": "Supermarket in 10 min"},
        "quiet": {"field": "neighbourhood.noise.max_lden_db", "max": 55, "weight": 2, "label": "Quiet street"},
        "gyms": {"field": "proximity.bands.walk.600.category_counts.gym", "min": 3, "weight": 1, "label": "3+ gyms in 10 min"},
        "no_flood": {"field": "neighbourhood.flood.zone", "max": 1, "must": true, "label": "Not in a flood zone"},
        "transit": {"field": "proximity.ratings.transit", "min": 70, "weight": 2, "label": "Good public transport"},
        "big_park": {"field": "proximity.bands.walk.900.over_5ha_count", "min": 1, "weight": 2, "label": "A park of 5+ ha in 15 min"}
      }
    }
  }' \
  "https://data.traveltimeapp.com/v1/custom-scores/cells"
200 · 100 H3 cells, more pages

Shade = checks.supermarket.value174592100 H3 cells; click a cell to open its row.

Try these requests in the playground →