Python client for the JSONCargo container tracking API
Project description
jsoncargo
Python client for the JSONCargo container tracking API.
pip install jsoncargo
Full API documentation: jsoncargo.com/documentation-api
Requirements
Python 3.8 or higher.
Setup
from jsoncargo import Client
client = Client("your_api_key")
Store your API key in an environment variable rather than hardcoding it:
import os
from jsoncargo import Client
client = Client(os.environ["JSONCARGO_API_KEY"])
Track a container
container = client.containers.track("MSCU1234567")
print(container.container_id) # MSCU1234567
print(container.status) # In Transit
print(container.shipped_from) # SHANGHAI, CN
print(container.shipped_to) # ROTTERDAM, NL
print(container.eta_final_destination) # 2024-08-01 00:00
print(container.current_vessel_name) # MSC LENA F
If the container prefix is shared across multiple carriers, pass the shipping_line parameter:
container = client.containers.track("MNBU0171007", shipping_line="MAERSK")
Valid shipping line values: MAERSK, HAPAG_LLOYD, HMM, ONE, EVERGREEN, MSC, CMA_CGM, COSCO, ZIM, YANG_MING, PIL
Get containers from a bill of lading
result = client.containers.from_bol("SELM60819800", shipping_line="HMM")
print(result.bill_of_lading) # SELM60819800
print(result.associated_containers) # 16
print(result.associated_container_numbers) # ['CAIU9933760', 'HMMU6053862', ...]
shipping_line is always required for bill of lading lookups.
Check API key usage
stats = client.stats()
print(stats["plan"]) # MARINER
print(stats["requests_total"]) # 2000
print(stats["requests_made"]) # 47
print(stats["requests_available"]) # 1953
Container fields
| Field | Type | Description |
|---|---|---|
container_id |
str | Container number |
container_type |
str | Container type |
status |
str | Current status |
shipping_line_name |
str | Full shipping line name |
shipping_line_id |
str | Internal shipping line ID |
tare |
float | Tare weight in kg |
shipped_from |
str | Origin location |
shipped_from_terminal |
str | Origin terminal |
shipped_to |
str | Destination location |
shipped_to_terminal |
str | Destination terminal |
atd_origin |
str | Actual departure from origin |
eta_final_destination |
str | ETA at final destination |
last_location |
str | Most recent location |
next_location |
str | Next expected location |
loading_port |
str | Port of loading |
discharging_port |
str | Port of discharge |
bill_of_lading |
str | Associated BOL number |
current_vessel_name |
str | Current vessel |
current_voyage_number |
str | Current voyage |
last_updated |
str | Data last refreshed |
raw |
dict | Full raw API response |
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jsoncargo-0.1.0.tar.gz.
File metadata
- Download URL: jsoncargo-0.1.0.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5db811207f8b5432d8ed62ffb167dc9cea9d4be697e99027b1a92c4b81a303e
|
|
| MD5 |
44a78e90f026c900cd6d0dffc10dd551
|
|
| BLAKE2b-256 |
3c8d10fe99df45086efdc31ddcbb528df5b527bd7b6eb7147a888c840544507f
|
File details
Details for the file jsoncargo-0.1.0-py3-none-any.whl.
File metadata
- Download URL: jsoncargo-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d74d035bd95c964cbe8f8ebd43d0cf001c099ac24089bd3ca81c15876e5e5d3
|
|
| MD5 |
8a350ff5339588d6ca6b0430ae6f48e6
|
|
| BLAKE2b-256 |
635b17f8f0cbabd482a75bcc058f5549f3e3c90f5bf4f9269d2ff1b63fd3dc39
|