SDKs overview
US Street Address offers a suite of Software Development Kits (SDKs) designed to facilitate integration with its US Street Address API. These SDKs are available for multiple programming languages, abstracting the complexities of direct HTTP requests and responses. The primary goal of these libraries is to enable developers to perform address validation, standardization, and enrichment tasks within their chosen development environments with minimal boilerplate code. By using an SDK, developers can interact with the US Street Address API using native language constructs, which can simplify tasks such as authentication, request construction, and parsing of structured address data responses. The API itself is a RESTful service, allowing for direct HTTP interactions, but the SDKs provide a more idiomatic approach for common programming languages.
The SDKs handle various aspects of API interaction, including:
- Authentication: Managing API keys and authentication headers.
- Request Formatting: Constructing properly formatted JSON or query parameter requests.
- Response Parsing: Deserializing JSON responses into language-specific objects.
- Error Handling: Providing structured error messages for API-specific issues.
- Batch Processing: Optimizing requests for multiple addresses when supported.
Using an SDK can reduce development time and potential errors compared to manually handling HTTP requests and JSON serialization/deserialization. Developers seeking to integrate US Street Address functionality into web applications, backend services, or data processing pipelines often opt for the official SDKs due to their direct compatibility and maintenance by the provider. For more details on the API's capabilities and conceptual overview, refer to the US Street Address API documentation.
Official SDKs by language
The US Street Address API officially supports SDKs across several popular programming languages. These libraries are maintained by the platform provider and are intended to offer the most current and reliable integration experience. Each SDK is tailored to the conventions of its respective language, providing an interface that feels native to developers working in that ecosystem. This section outlines the officially supported SDKs, their typical package names, installation methods, and a general indication of their maturity and stability.
| Language | Package/Library Name | Install Command | Maturity |
|---|---|---|---|
| Python | smartystreets-python-sdk |
pip install smartystreets-python-sdk |
Stable, actively maintained |
| JavaScript | @smartystreets/us-street-api |
npm install @smartystreets/us-street-api |
Stable, actively maintained |
| PHP | smartystreets/php-sdk |
composer require smartystreets/php-sdk |
Stable, actively maintained |
| Ruby | smartystreets-ruby-sdk |
gem install smartystreets-ruby-sdk |
Stable, actively maintained |
| C# | SmartyStreets.SmartyStreets-dotnet-sdk |
dotnet add package SmartyStreets.SmartyStreets-dotnet-sdk |
Stable, actively maintained |
| Java | com.smartystreets:smartystreets-java-sdk |
Add to pom.xml (Maven) or build.gradle (Gradle) |
Stable, actively maintained |
| Go | github.com/smarty/smartystreets-go-sdk |
go get github.com/smarty/smartystreets-go-sdk |
Stable, actively maintained |
Each SDK's documentation provides specific usage examples and configurations, accessible via the main US Street Address API documentation portal. These resources often include details on handling authentication, constructing address lookup requests, and interpreting the verification results.
Installation
Installing an official SDK typically involves using a language-specific package manager. The process is designed to be straightforward, allowing developers to quickly add the library to their project dependencies. Below are general installation instructions for each supported language. Developers should consult the specific SDK's repository or the official documentation for the most up-to-date and detailed installation guidance, including prerequisites and potential environment configurations.
Python
For Python projects, the SDK is available on PyPI and can be installed using pip:
pip install smartystreets-python-sdk
It is generally recommended to install packages within a Python virtual environment to manage project dependencies effectively.
JavaScript
For JavaScript projects, especially in Node.js environments or for use with front-end build tools, the SDK is available via npm:
npm install @smartystreets/us-street-api
This command adds the package to your project's node_modules directory and updates package.json.
PHP
PHP projects typically use Composer for dependency management. The SDK can be added with the following command:
composer require smartystreets/php-sdk
This will download the SDK and add it to your composer.json file.
Ruby
Ruby projects use RubyGems. The SDK can be installed via the gem command:
gem install smartystreets-ruby-sdk
To include it in a project, add gem 'smartystreets-ruby-sdk' to your Gemfile and run bundle install.
C#
For .NET projects, the SDK is distributed as a NuGet package. It can be installed using the .NET CLI:
dotnet add package SmartyStreets.SmartyStreets-dotnet-sdk
Alternatively, it can be installed through the NuGet Package Manager in Visual Studio.
Java
Java projects commonly use Maven or Gradle. For Maven, add the following to your pom.xml:
<dependency>
<groupId>com.smartystreets</groupId>
<artifactId>smartystreets-java-sdk</artifactId>
<version>X.Y.Z</version> <!-- Replace with the latest version -->
</dependency>
For Gradle, add to your build.gradle:
implementation 'com.smartystreets:smartystreets-java-sdk:X.Y.Z' // Replace with the latest version
Ensure to replace X.Y.Z with the latest version of the Java SDK.
Go
Go modules are used for dependency management. The Go SDK can be fetched using the go get command:
go get github.com/smarty/smartystreets-go-sdk
This command downloads the package and its dependencies, adding them to your go.mod file.
Quickstart example
This quickstart example demonstrates how to use the US Street Address Python SDK to validate a single address. The principles shown here – initializing the client, creating a lookup object, and processing the response – are generally applicable across other SDKs, with syntax adapted to each language's conventions. For specific examples in other languages, refer to the official SDK documentation.
Python Quickstart
First, ensure you have the smartystreets-python-sdk installed (pip install smartystreets-python-sdk).
from smartystreets_python_sdk import StaticCredentials, ClientBuilder
from smartystreets_python_sdk.us_street import Lookup as StreetLookup
# Replace with your actual Auth ID and Auth Token
auth_id = 'YOUR_AUTH_ID'
auth_token = 'YOUR_AUTH_TOKEN'
# Initialize credentials and client
credentials = StaticCredentials(auth_id, auth_token)
client = ClientBuilder(credentials).build_us_street_api_client()
# Create a lookup object
lookup = StreetLookup(
street='1600 Amphitheatre Pkwy',
city='Mountain View',
state='CA',
zipcode='94043'
)
# Send the lookup
try:
client.send_lookup(lookup)
except Exception as err:
print(err)
exit()
# Process the response
if lookup.result:
print(f"Address found: {len(lookup.result)} candidate(s).")
for candidate in lookup.result:
delivery_line_1 = candidate.delivery_line_1
last_line = candidate.last_line
components = candidate.components
metadata = candidate.metadata
print(f" Primary Line: {delivery_line_1}")
print(f" Secondary Line: {last_line}")
print(f" City: {components.city_name}")
print(f" State: {components.state_abbreviation}")
print(f" Zip Code: {components.zipcode}-{components.plus4_code}")
print(f" Latitude: {metadata.latitude}, Longitude: {metadata.longitude}")
print(f" DPV Match Code: {metadata.dpv_match_code}")
else:
print("Address not found or invalid.")
This script first configures authentication with StaticCredentials, then builds a client for the US Street API. It constructs a StreetLookup object with the address components and sends it to the API. The response, if successful, contains a list of candidate addresses, which are then iterated through to display validated components and metadata. Error handling for network issues or API-specific errors is included. It is good practice to store API keys securely, such as in environment variables, rather than hardcoding them directly in source files.
Community libraries
While official SDKs are provided and maintained, the open-source community sometimes develops additional libraries or wrappers for APIs. These community-contributed tools can offer alternative approaches, integrate with specific frameworks, or extend functionality in ways not covered by official SDKs. For the US Street Address API, the primary recommended route for integration is through the official SDKs due to their direct support and alignment with the API's current features. As of the current review, community-driven SDKs or libraries that significantly diverge from or enhance the official offerings are less prevalent, likely due to the comprehensive nature of the official SDKs themselves.
Developers interested in exploring community contributions might search platforms like GitHub or package repositories (e.g., PyPI, npm) for projects tagged with "SmartyStreets" or "US Street Address API." When considering a community library, it's advisable to assess its maintenance status, community support, and compatibility with the latest API versions. Factors such as licensing, documentation quality, and active development are important considerations for incorporating third-party code into production systems. For general best practices regarding third-party libraries, consult resources such as the Mozilla Developer Network's guide to web technologies which often touches on API interaction patterns and considerations for client-side development.
If a specific use case is not fully met by the official SDKs, developers can also directly interact with the US Street Address REST API using standard HTTP clients available in virtually all programming languages. This approach offers maximum flexibility but requires manual handling of authentication, request/response serialization, and error management.