SDKs overview
SpotSense offers a suite of Software Development Kits (SDKs) designed to streamline the integration of its geolocation and mapping services into various applications. These SDKs encapsulate the complexities of direct API calls, providing developers with idiomatic interfaces for common tasks such as geocoding, reverse geocoding, and address autocomplete. By utilizing an SDK, developers can reduce the amount of boilerplate code required and focus on application-specific logic, as detailed in the SpotSense developer documentation.
The official SDKs are maintained by SpotSense and are designed to provide stable and feature-rich access to the platform's core functionalities. They typically handle API authentication, request formatting, and response parsing, adhering to the SpotSense API reference specifications. The availability of SDKs across multiple programming languages supports a broad range of development environments and project requirements, aligning with common API integration patterns observed across the industry, such as those described in Mozilla's API documentation.
Official SDKs by language
SpotSense provides official SDKs for several popular programming languages, ensuring broad compatibility and ease of integration for developers. These SDKs are maintained to reflect the latest API versions and best practices. The following table summarizes the key details for each official SDK:
| Language | Package Name | Install Command Example | Maturity |
|---|---|---|---|
| JavaScript | @spotsense/js-sdk |
npm install @spotsense/js-sdk |
Stable |
| Node.js | @spotsense/node-sdk |
npm install @spotsense/node-sdk |
Stable |
| Python | spotsense-python |
pip install spotsense-python |
Stable |
| Ruby | spotsense-ruby |
gem install spotsense-ruby |
Stable |
| Go | github.com/spotsense/go-sdk |
go get github.com/spotsense/go-sdk |
Stable |
| PHP | spotsense/php-sdk |
composer require spotsense/php-sdk |
Stable |
| Java | com.spotsense:java-sdk |
Add to pom.xml (Maven) or build.gradle (Gradle) |
Stable |
Each SDK is designed to provide a consistent experience across different environments, abstracting the underlying HTTP requests and JSON parsing. Developers can refer to the specific SpotSense SDK documentation for detailed API method mappings and usage examples for each language.
Installation
Installing a SpotSense SDK typically involves using the standard package manager for the respective programming language. The process ensures that all necessary dependencies are resolved and the SDK can be imported into your project. Below are common installation instructions for the officially supported SDKs:
JavaScript / Node.js
For JavaScript-based projects, including Node.js environments, the SDK can be installed via npm or yarn:
# Using npm
npm install @spotsense/js-sdk
# Using yarn
yarn add @spotsense/js-sdk
After installation, the module can be imported using ES6 modules or CommonJS syntax.
Python
Python developers can install the SpotSense SDK using pip, the Python package installer:
pip install spotsense-python
Upon successful installation, the library can be imported into Python scripts.
Ruby
For Ruby applications, the SDK is available as a RubyGems package:
gem install spotsense-ruby
The gem can then be required in Ruby code.
Go
Go developers can fetch the SDK using the go get command:
go get github.com/spotsense/go-sdk
This command downloads the package and its dependencies into the Go module cache.
PHP
The PHP SDK is distributed via Composer, the PHP dependency manager:
composer require spotsense/php-sdk
After running this command, Composer's autoloader will make the SDK classes available.
Java
For Java projects, the SDK can be included as a dependency in your build tool configuration (e.g., Maven or Gradle). For Maven, add the following to your pom.xml:
<dependency>
<groupId>com.spotsense</groupId>
<artifactId>java-sdk</artifactId>
<version>1.0.0</version> <!-- Use the latest version -->
</dependency>
For Gradle, add to your build.gradle:
implementation 'com.spotsense:java-sdk:1.0.0' // Use the latest version
Consult the SpotSense installation guides for the most current version numbers and detailed instructions.
Quickstart example
This quickstart example demonstrates how to use the SpotSense Python SDK to perform a geocoding request. It assumes you have already installed the spotsense-python package and have a valid SpotSense API key.
Python Geocoding Example
import os
from spotsense import SpotSenseClient
# It's recommended to store your API key as an environment variable
api_key = os.environ.get("SPOTSENSE_API_KEY")
if not api_key:
print("Error: SPOTSENSE_API_KEY environment variable not set.")
exit()
client = SpotSenseClient(api_key)
address = "1600 Amphitheatre Parkway, Mountain View, CA"
try:
# Perform a geocoding request
geocoded_result = client.geocode(address)
if geocoded_result and geocoded_result.get("features"):
print(f"Geocoding results for '{address}':")
for feature in geocoded_result["features"]:
properties = feature.get("properties", {})
geometry = feature.get("geometry", {})
coordinates = geometry.get("coordinates")
print(f" Address: {properties.get('formatted_address', 'N/A')}")
print(f" Latitude: {coordinates[1] if coordinates else 'N/A'}")
print(f" Longitude: {coordinates[0] if coordinates else 'N/A'}")
print(f" Confidence: {properties.get('confidence', 'N/A')}")
else:
print(f"No geocoding results found for '{address}'.")
except Exception as e:
print(f"An error occurred: {e}")
This example initializes the SpotSenseClient with an API key retrieved from an environment variable. It then calls the geocode method with a sample address and prints relevant details from the first returned feature. This pattern can be adapted for other SpotSense API calls, such as reverse geocoding or address autocomplete, by invoking the respective methods on the client object. More detailed examples for each API endpoint are available in the SpotSense code examples section.
Community libraries
While SpotSense provides official SDKs for core languages, the developer community may also contribute third-party libraries or integrations. These community-driven projects can offer specialized functionalities, integrations with specific frameworks, or support for additional programming languages not officially covered. Community libraries are typically hosted on platforms like GitHub and are often developed to address niche use cases or to provide alternative approaches to API interaction.
Developers considering community libraries should evaluate their stability, maintenance status, and compatibility with the latest SpotSense API versions. It is advisable to review the project's documentation, issue tracker, and recent commit history. While some community libraries may offer unique benefits, they do not carry the same level of official support or guarantees as the SDKs provided directly by SpotSense. For a comprehensive list of available tools and integrations, including any community-contributed resources, developers can refer to the SpotSense developer portal.