Python client library for the Job Bookers Routing API — UK drive time, distance, and postcode lookup.
pip install jobbookers-routingOr install the latest version straight from GitHub:
pip install git+https://github.com/Gutsy666/jobbookers-routing-python.gitOr from a local clone:
git clone https://github.com/Gutsy666/jobbookers-routing-python
cd jobbookers-routing-python
pip install .from jobbookers_routing import JobBookersRouting
client = JobBookersRouting(api_key="jbr_live_your_key_here")
# Drive time and distance
result = client.route("NR21 8AB", "PE37 7JL")
print(f"{result['duration_mins']} mins, {result['distance_miles']} miles")
# 23 mins, 16.2 miles
# Postcode coordinates
coords = client.geocode("NR21 8AB")
print(f"Lat: {coords['lat']}, Lon: {coords['lon']}")
# Lat: 52.83162, Lon: 0.87049
# Street name
street = client.street("NR21 8AB")
print(street['street'])
# Walnut GroveGet an API key at api.jobbookers.co.uk.
Always keep your API key server-side. Never include it in client-side code or commit it to version control. Use environment variables:
import os
from jobbookers_routing import JobBookersRouting
client = JobBookersRouting(api_key=os.environ["JBR_API_KEY"])Returns drive time and distance between two UK postcodes.
result = client.route("NR21 8AB", "PE37 7JL")
# {
# "duration_mins": 23,
# "distance_miles": 16.2,
# "from_postcode": "NR21 8AB",
# "to_postcode": "PE37 7JL"
# }Returns latitude and longitude for a UK postcode.
result = client.geocode("NR21 8AB")
# {
# "postcode": "NR21 8AB",
# "lat": 52.83162,
# "lon": 0.87049
# }Returns the street name for a UK postcode.
result = client.street("NR21 8AB")
# {
# "postcode": "NR21 8AB",
# "street": "Walnut Grove"
# }from jobbookers_routing import (
JobBookersRouting,
AuthenticationError,
InvalidPostcodeError,
NotFoundError,
RateLimitError,
ServerError,
)
client = JobBookersRouting(api_key=os.environ["JBR_API_KEY"])
try:
result = client.route("NR21 8AB", "PE37 7JL")
except AuthenticationError:
print("Invalid API key")
except InvalidPostcodeError as e:
print(f"Bad postcode: {e}")
except NotFoundError as e:
print(f"Postcode not found: {e}")
except RateLimitError:
print("Monthly limit reached — upgrade your plan")
except ServerError as e:
print(f"API error: {e}")- Python 3.7+
- No external dependencies (uses stdlib only)
Routing data © OpenStreetMap contributors, available under the Open Database Licence. Contains public sector information licensed under the Open Government Licence v3.0.
MIT