For the complete documentation index, see llms.txt. This page is also available as Markdown.

API Reference

Knowledge Base API reference.

Knowledge Base endpoints are available under:

https://api.laws.africa/ai/v1/knowledge-bases

Use these endpoints to list available Knowledge Bases, inspect a single Knowledge Base and retrieve matching legal context.

List Knowledge Bases

Call this endpoint to list the Knowledge Bases available to your account.

Explore legal data Knowledge Bases for use with Generative AI (PREVIEW).

get

Get details of Laws.Africa's Knowledge Bases.

Note: this API is a preview and may change in future.

Authorizations
sessionidstringRequired
Query parameters
pageintegerOptional

A page number within the paginated result set.

page_sizeintegerOptional

Number of results to return per page.

Responses
200Success
application/json
countintegerRequiredExample: 123
nextstring · uri · nullableOptionalExample: http://api.example.org/accounts/?page=4
previousstring · uri · nullableOptionalExample: http://api.example.org/accounts/?page=2
get/ai/v1/knowledge-bases
GET /ai/v1/knowledge-bases HTTP/1.1
Accept: */*
200Success
{
  "count": 123,
  "next": "http://api.example.org/accounts/?page=4",
  "previous": "http://api.example.org/accounts/?page=2",
  "results": [
    {
      "code": "text",
      "name": "text",
      "description": "text",
      "url": "https://example.com"
    }
  ]
}

Get a Knowledge Base

Get details for a Knowledge Base using its unique code.

Explore legal data Knowledge Bases for use with Generative AI (PREVIEW).

get

Get details of Laws.Africa's Knowledge Bases.

Note: this API is a preview and may change in future.

Authorizations
sessionidstringRequired
Path parameters
codestringRequired

Unique code identifying this knowledge base

Responses
200Success
application/json
codestring · max: 50Required

Unique code identifying this knowledge base

Pattern: ^[-a-zA-Z0-9_]+$
namestring · max: 255Required

Name of the knowledge base

descriptionstringRequired

Description of the knowledge base

urlstring · uriRead-onlyRequired
get/ai/v1/knowledge-bases/{code}
GET /ai/v1/knowledge-bases/{code} HTTP/1.1
Accept: */*
200Success
{
  "code": "text",
  "name": "text",
  "description": "text",
  "url": "https://example.com"
}

Query a Knowledge Base

Use the retrieve endpoint to query a Knowledge Base for legal information that matches keywords, phrases or AI-generated search text.

The request must:

  1. identify the Knowledge Base by code in the URL;

  2. include the text to search for;

  3. optionally include top_k and filters.

The response returns matching items with text, metadata and a score.

Query the knowledge base for matching items.

post

Retrieve items from the knowledge base that match your query.

Authorizations
sessionidstringRequired
Path parameters
codestringRequired

Unique code identifying this knowledge base

Body

Details to retrieve items from a knowledge base.

textstringRequired

The text to find matching items for

top_kinteger · min: 1 · max: 100Optional

Number of results to return

Default: 10
Responses
200Success
application/json

Items retrieved from a knowledge base.

post/ai/v1/knowledge-bases/{code}/retrieve
POST /ai/v1/knowledge-bases/{code}/retrieve HTTP/1.1
Content-Type: application/json
Accept: */*
Content-Length: 350

{
  "text": "text",
  "top_k": 10,
  "filters": {
    "work_frbr_uri": "text",
    "work_frbr_uri__in": [
      "text"
    ],
    "expression_frbr_uri": "text",
    "expression_frbr_uri__in": [
      "text"
    ],
    "frbr_place": "text",
    "frbr_place__in": [
      "text"
    ],
    "frbr_doctype": "text",
    "frbr_doctype__in": [
      "text"
    ],
    "frbr_subtype": "text",
    "frbr_subtype__in": [
      "text"
    ],
    "repealed": true,
    "commenced": true,
    "principal": true
  }
}
200Success
{
  "results": [
    {
      "content": {
        "text": "text"
      },
      "metadata": {
        "work_frbr_uri": "text",
        "frbr_place": "text",
        "frbr_country": "text",
        "frbr_doctype": "text",
        "frbr_subtype": "text",
        "title": "text",
        "repealed": true,
        "commenced": true,
        "principal": true,
        "blurb": "text",
        "flynote": "text",
        "expression_date": "2026-01-01",
        "expression_frbr_uri": "text",
        "public_url": "text",
        "portion_type": "page",
        "portion_id": "text",
        "portion_title": "text",
        "portion_parent_ids": [
          "text"
        ],
        "portion_parent_titles": [
          "text"
        ],
        "portion_public_url": "text"
      },
      "score": 1
    }
  ]
}

Last updated