Nearly two years ago I built a short URL generator that used AWS Lambda, API Gateway, S3 and CloudFront. It costs pence to run and it was a good excuse to properly get to grips with a load of serverless tech that I hadn’t had a chance to play with yet.

Until recently I'd been using curl as means of creating a short URL over the API:

curl -X POST \
	-d '{"url": ""}' \
	-H "x-api-key: XXXXX" \

I've been wanting to invoke the short URL API from a python script for a while, so I decided to write a python client that can act as both a CLI application and a library.

How does it work?

Its a very simple python application that uses the popular requests library for the interactions with the API, and the built-in configparser and argparse packages.

I've used vcrpy to help put in place comprehensive test coverage for the library and application. vcrpy lets you mock out API requests and provide specific responses based on requests.

The elegance of vcrpy is that it can be used to capture a real API interaction and replay it for the purpose of tests.

vcrpy is a python implementation of the vcr library for Ruby.


This is a very simple application, so I intend to keep the usage as simple and minimalist as possible.


pip install short-urls

Setup credentials:

short-urls config -d -a MyApiKey-l3tm31n

Off you go, create your short URLs!

short-urls create python-client


The python client along with the original short URLs project is all open source: