SDKs overview
BdAPIs offers Software Development Kits (SDKs) and libraries designed to facilitate interaction with its Geocoding API, Reverse Geocoding API, and Address Autocomplete API. These tools provide language-specific interfaces that abstract HTTP requests and JSON parsing, allowing developers to integrate geospatial functionalities into their applications using familiar programming constructs. The SDKs aim to reduce development time by handling common tasks such as API key management, request formatting, and response processing.
The availability of SDKs across multiple programming languages supports a broad range of development environments and projects, from web applications using JavaScript to backend services implemented in Python or Java. Community-contributed libraries may also extend the platform's reach to additional languages or frameworks, though their maintenance and support levels can vary.
Official SDKs by language
BdAPIs officially supports SDKs for several popular programming languages, providing tested and maintained packages for developers. These SDKs are documented within the official BdAPIs documentation and typically include example code for common operations such as performing a geocoding lookup or validating an address. The following table outlines the key official SDKs:
| Language | Package Manager / Name | Installation Command | Maturity |
|---|---|---|---|
| JavaScript | npm (@bdapis/sdk-js) |
npm install @bdapis/sdk-js |
Stable |
| Python | pip (bdapis-sdk-python) |
pip install bdapis-sdk-python |
Stable |
| PHP | Composer (bdapis/sdk-php) |
composer require bdapis/sdk-php |
Stable |
| Ruby | RubyGems (bdapis-sdk-ruby) |
gem install bdapis-sdk-ruby |
Stable |
| Java | Maven / Gradle (com.bdapis:sdk-java) |
Refer to Java SDK setup instructions | Stable |
| C# | NuGet (BdApis.Sdk.CSharp) |
dotnet add package BdApis.Sdk.CSharp |
Stable |
Installation
Installation of the BdAPIs SDKs typically involves using the standard package manager for each respective programming language. Each SDK is designed to be easily integrated into existing projects. Before installation, developers should ensure their development environment is configured correctly for the target language and its package manager.
JavaScript (Node.js/Browser)
For JavaScript environments, including Node.js and modern browsers, the SDK is available via npm. After installing Node.js and npm, execute the following command in your project directory:
npm install @bdapis/sdk-js
Python
The Python SDK is distributed through PyPI and can be installed using pip, Python's package installer. Ensure you have Python and pip installed:
pip install bdapis-sdk-python
PHP
PHP projects typically use Composer for dependency management. If Composer is not installed, follow the Composer installation guide. Then, add the BdAPIs SDK to your project:
composer require bdapis/sdk-php
Ruby
Ruby projects can install the SDK using RubyGems. Ensure Ruby and the gem command are available in your environment:
gem install bdapis-sdk-ruby
Java
For Java applications, the SDK can be integrated using build tools like Maven or Gradle. The necessary dependency declarations can be found in the BdAPIs Java SDK documentation. Below is an example for Maven:
<dependencies>
<dependency>
<groupId>com.bdapis</groupId>
<artifactId>sdk-java</artifactId>
<version>1.0.0</version> <!-- Use the latest version -->
</dependency>
</dependencies>
C# (.NET)
C# developers can install the SDK using NuGet, the package manager for .NET. Use the .NET CLI or the Package Manager Console in Visual Studio:
dotnet add package BdApis.Sdk.CSharp
Quickstart example
This quickstart demonstrates how to perform a basic geocoding request using the BdAPIs Python SDK. This example assumes you have an API key for BdAPIs and have installed the Python SDK as described in the installation section.
import os
from bdapis_sdk_python.client import BdApisClient
from bdapis_sdk_python.exceptions import BdApisApiException
# Initialize the client with your API key
# It's recommended to store your API key as an environment variable
api_key = os.getenv("BDAPIS_API_KEY")
if not api_key:
raise ValueError("BDAPIS_API_KEY environment variable not set.")
client = BdApisClient(api_key=api_key)
try:
# Perform a geocoding request for an address
address = "1600 Amphitheatre Parkway, Mountain View, CA"
response = client.geocoding.geocode(address=address)
print(f"Geocoding results for '{address}':")
if response and response.results:
for result in response.results:
print(f" Latitude: {result.latitude}, Longitude: {result.longitude}")
print(f" Formatted Address: {result.formatted_address}")
# Access other properties like components, confidence, etc.
else:
print(" No results found.")
# Example of a reverse geocoding request
latitude = 37.4219999
longitude = -122.0840575
reverse_response = client.reverse_geocoding.reverse_geocode(latitude=latitude, longitude=longitude)
print(f"\nReverse geocoding results for ({latitude}, {longitude}):")
if reverse_response and reverse_response.results:
for result in reverse_response.results:
print(f" Formatted Address: {result.formatted_address}")
else:
print(" No results found for reverse geocoding.")
except BdApisApiException as e:
print(f"API Error: {e.status_code} - {e.message}")
except Exception as e:
print(f"An unexpected error occurred: {e}")
This example demonstrates how to set up the client, make a geocoding call, and then a reverse geocoding call. The API key should be securely stored, preferably as an environment variable, rather than hardcoded directly in the source code. Error handling is included to manage potential issues with the API request or response.
Community libraries
Beyond the official SDKs, the developer community may contribute libraries and integrations for BdAPIs. These community-driven projects can offer support for additional programming languages, frameworks, or specialized use cases not covered by the official offerings. For instance, developers might find libraries that integrate BdAPIs with specific web frameworks like Django or Ruby on Rails, or provide wrappers for languages like Go or Rust.
While community libraries can be valuable, developers should assess their usage based on several factors:
- Maintenance Status: Check the project's activity, recent updates, and open issues to gauge ongoing support.
- Documentation: Verify if the library has clear and comprehensive documentation.
- Licensing: Understand the license under which the library is distributed.
- Official Endorsement: Community libraries are not officially supported by BdAPIs, meaning support for issues may be provided by the community maintainers rather than the BdAPIs team.
Developers often discover community libraries through package managers (e.g., PyPI for Python, npm for JavaScript) by searching for keywords like "bdapis" combined with their desired language or framework. GitHub and other code hosting platforms are also common places to find such projects. For example, a search on GitHub for geocoding libraries may reveal relevant projects. Always refer to the specific project's README and documentation for installation and usage instructions.