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.1.tar.gz (5.7 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.1-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file jsoncargo-0.1.1.tar.gz.

File metadata

  • Download URL: jsoncargo-0.1.1.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for jsoncargo-0.1.1.tar.gz
Algorithm Hash digest
SHA256 80b7ce28adff9a3a87a4bfd653a528d313610fa4b012767f5d594b028dab2eae
MD5 ceb8e5b720ecc537ce7801b637f6276d
BLAKE2b-256 e33392ba943ab07773f7e63d470852e0bf45de3f89eac06e152fc385b59a0dda

See more details on using hashes here.

File details

Details for the file jsoncargo-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: jsoncargo-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for jsoncargo-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4700d41d44dd5c1b9c14bcaf61a04309a9f897b7585cbbdf51860c18301bd7e7
MD5 34a586f540b0e494cfb8c1ceb2e64412
BLAKE2b-256 cfea99b5b8a2f4bd0a4e319d8a196735e82b7d8570898da141f3de4e3ed0272f

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