SDKs overview
GeoDataSource offers various Software Development Kits (SDKs) and libraries designed to facilitate integration with its geocoding and IP geolocation services. These tools enable developers to interact with the GeoDataSource Web Services API or utilize their downloadable databases for offline operations. The SDKs abstract the underlying HTTP requests and data parsing, providing language-native objects and methods for common geospatial queries such as converting addresses to coordinates (geocoding), converting coordinates to addresses (reverse geocoding), and identifying geographical information based on IP addresses.
The primary goal of these SDKs is to reduce the boilerplate code required for API interaction, allowing developers to focus on application logic rather than HTTP client management or JSON parsing. GeoDataSource provides official libraries for several popular programming languages, alongside community-contributed resources that extend support and offer alternative integration patterns. This approach supports both online, real-time data access and scenarios requiring local, high-performance geospatial data processing without external API calls.
Official SDKs by language
GeoDataSource maintains official SDKs for several programming languages, providing direct support for their Web Services API and database integration. These SDKs are designed to align with the GeoDataSource Web Services API reference and are typically available through standard package managers for each respective language.
| Language | Package/Library Name | Install Command (example) | Maturity |
|---|---|---|---|
| PHP | geodatasource-php |
composer require geodatasource/geodatasource-php |
Stable |
| Java | geodatasource-java |
Add to pom.xml or build.gradle |
Stable |
| Python | geodatasource-python |
pip install geodatasource-python |
Stable |
| Ruby | geodatasource-ruby |
gem install geodatasource-ruby |
Stable |
| Node.js | geodatasource-nodejs |
npm install geodatasource-nodejs |
Stable |
| C# | GeoDataSource.NET |
Install-Package GeoDataSource.NET |
Stable |
Installation
Installation of GeoDataSource SDKs typically involves using the package manager specific to the programming language. Detailed instructions and specific version requirements are available on the GeoDataSource developers page.
PHP
For PHP projects, the SDK is distributed via Composer, the dependency manager for PHP. Ensure Composer is installed on your system.
composer require geodatasource/geodatasource-php
After installation, you can include the autoloader in your project:
require 'vendor/autoload.php';
Java
Java developers can integrate the GeoDataSource library by adding it as a dependency in their build configuration, typically using Maven or Gradle.
Maven
Add the following to your pom.xml:
<dependency>
<groupId>com.geodatasource</groupId>
<artifactId>geodatasource-java</artifactId>
<version>1.0.0</version> <!-- Replace with the latest version -->
</dependency>
Gradle
Add the following to your build.gradle:
implementation 'com.geodatasource:geodatasource-java:1.0.0' // Replace with the latest version
Python
The Python SDK is available through pip, the Python package installer. It is recommended to install it within a virtual environment.
pip install geodatasource-python
Ruby
Ruby developers can install the GeoDataSource gem using the Bundler dependency manager or directly via the gem command.
gem install geodatasource-ruby
If using Bundler, add to your Gemfile:
gem 'geodatasource-ruby'
Then run:
bundle install
Node.js
For Node.js projects, the SDK is available on npm, the Node.js package manager.
npm install geodatasource-nodejs
Or using yarn:
yarn add geodatasource-nodejs
C# (.NET)
The C# SDK is distributed as a NuGet package, available through the NuGet Package Manager in Visual Studio or via the .NET CLI.
Install-Package GeoDataSource.NET
Or using the .NET CLI:
dotnet add package GeoDataSource.NET
Quickstart example
This example demonstrates how to perform a simple geocoding request (converting an address to coordinates) using the GeoDataSource Python SDK. You will need an API key, which can be obtained from the GeoDataSource developer portal.
from geodatasource import GeoDataSource
# Replace 'YOUR_API_KEY' with your actual GeoDataSource API key
api_key = 'YOUR_API_KEY'
gds = GeoDataSource(api_key)
# Geocode an address
address = "1600 Amphitheatre Parkway, Mountain View, CA"
geocode_result = gds.geocode(address)
if geocode_result:
print(f"Address: {address}")
print(f"Latitude: {geocode_result['latitude']}")
print(f"Longitude: {geocode_result['longitude']}")
print(f"Country: {geocode_result['country_name']}")
print(f"City: {geocode_result['city']}")
else:
print(f"Could not geocode address: {address}")
# Example of reverse geocoding (coordinates to address)
latitude = 34.052235
longitude = -118.243683
reverse_geocode_result = gds.reverse_geocode(latitude, longitude)
if reverse_geocode_result:
print(f"\nCoordinates: ({latitude}, {longitude})")
print(f"Nearest Address: {reverse_geocode_result['address']}")
print(f"City: {reverse_geocode_result['city']}")
print(f"Country: {reverse_geocode_result['country_name']}")
else:
print(f"Could not reverse geocode coordinates: ({latitude}, {longitude})")
# Example of IP Geolocation
ip_address = "8.8.8.8" # Google's public DNS server
ip_location_result = gds.ip_geolocation(ip_address)
if ip_location_result:
print(f"\nIP Address: {ip_address}")
print(f"Country: {ip_location_result['country_name']}")
print(f"City: {ip_location_result['city']}")
print(f"Latitude: {ip_location_result['latitude']}")
print(f"Longitude: {ip_location_result['longitude']}")
else:
print(f"Could not get IP location for: {ip_address}")
This quickstart demonstrates the basic usage pattern for initializing the GeoDataSource client and performing common operations like geocoding, reverse geocoding, and IP geolocation. The returned data structures are dictionaries (or equivalent objects in other languages) containing various geographical attributes.
Community libraries
While GeoDataSource provides official SDKs, the broader developer community may contribute additional libraries or wrappers for specific frameworks, languages not officially supported, or for integrating GeoDataSource's local databases more efficiently. These community-driven projects can offer alternative approaches or extend functionality beyond the official offerings. Developers often publish such libraries on platforms like GitHub, PyPI for Python, npm for Node.js, or RubyGems for Ruby.
When considering community libraries, it is important to evaluate their maintenance status, documentation, and compatibility with the latest GeoDataSource API versions. One common pattern for interacting with APIs via community libraries is to use generic HTTP client libraries (such as requests in Python or axios in Node.js) to construct requests manually, adhering to the HTTP/1.1 specification for direct API calls if a specific SDK is unavailable or unsuitable. For example, a developer might use a general-purpose HTTP client to interact with any RESTful API, including GeoDataSource's. Always refer to the official GeoDataSource documentation for the most accurate and up-to-date API specifications when using or developing community wrappers.