Skip to main content

A modern, async Python SDK for seamless integration with the AfriGIS Search suite of APIs. Provides robust, versioned, and strongly-typed access to Autocomplete, Geocode, Place Details, and Delivery Address Format endpoints, with automatic authentication and error handling.

Project description

AfriGIS Python Search Client

Overview

AfriGIS Python Search Client is a modern, async Python SDK for seamless integration with the AfriGIS Search suite of APIs. It provides robust, versioned, and strongly-typed access to Autocomplete, Geocode, Place Details, and Delivery Address Format APIs, handling authentication, request formatting, and error mapping for you.

  • Token-based authentication (OAuth2)
  • API key support
  • Strongly-typed request/response models (Pydantic)
  • Async API for scalable apps
  • Comprehensive error handling
  • Thread/async-safe and production-ready
  • Versioned endpoints for future compatibility

Installation

Install via pip (after building or from PyPI):

pip install afrigis-search-client

Configuration

You can provide credentials via environment variables, .env file, or directly as parameters. Example .env:

AFRIGIS_AUTH_URL=https://auth.afrigis.services
AFRIGIS_CLIENT_ID=your-client-id
AFRIGIS_CLIENT_SECRET=your-client-secret
AFRIGIS_API_KEY=your-api-key

Client Initialization

from afrigis_search_client import AfrigisSearchClient
import os

client = AfrigisSearchClient(
    client_id=os.getenv("AFRIGIS_CLIENT_ID"),
    client_secret=os.getenv("AFRIGIS_CLIENT_SECRET"),
    api_key=os.getenv("AFRIGIS_API_KEY")
)

Usage Examples

All endpoints are async and raise exceptions for error conditions. See below for details on which exceptions are raised and when.

Autocomplete

result = await client.autocomplete.v3.autocomplete(query="446 Rigel", max_results=5)
for suggestion in result.result:
    print(f"{suggestion.description} ({suggestion.country})")

Geocoding

result = await client.geocode.v3.geocode_address(query="446 Rigel Avenue South, Erasmusrand", max_results=5)
for address in result.result:
    print(f"{address.formatted_address} - {address.location}")

Place Details

result = await client.details.v3.get_details(reference="2XIAs5De9f_eEXNFubwV-ZXI41F281017")
print(result.result.formatted_address)
print(result.result.location)

Delivery Address Lookup

result = await client.delivery.v1.get_delivery(reference="2XIAs5De9f_eEXNFubwV-ZXI41F281017")
print(result.result.formatted_address)
print(result.result.delivery)

Autocomplete/Geocode with IncludeTypes/ExcludeTypes

result = await client.autocomplete.v3.autocomplete(
    query="446 Rigel",
    max_results=5,
    include_types=["street_address_level_1", "locality"],
    exclude_types=["administrative_area_level_1"]
)

Exception Handling

All endpoints raise exceptions for error conditions:

  • ValueError: For invalid input (e.g., empty query)
  • Exception: For API errors, network errors, or response validation errors

Thread Safety & Token Management

  • The client is async/thread-safe and manages authentication tokens automatically.
  • Tokens are refreshed as needed; you do not need to handle this yourself.

API Reference

Support & Further Resources

  • Contact AfriGIS for production support and API documentation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

afrigis_search_client-0.1.1.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

afrigis_search_client-0.1.1-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file afrigis_search_client-0.1.1.tar.gz.

File metadata

  • Download URL: afrigis_search_client-0.1.1.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for afrigis_search_client-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4a60c815d8341e5d6be27ade26b773baa02634ca817138b4ac5151703ffdadcd
MD5 e08ef74833db95c181df9ec183798e96
BLAKE2b-256 b2a64fc528d10f7e317d9e586ea54b023ca5f2025ea67ebfeeb47a0f5766e746

See more details on using hashes here.

File details

Details for the file afrigis_search_client-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for afrigis_search_client-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e522a41ea4d1a77e02ed24d02208eaa3162c3f6365e5c5da557035a73bf4e2ef
MD5 3de900b33e0cdacb415be57aed5e0c34
BLAKE2b-256 8d4d7d4b6ba161d33f40c5fcf95ecae6bc6b50be53404df99e4bf77da3968764

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page