SDKs overview

WhereParcel provides Software Development Kits (SDKs) to simplify integration with its tracking API. These SDKs abstract the underlying HTTP requests and JSON response parsing, allowing developers to interact with WhereParcel services using native language constructs. The primary goal of these libraries is to reduce the boilerplate code required for common operations, such as tracking shipments, retrieving carrier information, and managing webhooks for real-time updates. By using an SDK, developers can focus on application logic rather than the intricacies of API communication, authentication, and error handling. WhereParcel's API is designed as RESTful web services, consistently returning JSON formatted data for all requests.

The official SDKs are maintained by WhereParcel and are designed to be compatible with the latest API versions, ensuring access to new features and stability. In addition to official support, a developer community contributes third-party libraries and tools, extending integration possibilities across various platforms and frameworks. These community efforts often provide specialized wrappers or integrations that cater to specific use cases or development environments not directly covered by the official SDKs.

Official SDKs by language

WhereParcel offers official SDKs for several popular programming languages, providing a streamlined experience for developers. Each SDK is designed to encapsulate the API's functionality within the conventions of its respective language, offering methods for key operations such as adding tracking numbers, fetching shipment details, and configuring notifications.

Language Package/Module Installation Command Maturity
Node.js @whereparcel/node-sdk npm install @whereparcel/node-sdk or yarn add @whereparcel/node-sdk Stable
PHP whereparcel/php-sdk composer require whereparcel/php-sdk Stable
Python whereparcel-python-sdk pip install whereparcel-python-sdk Stable
Ruby whereparcel-ruby-sdk gem install whereparcel-ruby-sdk Stable
Java com.whereparcel:java-sdk Add to pom.xml (Maven) or build.gradle (Gradle) Stable
Go github.com/whereparcel/go-sdk go get github.com/whereparcel/go-sdk Stable

Each SDK's documentation, including detailed API method references and usage examples, can be found within the WhereParcel official documentation portal. Developers are encouraged to consult these resources for the most up-to-date information on specific SDK versions and their capabilities. The SDKs handle common tasks such as authentication with API keys, proper request formatting, and robust error handling, which are critical for reliable integration. For example, the Node.js SDK automatically manages asynchronous operations using Promises, aligning with modern JavaScript development practices.

Installation

Installation of WhereParcel SDKs typically follows the standard package management practices for each respective language. Below are detailed instructions for installing the official SDKs.

Node.js

To install the Node.js SDK, use npm or Yarn:

npm install @whereparcel/node-sdk
# or
yarn add @whereparcel/node-sdk

This command downloads the package and its dependencies, making the whereparcel client available in your Node.js project. Ensure you have Node.js and npm/Yarn installed on your system. You can verify your Node.js installation by running node -v in your terminal.

PHP

The PHP SDK is distributed via Composer, the dependency manager for PHP:

composer require whereparcel/php-sdk

This command adds the whereparcel/php-sdk package to your project's composer.json file and installs it. After installation, you can include Composer's autoloader in your PHP script to use the SDK classes.

Python

For Python, use pip, the Python package installer:

pip install whereparcel-python-sdk

This command installs the Python SDK into your active Python environment. It is recommended to use a virtual environment for your Python projects to manage dependencies effectively, as described in the Python virtual environments tutorial.

Ruby

The Ruby SDK is available as a RubyGems package:

gem install whereparcel-ruby-sdk

This command installs the gem globally or within your project's Gemfile if you are using Bundler. If using Bundler, add gem 'whereparcel-ruby-sdk' to your Gemfile and run bundle install.

Java

For Java projects, you typically add the SDK as a dependency in your build tool's configuration file. For Maven, add the following to your pom.xml:

<dependency>
    <groupId>com.whereparcel</groupId>
    <artifactId>java-sdk</artifactId>
    <version>1.0.0</version> <!-- Replace with the latest version -->
</dependency>

For Gradle, add it to your build.gradle file:

implementation 'com.whereparcel:java-sdk:1.0.0' // Replace with the latest version

Always check the WhereParcel API documentation for the latest stable version number.

Go

To install the Go SDK, use the go get command:

go get github.com/whereparcel/go-sdk

This command fetches the module and adds it to your go.mod file. You can then import the package in your Go source files.

Quickstart example

This quickstart example demonstrates how to use the Node.js SDK to track a new shipment and retrieve its details. The principle is similar across other languages, involving initialization with an API key and calling specific methods to interact with the WhereParcel API.

const WhereParcel = require('@whereparcel/node-sdk');

// Initialize the WhereParcel client with your API key
const client = new WhereParcel('YOUR_API_KEY');

async function trackShipment() {
  try {
    // 1. Add a new tracking number
    const addResponse = await client.trackings.add({
      tracking_number: 'LP0001234567890',
      carrier_code: 'usps',
      title: 'My First Parcel'
    });
    console.log('Tracking added:', addResponse.data);

    // 2. Retrieve the details of the newly added tracking
    const trackingId = addResponse.data.id; // Assuming the ID is returned
    const getResponse = await client.trackings.get(trackingId);
    console.log('Tracking details:', getResponse.data);

    // 3. Optionally, list all trackings
    const listResponse = await client.trackings.list();
    console.log('All trackings:', listResponse.data);

  } catch (error) {
    console.error('Error tracking shipment:', error.response ? error.response.data : error.message);
  }
}

trackShipment();

Replace 'YOUR_API_KEY' with your actual WhereParcel API key, which can be obtained from your WhereParcel account dashboard. The carrier_code should correspond to a supported carrier; WhereParcel's documentation provides a list of supported carriers. This example demonstrates a common workflow: adding a parcel to be tracked, and then retrieving its current status. Error handling is included to catch potential issues during API calls, such as invalid API keys or malformed requests.

Community libraries

Beyond the official SDKs, the WhereParcel developer community has contributed various libraries and integrations that extend the platform's reach. These community-driven projects often address specific use cases, frameworks, or languages not directly covered by official support. Examples might include:

  • Framework-specific wrappers: Libraries tailored for popular web frameworks like Django (Python), Ruby on Rails (Ruby), or Laravel (PHP), providing more idiomatic integration patterns.
  • Front-end components: JavaScript libraries or React components that simplify displaying tracking information directly within web applications.
  • CLI tools: Command-line interfaces built on top of the WhereParcel API for administrative tasks or quick lookups.
  • Unlisted languages: SDKs or client libraries for languages not officially supported, such as Rust or C#.

While community libraries can offer flexibility and cater to niche requirements, it is important to note that they may not always be as up-to-date or as rigorously maintained as the official SDKs. Developers considering community contributions should review the project's documentation, community activity, and compatibility with the latest WhereParcel API version. Resources like GitHub and other open-source repositories are common places to discover these contributions. For instance, developers often share their open-source projects on platforms like GitHub topic pages, allowing others to discover and contribute.

WhereParcel encourages community contributions and often highlights notable projects within its developer forums or documentation. However, support for these libraries typically comes from their respective maintainers rather than directly from WhereParcel. When incorporating community code, developers should perform due diligence to ensure code quality, security, and ongoing maintenance.