API Reference
Knowledge Base API reference.
Knowledge Base endpoints are available under:
https://api.laws.africa/ai/v1/knowledge-basesUse 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.
Get details of Laws.Africa's Knowledge Bases.
Note: this API is a preview and may change in future.
A page number within the paginated result set.
Number of results to return per page.
123http://api.example.org/accounts/?page=4http://api.example.org/accounts/?page=2GET /ai/v1/knowledge-bases HTTP/1.1
Accept: */*
{
"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.
Get details of Laws.Africa's Knowledge Bases.
Note: this API is a preview and may change in future.
Unique code identifying this knowledge base
Unique code identifying this knowledge base
^[-a-zA-Z0-9_]+$Name of the knowledge base
Description of the knowledge base
GET /ai/v1/knowledge-bases/{code} HTTP/1.1
Accept: */*
{
"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:
identify the Knowledge Base by
codein the URL;include the
textto search for;optionally include
top_kandfilters.
The response returns matching items with text, metadata and a score.
Retrieve items from the knowledge base that match your query.
Unique code identifying this knowledge base
Details to retrieve items from a knowledge base.
The text to find matching items for
Number of results to return
10Items retrieved from a knowledge base.
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
}
}{
"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