Quick start

A quick introduction to using the Laws.Africa Content API.

This quick start guide will get you started with fetching legislation from the Laws.Africa Content API. It includes:

  1. Signing up for a Laws.Africa account

  2. Listing available legislation

  3. Fetching the HTML for a piece of legislation

  4. Displaying the HTML

This guide uses the Cape Town by-laws as example content, which is free and doesn't require an API subscription. Other content such as national laws require a subscription.

Find out more about API subscriptions and licensing terms at https://laws.africa/api/detail.

Create an account

To get started, you'll need a free Laws.Africa account and API token.

  1. Sign up for a free Laws.Africa account at https://edit.laws.africa/accounts/login/

In the examples below, replace <YOUR_AUTH_TOKEN> with your personal API token.

Once you're signed into your account, you can also visit the API URLs in your browser.

Get a list of by-laws

Fetch a list of the by-laws (municipal legislation) for the City of Cape Town.

$ curl -H "Authorization: Token <YOUR_AUTH_TOKEN>" \
  https://api.laws.africa/v3/akn/za-cpt/.json

The za-cpt part of the URL identifies the City of Cape Town in South Africa.

Fetch the Animal by-law

Let's fetch the details of Cape Town's Animal by-law, in JSON format. This includes the title, publication details and a list of other API calls you can make for additional details.

Laws.Africa can provide us with a Table of Contents for the by-law, also in JSON format. Let's fetch that:

Now let's get the HTML content of Section 3 of the by-law, regarding dog registration and licensing:

Display the by-law

Finally, let's put that HTML into a webpage and include the Laws.Africa Law Widgets to apply stylesheets to make it look good:

Next steps

  • The Tutorial goes step-by-step through building a Django application that display legislation fetched from the Laws.Africa Content API.

  • Browse the API documentation.

Introduction

Last updated