Demo Application

Learn to build a fully functional Django shipment management system using Shippo APIs.

We'll cover the following

In this lesson, we’ll see a sample Django application of a shipment management system. We’ve used the following endpoints in the application:

  1. Addresses: We’ll create to_address and from_address using the addresses endpoint.
  2. Parcels: We’ll create a parcel using the parcel's endpoint.
  3. Shipments: The addresses and the parcel above will be used to create a shipment object. The shipment object will contain a rate list of different carriers.
  4. Transactions: The user selects a rate from the rate list retrieved from the shipment object. The transaction endpoint will take that rate and place the shipment in the queue.

Workflow and APIs

Let’s dive into the code and see how we've integrated different Shippo APIs into our web application. We can see the contents of the views.py file in the widget below. Let’s discuss the code:

  • Line 13: The index function retrieves all the shipment transactions that have been made until now. These shipment transactions will display on the home page.
  • Line 51 and 68: The create_sender_address and create_recepient_address functions are used to create addresses. These functions receive inputs from the GUI.
  • Line 85: The create_parcel function creates a parcel and receives inputs from the GUI.
  • Line 102: The create_shipment function requires two addresses and a parcel detail to create a shipment. After the shipment has been created, a rate list of different carriers will return with the shipment object. We retrieve this list and display it on the GUI.
  • Line 133: The transaction function will take the ID of a rate object selected by the user and complete the shipment transaction.

Demo

The demo application can be run by clicking “Run” in the widget below. Before that, don’t forget to enter the TOKEN. Once the server starts, click the link next to “Your app can be found at”:

Note: The following widget only shows the necessary files required to explain the endpoints of the Shippo API.

Get hands-on with 1200+ tech skills courses.