Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jsoncargo-0.1.0.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jsoncargo-0.1.0-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

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

Hashes for jsoncargo-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d5db811207f8b5432d8ed62ffb167dc9cea9d4be697e99027b1a92c4b81a303e
MD5 44a78e90f026c900cd6d0dffc10dd551
BLAKE2b-256 3c8d10fe99df45086efdc31ddcbb528df5b527bd7b6eb7147a888c840544507f

See more details on using hashes here.

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

Hashes for jsoncargo-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0d74d035bd95c964cbe8f8ebd43d0cf001c099ac24089bd3ca81c15876e5e5d3
MD5 8a350ff5339588d6ca6b0430ae6f48e6
BLAKE2b-256 635b17f8f0cbabd482a75bcc058f5549f3e3c90f5bf4f9269d2ff1b63fd3dc39

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page