Shippo is a shipping API that connects you with multiple shipping carriers (such as USPS, UPS, DHL, Canada Post, Australia Post, and many others) through one interface.
You must register for a Shippo account to use our API. It's free to sign up. Only pay to print a live label, test labels are free.
To use the API, you must generate an API Token. In the following examples, replace <YOUR_API_KEY_HERE>
with
your own token.
For example.
Shippo sdk = Shippo.builder()
.apiKeyHeader("<YOUR_API_KEY_HERE>")
.build();
Shippo external API.: Use this API to integrate with the Shippo service
JDK 11 or later is required.
The samples below show how a published SDK artifact is used:
Gradle:
implementation 'com.goshippo:shippoSDK:1.0.0-beta.1'
Maven:
<dependency>
<groupId>com.goshippo</groupId>
<artifactId>shippoSDK</artifactId>
<version>1.0.0-beta.1</version>
</dependency>
After cloning the git repository to your file system you can build the SDK artifact from source to the build
directory by running ./gradlew build
on *nix systems or gradlew.bat
on Windows systems.
If you wish to build from source and publish the SDK artifact to your local Maven repository (on your filesystem) then use the following command (after cloning the git repo locally):
On *nix:
./gradlew publishToMavenLocal -Pskip.signing
On Windows:
gradlew.bat publishToMavenLocal -Pskip.signing
package hello.world;
import com.goshippo.shippo_sdk.Shippo;
import com.goshippo.shippo_sdk.models.operations.ListAddressesResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws Exception {
Shippo sdk = Shippo.builder()
.apiKeyHeader("<YOUR_API_KEY_HERE>")
.shippoApiVersion("2018-02-08")
.build();
ListAddressesResponse res = sdk.addresses().list()
.page(1L)
.results(5L)
.shippoApiVersion("2018-02-08")
.call();
if (res.addressPaginatedList().isPresent()) {
// handle response
}
}
}
Available methods
- list - List all addresses
- create - Create a new address
- get - Retrieve an address
- validate - Validate an address
- create - Create a batch
- get - Retrieve a batch
- addShipments - Add shipments to a batch
- purchase - Purchase a batch
- removeShipments - Remove shipments from a batch
- list - List all carrier accounts
- create - Create a new carrier account
- get - Retrieve a carrier account
- update - Update a carrier account
- initiateOauth2Signin - Connect an existing carrier account using OAuth 2.0
- register - Add a Shippo carrier account
- getRegistrationStatus - Get Carrier Registration status
- list - List all customs declarations
- create - Create a new customs declaration
- get - Retrieve a customs declaration
- create - Create a pickup
- get - Retrieve a rate
- listShipmentRates - Retrieve shipment rates
- listShipmentRatesByCurrencyCode - Retrieve shipment rates in currency
- create - Generate a live rates request
- getDefaultParcelTemplate - Show current default parcel template
- updateDefaultParcelTemplate - Update default parcel template
- deleteDefaultParcelTemplate - Clear current default parcel template
- list - List all service groups
- create - Create a new service group
- update - Update an existing service group
- delete - Delete a service group
- list - List all Shippo Accounts
- create - Create a Shippo Account
- get - Retrieve a Shippo Account
- update - Update a Shippo Account
- list - List all user parcel templates
- create - Create a new user parcel template
- delete - Delete a user parcel template
- get - Retrieves a user parcel template
- update - Update an existing user parcel template
- createWebhook - Create a new webhook
- listWebhooks - List all webhooks
- getWebhook - Retrieve a specific webhook
- updateWebhook - Update an existing webhook
- deleteWebhook - Delete a specific webhook
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.
While we value open-source contributions to this SDK, this library is generated programmatically. Feel free to open a PR or a Github issue as a proof of concept and we'll do our best to include it in a future release!
Connect with multiple different carriers, get discounted shipping labels, track parcels, and much more with just one integration. You can use your own carrier accounts or take advantage of our discounted rates with the Shippo carrier accounts. Using Shippo makes it easy to deal with multiple carrier integrations, rate shopping, tracking and other parts of the shipping workflow. We provide the API and web app for all your shipping needs.
Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an exception.
By default, an API error will throw a models/errors/SDKError
exception. When custom error responses are specified for an operation, the SDK may also throw their associated exception. You can refer to respective Errors tables in SDK docs for more details on possible exception types for each operation. For example, the initiateOauth2Signin
method throws the following exceptions:
Error Type | Status Code | Content Type |
---|---|---|
models/errors/InitiateOauth2SigninResponseBody | 400 | application/json |
models/errors/InitiateOauth2SigninCarrierAccountsResponseBody | 401 | application/json |
models/errors/InitiateOauth2SigninCarrierAccountsResponseResponseBody | 404 | application/json |
models/errors/SDKError | 4XX, 5XX | */* |
package hello.world;
import com.goshippo.shippo_sdk.Shippo;
import com.goshippo.shippo_sdk.models.errors.InitiateOauth2SigninCarrierAccountsResponseBody;
import com.goshippo.shippo_sdk.models.errors.InitiateOauth2SigninCarrierAccountsResponseResponseBody;
import com.goshippo.shippo_sdk.models.errors.InitiateOauth2SigninResponseBody;
import com.goshippo.shippo_sdk.models.operations.InitiateOauth2SigninResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws InitiateOauth2SigninResponseBody, InitiateOauth2SigninCarrierAccountsResponseBody, InitiateOauth2SigninCarrierAccountsResponseResponseBody, Exception {
Shippo sdk = Shippo.builder()
.apiKeyHeader("<YOUR_API_KEY_HERE>")
.shippoApiVersion("2018-02-08")
.build();
InitiateOauth2SigninResponse res = sdk.carrierAccounts().initiateOauth2Signin()
.carrierAccountObjectId("<id>")
.redirectUri("https://enlightened-mortise.com/")
.state("Louisiana")
.shippoApiVersion("2018-02-08")
.call();
// handle response
}
}
The default server can also be overridden globally using the .serverURL(String serverUrl)
builder method when initializing the SDK client instance. For example:
package hello.world;
import com.goshippo.shippo_sdk.Shippo;
import com.goshippo.shippo_sdk.models.operations.ListAddressesResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws Exception {
Shippo sdk = Shippo.builder()
.serverURL("https://api.goshippo.com")
.apiKeyHeader("<YOUR_API_KEY_HERE>")
.shippoApiVersion("2018-02-08")
.build();
ListAddressesResponse res = sdk.addresses().list()
.page(1L)
.results(5L)
.shippoApiVersion("2018-02-08")
.call();
if (res.addressPaginatedList().isPresent()) {
// handle response
}
}
}
This SDK supports the following security scheme globally:
Name | Type | Scheme |
---|---|---|
apiKeyHeader |
apiKey | API key |
To authenticate with the API the apiKeyHeader
parameter must be set when initializing the SDK client instance. For example:
package hello.world;
import com.goshippo.shippo_sdk.Shippo;
import com.goshippo.shippo_sdk.models.operations.ListAddressesResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws Exception {
Shippo sdk = Shippo.builder()
.apiKeyHeader("<YOUR_API_KEY_HERE>")
.shippoApiVersion("2018-02-08")
.build();
ListAddressesResponse res = sdk.addresses().list()
.page(1L)
.results(5L)
.shippoApiVersion("2018-02-08")
.call();
if (res.addressPaginatedList().isPresent()) {
// handle response
}
}
}