{"openapi":"3.1.0","info":{"title":"UK Location APIs","version":"1.0.0","description":"Postcode check (ONS area codes, Environment Agency flood risk, police.uk crime and nearest schools with Ofsted outcomes) and UK fuel prices from the government Fuel Finder scheme. Contains public sector information licensed under the Open Government Licence v3.0. Contains OS data © Crown copyright and database right. Contains Royal Mail data © Royal Mail copyright and database right.","contact":{"name":"Tyche Labs","email":"info@tychelabs.net","url":"https://api.tychelabs.net"},"termsOfService":"https://api.tychelabs.net/terms","license":{"name":"Contains public sector information licensed under the Open Government Licence v3.0","url":"https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/"},"x-logo":{"url":"https://api.tychelabs.net/logo.png"}},"externalDocs":{"description":"Guides, error codes and sandbox values","url":"https://api.tychelabs.net/docs"},"servers":[{"url":"https://api.tychelabs.net","description":"Production (use a tl_test_ key for sandbox data)"}],"security":[{"apiKey":[]}],"tags":[{"name":"Postcodes","description":"Area codes, flood risk, crime and schools for a postcode"},{"name":"Fuel","description":"UK forecourt fuel prices"},{"name":"Account","description":"Plan and usage"}],"paths":{"/v1/postcodes/{postcode}":{"get":{"summary":"Check a postcode: area codes, flood risk, crime and schools","operationId":"checkPostcode","tags":["Postcodes"],"parameters":[{"name":"postcode","in":"path","required":true,"schema":{"type":"string"},"example":"SW1A2AA","description":"A postcode in Great Britain. Spaces and case are ignored."},{"name":"include","in":"query","schema":{"type":"string"},"example":"areas,flood,crime,schools","description":"Comma-separated parts to return (default all)."},{"name":"schools","in":"query","schema":{"type":"integer","minimum":1,"maximum":10},"example":5,"description":"How many schools to return."},{"name":"phase","in":"query","schema":{"type":"string","enum":["primary","secondary","all"]},"example":"all"}],"responses":{"200":{"description":"Postcode check","headers":{"x-usage-limit":{"description":"Calls included in your plan this month","schema":{"type":"integer"}},"x-usage-remaining":{"description":"Calls left this month","schema":{"type":"integer"}},"x-request-id":{"description":"Quote this if you contact support","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/PostcodeCheck"},"meta":{"$ref":"#/components/schemas/Meta"}}},"examples":{"westminster":{"summary":"Westminster postcode (sandbox)","value":{}}}}}},"400":{"description":"Invalid input","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"invalid_postcode":{"value":{"error":{"code":"invalid_postcode","message":"Send a UK postcode, for example SW1A 1AA."},"meta":{"requestId":"req_3f9a1c2b7d"}}}}}}},"401":{"description":"Missing or invalid key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"missing_api_key":{"value":{"error":{"code":"missing_api_key","message":"Send your key in the x-api-key header. Get a free key at https://api.tychelabs.net/signup"},"meta":{"requestId":"req_3f9a1c2b7d"}}},"invalid_api_key":{"value":{"error":{"code":"invalid_api_key","message":"That API key is not valid."},"meta":{"requestId":"req_3f9a1c2b7d"}}}}}}},"404":{"description":"Not in the ONS Postcode Directory (billed)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"postcode_not_found":{"value":{"error":{"code":"postcode_not_found","message":"That postcode is not in the ONS Postcode Directory (live or terminated)."},"meta":{"requestId":"req_3f9a1c2b7d"}}}}}}},"422":{"description":"Outside coverage (not billed)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"unsupported_region":{"value":{"error":{"code":"unsupported_region","message":"Northern Ireland postcodes are not covered."},"meta":{"requestId":"req_3f9a1c2b7d"}}}}}}},"429":{"description":"Rate limit or monthly quota reached","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"quota_exceeded":{"value":{"error":{"code":"quota_exceeded","message":"You have used all 100 lookups in your Free plan this month. Request a paid plan at https://api.tychelabs.net/pricing"},"meta":{"requestId":"req_3f9a1c2b7d"}}},"rate_limited":{"value":{"error":{"code":"rate_limited","message":"Slow down: your plan allows 2 requests a second."},"meta":{"requestId":"req_3f9a1c2b7d"}}}}}},"headers":{"retry-after":{"description":"Seconds to wait","schema":{"type":"integer"}}}},"503":{"description":"Upstream unavailable and no cached copy (not billed). Retry after the Retry-After header.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"upstream_unavailable":{"value":{"error":{"code":"upstream_unavailable","message":"Vehicle sources are unavailable right now. Please retry shortly; calls that fail like this are not counted."},"meta":{"requestId":"req_3f9a1c2b7d"}}}}}},"headers":{"retry-after":{"description":"Seconds to wait","schema":{"type":"integer"}}}}}}},"/v1/fuel/nearest":{"get":{"summary":"Nearest or cheapest forecourts for a fuel","operationId":"fuelNearest","tags":["Fuel"],"parameters":[{"name":"postcode","in":"query","schema":{"type":"string"},"example":"SW1A2AA","description":"A GB postcode (or send lat and lng)"},{"name":"lat","in":"query","schema":{"type":"number"}},{"name":"lng","in":"query","schema":{"type":"number"}},{"name":"fuel","in":"query","schema":{"type":"string","enum":["E10","E5","B7_STANDARD","B7_PREMIUM","B10","HVO","B7","SDV"]},"example":"E10"},{"name":"radius","in":"query","schema":{"type":"number","maximum":25},"example":5,"description":"Kilometres"},{"name":"sort","in":"query","schema":{"type":"string","enum":["price","distance"]}},{"name":"limit","in":"query","schema":{"type":"integer","maximum":50}}],"responses":{"200":{"description":"Forecourts with prices as reported, sorted on price or distance only","headers":{"x-usage-limit":{"description":"Calls included in your plan this month","schema":{"type":"integer"}},"x-usage-remaining":{"description":"Calls left this month","schema":{"type":"integer"}},"x-request-id":{"description":"Quote this if you contact support","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/FuelNearest"},"meta":{"$ref":"#/components/schemas/Meta"}}},"examples":{"e10":{"summary":"Cheapest E10 near Westminster (sandbox)","value":{"data":{"fuel":"E10","location":{"lat":51.50101,"lng":-0.141563},"radiusKm":5,"sort":"price","total":4,"items":[{"station":{"id":"0505050505050505050505050505050505050505050505050505050505050505","name":"PLACEHOLDER ENERGY VAUXHALL","brand":"PLACEHOLDER ENERGY","address":{"line1":"5 Placeholder Place","line2":null,"city":"LONDON","county":null,"postcode":"SE11 1AA","country":"England"},"location":{"lat":51.4862,"lng":-0.1229},"isMotorway":false,"isSupermarket":false,"temporaryClosure":false,"permanentClosure":false},"distanceKm":2.09,"fuel":"E10","price":132.9,"unit":"pence_per_litre","priceLastUpdated":"2026-11-24T06:31:12.000Z","priceEffectiveAt":"2026-11-24T06:30:00.000Z"},{"station":{"id":"0202020202020202020202020202020202020202020202020202020202020202","name":"SAMPLE SUPERSTORE BATTERSEA","brand":"SAMPLE SUPERSTORE","address":{"line1":"2 Sample Way","line2":null,"city":"LONDON","county":null,"postcode":"SW11 1AA","country":"England"},"location":{"lat":51.4791,"lng":-0.15},"isMotorway":false,"isSupermarket":true,"temporaryClosure":false,"permanentClosure":false},"distanceKm":2.51,"fuel":"E10","price":132.9,"unit":"pence_per_litre","priceLastUpdated":"2026-11-24T06:31:12.000Z","priceEffectiveAt":"2026-11-24T06:30:00.000Z"}]},"meta":{"requestId":"req_4d8b2a6c1e9f3b70","sandbox":true,"source":"fuel_finder","dataRefreshedAt":"2026-11-24T07:55:00.000Z","dataAgeSeconds":22505,"reportDiscrepancyUrl":"https://www.fuel-finder.service.gov.uk/motorist/price-report","ranking":"price, then distance","excluded":{"closed":1,"implausiblePrice":0},"plausiblePriceRange":{"min":50,"max":400,"unit":"pence_per_litre"},"usage":{"plan":"free","used":9,"limit":1000,"period":"2026-11"}}}}}}}},"400":{"description":"Invalid input","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"invalid_location":{"value":{"error":{"code":"invalid_location","message":"Send postcode, or lat and lng."},"meta":{"requestId":"req_3f9a1c2b7d"}}}}}}},"401":{"description":"Missing or invalid key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"missing_api_key":{"value":{"error":{"code":"missing_api_key","message":"Send your key in the x-api-key header. Get a free key at https://api.tychelabs.net/signup"},"meta":{"requestId":"req_3f9a1c2b7d"}}},"invalid_api_key":{"value":{"error":{"code":"invalid_api_key","message":"That API key is not valid."},"meta":{"requestId":"req_3f9a1c2b7d"}}}}}}},"429":{"description":"Rate limit or monthly quota reached","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"quota_exceeded":{"value":{"error":{"code":"quota_exceeded","message":"You have used all 100 lookups in your Free plan this month. Request a paid plan at https://api.tychelabs.net/pricing"},"meta":{"requestId":"req_3f9a1c2b7d"}}},"rate_limited":{"value":{"error":{"code":"rate_limited","message":"Slow down: your plan allows 2 requests a second."},"meta":{"requestId":"req_3f9a1c2b7d"}}}}}},"headers":{"retry-after":{"description":"Seconds to wait","schema":{"type":"integer"}}}},"503":{"description":"Upstream unavailable and no cached copy (not billed). Retry after the Retry-After header.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"upstream_unavailable":{"value":{"error":{"code":"upstream_unavailable","message":"Vehicle sources are unavailable right now. Please retry shortly; calls that fail like this are not counted."},"meta":{"requestId":"req_3f9a1c2b7d"}}}}}},"headers":{"retry-after":{"description":"Seconds to wait","schema":{"type":"integer"}}}}}}},"/v1/fuel/stations/{id}":{"get":{"summary":"Every price at one forecourt","operationId":"fuelStation","tags":["Fuel"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Station and prices"},"401":{"description":"Missing or invalid key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"missing_api_key":{"value":{"error":{"code":"missing_api_key","message":"Send your key in the x-api-key header. Get a free key at https://api.tychelabs.net/signup"},"meta":{"requestId":"req_3f9a1c2b7d"}}},"invalid_api_key":{"value":{"error":{"code":"invalid_api_key","message":"That API key is not valid."},"meta":{"requestId":"req_3f9a1c2b7d"}}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"station_not_found":{"value":{"error":{"code":"station_not_found","message":"No forecourt with that id."},"meta":{"requestId":"req_3f9a1c2b7d"}}}}}}},"503":{"description":"Upstream unavailable and no cached copy (not billed). Retry after the Retry-After header.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"upstream_unavailable":{"value":{"error":{"code":"upstream_unavailable","message":"Vehicle sources are unavailable right now. Please retry shortly; calls that fail like this are not counted."},"meta":{"requestId":"req_3f9a1c2b7d"}}}}}},"headers":{"retry-after":{"description":"Seconds to wait","schema":{"type":"integer"}}}}}}},"/v1/fuel/stations/{id}/history":{"get":{"summary":"Price history for a forecourt (up to 90 days)","operationId":"fuelHistory","tags":["Fuel"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"days","in":"query","schema":{"type":"integer","minimum":1,"maximum":90}}],"responses":{"200":{"description":"Price series by fuel"},"401":{"description":"Missing or invalid key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"missing_api_key":{"value":{"error":{"code":"missing_api_key","message":"Send your key in the x-api-key header. Get a free key at https://api.tychelabs.net/signup"},"meta":{"requestId":"req_3f9a1c2b7d"}}},"invalid_api_key":{"value":{"error":{"code":"invalid_api_key","message":"That API key is not valid."},"meta":{"requestId":"req_3f9a1c2b7d"}}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"station_not_found":{"value":{"error":{"code":"station_not_found","message":"No forecourt with that id."},"meta":{"requestId":"req_3f9a1c2b7d"}}}}}}}}}},"/v1/account":{"get":{"summary":"Your plan, usage this month and webhook secret","operationId":"getAccount","tags":["Account"],"responses":{"200":{"description":"Account"},"401":{"description":"Missing or invalid key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"missing_api_key":{"value":{"error":{"code":"missing_api_key","message":"Send your key in the x-api-key header. Get a free key at https://api.tychelabs.net/signup"},"meta":{"requestId":"req_3f9a1c2b7d"}}},"invalid_api_key":{"value":{"error":{"code":"invalid_api_key","message":"That API key is not valid."},"meta":{"requestId":"req_3f9a1c2b7d"}}}}}}}}}}},"components":{"securitySchemes":{"apiKey":{"type":"apiKey","in":"header","name":"x-api-key","description":"Your tl_live_ or tl_test_ key. Free keys at https://api.tychelabs.net/signup. A tl_test_ key returns sandbox data and is never billed."}},"schemas":{"PostcodeCheck":{"type":"object","properties":{"postcode":{"type":"string"},"areas":{"type":"object","description":"ONS Postcode Directory: outcode, incode, status, terminated, latitude, longitude, eastings, northings, country, region, localAuthority, county, ward, parish, parliamentaryConstituency, lsoa21, msoa21, outputArea21, policeForceArea, nhs, ruralUrban"},"flood":{"type":["object","null"],"description":"Environment Agency flood risk for the postcode (England)"},"crime":{"type":["object","null"],"description":"police.uk street-level crime around the postcode for the last 12 months (England and Wales)"},"schools":{"type":["object","null"],"description":"Nearest open schools with their latest Ofsted outcome (England)"}}},"FuelNearest":{"type":"object","properties":{"fuel":{"type":"string"},"location":{"type":"object"},"radiusKm":{"type":"number"},"sort":{"type":"string"},"total":{"type":"integer"},"items":{"type":"array","items":{"type":"object","properties":{"station":{"type":"object"},"distanceKm":{"type":"number"},"fuel":{"type":"string"},"price":{"type":"number","description":"Pence a litre"},"priceLastUpdated":{"type":"string"},"priceEffectiveAt":{"type":"string"}}}}}},"Meta":{"type":"object","properties":{"requestId":{"type":"string"},"sandbox":{"type":"boolean"},"partial":{"type":"boolean","description":"True when one source failed and the response holds the others."},"stale":{"type":"boolean","description":"True when a source was down and we served our last good copy."},"billed":{"type":"integer","description":"Bulk only: lookups counted against your plan."},"attribution":{"type":"string","description":"Open Government Licence v3.0 attribution. Show it wherever you display the data to others."},"sources":{"type":"object","additionalProperties":{"type":"object","properties":{"status":{"type":"string","enum":["ok","stale","not_found","unavailable","rate_limited","skipped"]},"fetchedAt":{"type":"string","format":"date-time"},"cache":{"type":"string"},"message":{"type":"string"}}}},"usage":{"type":"object","properties":{"plan":{"type":"string"},"used":{"type":"integer"},"limit":{"type":"integer"},"period":{"type":"string"}}}}},"Error":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string","enum":["coming_soon","invalid_name","invalid_eori","invalid_postcode","unsupported_region","postcode_not_found","station_not_found","missing_api_key","invalid_api_key","invalid_registration","invalid_company_number","invalid_vat_number","invalid_query","invalid_body","invalid_url","invalid_target","live_key_required","invalid_marketplace_secret","too_many","vehicle_not_found","company_not_found","not_found","watch_exists","watch_limit","quota_exceeded","rate_limited","upstream_unavailable","internal_error"],"description":"Stable machine-readable code. See https://api.tychelabs.net/docs#errors"},"message":{"type":"string"}},"required":["code","message"]},"meta":{"$ref":"#/components/schemas/Meta"}},"required":["error"]}}}}