Quick start

Make your first Laws.Africa Knowledge Base query.

This guide shows you how to query a Knowledge Base and use the result in an application.

You will:

  1. create a platform account and API token;

  2. list available Knowledge Bases;

  3. query a Knowledge Base;

  4. use the returned legal context in Python.

Create an API token

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

Knowledge Base retrieve calls count toward your account's Knowledge Base usage limits. You can monitor usage in the platform and read rate-limit guidance in manage your plan and subscription.

List available Knowledge Bases

curl -H "Authorization: Bearer <YOUR_AUTH_TOKEN>" \
  https://api.laws.africa/ai/v1/knowledge-bases

The response includes Knowledge Base codes. Use a code in the retrieve endpoint.

Query a legislation Knowledge Base

This example queries the South African municipal legislation Knowledge Base for Cape Town dog ownership rules.

The response contains matching legal portions:

For legislation queries, start with principal: true and repealed: false so results prefer current principal legislation rather than amendment notices or repealed works.

Use the result in Python

Pass this context into your search interface, RAG prompt or agent response with the user's question. Always include source URLs so users can inspect the legal material.

Next steps

Last updated