A microservice to get the distance between 2 UK postcodes. Built for my friends at Jerk Off BBQ.
Feel free to use it for any non-evil purpose!
Uses plain Ruby rather than a framework to keep the size down and allow deployment on Vercel's generous free tier.
CSS by Tailwind.
Utilises the Open Postcode Geo API to get the eastings and northings of each postcode. Pythagoras' theorem is used to calculate the distance between each point.
Pass the from and to postcodes as query strings to get the 'as the crow flies' distance between the postcodes in metres.
The Open Postcode Geo API encourages the use of (URL-encoded %20) spaces since some postcodes can only be distinguished from either with spaces. Letter case doesn't matter.
https://worthatrip.vercel.app/api/v1/handler?from=EC3N%204AB&to=M1%201AG
Excludes Northern Ireland due to licensing requirements.
Office for National Statistics licensed under the Open Government Licence v3.0