Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Job Bookers Routing — Python Client

Python client library for the Job Bookers Routing API — UK drive time, distance, and postcode lookup.

Installation

pip install jobbookers-routing

Or install the latest version straight from GitHub:

pip install git+https://github.com/Gutsy666/jobbookers-routing-python.git

Or from a local clone:

git clone https://github.com/Gutsy666/jobbookers-routing-python
cd jobbookers-routing-python
pip install .

Quick Start

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 Grove

API Key

Get 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"])

Methods

route(from_postcode, to_postcode)

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"
# }

geocode(postcode)

Returns latitude and longitude for a UK postcode.

result = client.geocode("NR21 8AB")
# {
#   "postcode": "NR21 8AB",
#   "lat": 52.83162,
#   "lon": 0.87049
# }

street(postcode)

Returns the street name for a UK postcode.

result = client.street("NR21 8AB")
# {
#   "postcode": "NR21 8AB",
#   "street": "Walnut Grove"
# }

Error Handling

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}")

Requirements

  • Python 3.7+
  • No external dependencies (uses stdlib only)

Links

Attribution

Routing data © OpenStreetMap contributors, available under the Open Database Licence. Contains public sector information licensed under the Open Government Licence v3.0.

Licence

MIT

About

Python client for the Job Bookers UK Routing API — postcode to postcode drive time, distance and street lookup

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages