SDKs overview
Rwanda Locations offers a suite of Application Programming Interfaces (APIs) designed to provide accurate and detailed geospatial data for Rwanda. To facilitate developer integration, the platform provides official Software Development Kits (SDKs) and supports community-contributed libraries. These SDKs are designed to streamline access to core services such as Geocoding API, Reverse Geocoding API, and Place Autocomplete API. By encapsulating the complexities of HTTP requests, response parsing, and authentication, SDKs enable developers to focus on application logic rather than low-level API interactions.
The SDKs are developed and maintained to ensure compatibility with the latest API versions and to adhere to best practices for the respective programming languages. They typically include methods for constructing requests, handling API keys, and processing JSON responses into language-specific data structures. This approach reduces development time and potential integration errors, as documented in general principles for API key management and RESTful API client design.
Official SDKs by language
Rwanda Locations provides official SDKs for several popular programming languages, reflecting the primary development environments used by its target audience. These SDKs are maintained by the Rwanda Locations team and are the recommended method for integrating the platform's services into new or existing applications. Each SDK is designed to offer a consistent developer experience while leveraging the idiomatic features of its respective language.
The official SDKs are regularly updated to incorporate new features, performance improvements, and security enhancements. Developers are encouraged to consult the official documentation for the most current information regarding SDK versions and capabilities. The following table provides an overview of the officially supported SDKs:
| Language | Package Name / Identifier | Install Command Example | Maturity Level |
|---|---|---|---|
| Python | rwandalocations-python |
pip install rwandalocations-python |
Stable |
| JavaScript (Node.js/Browser) | @rwandalocations/js-sdk |
npm install @rwandalocations/js-sdk |
Stable |
| PHP | rwandalocations/php-sdk |
composer require rwandalocations/php-sdk |
Stable |
Installation
Installing an SDK typically involves using a package manager specific to the programming language. The following sections detail the installation process for each official SDK. Before proceeding, ensure that you have the appropriate language runtime and package manager installed on your development environment.
Python SDK Installation
The Python SDK for Rwanda Locations is available via PyPI (Python Package Index). Use pip, the standard package installer for Python, to add the SDK to your project:
pip install rwandalocations-python
For virtual environments, activate your environment before running the install command:
python -m venv venv
source venv/bin/activate # On Windows, use `venv\Scripts\activate`
pip install rwandalocations-python
JavaScript SDK Installation
The JavaScript SDK is distributed through npm (Node Package Manager) and can be used in both Node.js environments and modern web browsers. Install it using npm or yarn:
npm install @rwandalocations/js-sdk
Or with Yarn:
yarn add @rwandalocations/js-sdk
For browser-based applications, you can import the module directly if using a module bundler like Webpack or Rollup. For environments without a bundler, a pre-compiled UMD (Universal Module Definition) build may be available for direct inclusion via a <script> tag, as described in the JavaScript SDK documentation.
PHP SDK Installation
The PHP SDK for Rwanda Locations is managed via Composer, the dependency manager for PHP. Add the SDK to your project by running the following command in your project's root directory:
composer require rwandalocations/php-sdk
This command will add the necessary entry to your composer.json file and install the package into your vendor/ directory. After installation, remember to include Composer's autoloader in your PHP scripts:
require 'vendor/autoload.php';
Quickstart example
This quickstart example demonstrates how to perform a basic geocoding request using the Python SDK. This example assumes you have already installed the rwandalocations-python package and obtained an API key from your Rwanda Locations dashboard.
import os
from rwandalocations import RwandaLocationsClient
# Initialize the client with your API key
# It's recommended to store your API key in an environment variable
api_key = os.getenv("RWANDA_LOCATIONS_API_KEY")
client = RwandaLocationsClient(api_key)
# Define the address to geocode
address = "KN 4 Ave, Kigali, Rwanda"
try:
# Perform a geocoding request
response = client.geocode(address)
# Check if results were found
if response and response.get("results"):
first_result = response["results"][0]
print(f"Address: {first_result.get('formatted_address')}")
print(f"Latitude: {first_result.get('geometry', {}).get('lat')}")
print(f"Longitude: {first_result.get('geometry', {}).get('lng')}")
else:
print(f"No results found for address: {address}")
except Exception as e:
print(f"An error occurred: {e}")
This script initializes the RwandaLocationsClient with an API key (retrieved from an environment variable for security best practices), sends a geocoding request for a specific address in Kigali, and then prints the formatted address, latitude, and longitude of the first result. Error handling is included to catch potential issues during the API call.
Community libraries
In addition to the official SDKs, the broader developer community may contribute libraries or wrappers that interact with the Rwanda Locations API. These community-driven projects can offer support for languages not officially covered, provide specialized functionalities, or integrate with specific frameworks. While these libraries are not officially maintained or endorsed by Rwanda Locations, they can be valuable resources for developers.
When considering a community library, it is advisable to evaluate its active maintenance, documentation quality, and community support. Developers should check the project's repository (e.g., GitHub) for recent commits, open issues, and pull requests to gauge its current status. Community libraries might also appear on package managers like npm or PyPI, often with varying levels of integration completeness or feature parity with the official APIs. For example, some community tools might focus on specific aspects like polyline encoding or map visualization, extending the core capabilities provided by the raw API or official SDKs.
Rwanda Locations encourages community contributions and provides clear API guidelines to assist developers in building robust integrations. While specific community libraries are not listed here due to their dynamic nature and varying levels of support, developers can search relevant package repositories or developer forums for projects tagged with "Rwanda Locations" or "Rwandan geospatial" to discover potential community solutions.