Programming guide

Fetch data from a public API with Python

Write a short Python script that requests data from a public web API, checks the response properly and saves the results to a CSV file you can open in a spreadsheet.

Estimated time: 1–2 hoursUpdated: 1 October 2026

Use this guide when you know basic Python and want to pull live data from a web service instead of copying it by hand. You need Python 3 installed, a project folder with a virtual environment and the documentation page for the API you want to use.

Step by step

  1. Pick an API and read its rules first

    Start with a free public feed that needs no key, for example GOV.UK publishes UK bank holiday dates as a JSON feed, which is ideal for practice. Before writing code, read the API documentation for three things: the exact endpoint address, whether it needs a key, and any usage limits or terms. Note the limit in a comment at the top of your script so you respect it later.

Members

The rest of this guide is for members

The rest of this guide – the remaining steps, a ready-to-use checklist, practical tips and fixes for common problems – is for members. Membership unlocks every ABCDayZ guide.

£3.99 for 1 month or £29 for 12 months. One payment, no automatic renewal.

Unlock all guides

Already a member on another device? Open your personal access link. Bought Programming with AI? Your first month is included.