Skip to main content

Marine Traffic Client Api

Project description

Marine Traffic API Client Python Library

PyPI version Build Status

Installation

Works on python 3.x.

pip install Marine-Traffic-API

Initialize API

from marinetrafficapi import MarineTrafficApi

api = MarineTrafficApi(api_key="__your_api_key_here__")

[VI03] Port Distance and Routes

routes = api.routes(port_start_id=1, 
                    port_target_id=10, 
                    include_alternatives=True, 
                    include_in_land=True,
                    protocol='json'|'jsono'|'csv'|'xml')

routes.raw_data  # raw data from api call (json, csv or xml)
routes.formatted_data  # data list
routes.models  # list of Client models representing the data

for route in routes.models:
	route.distance
	route.panama
	route.suez
	route.final_path

[PS01] Vessel History Track

vessel_positions = api.vessel_track(period='daily', 
                                    days=3, 
                                    mmsi=241486000)

for position in vessel_positions.models:
	position.mmsi
	position.status
	position.speed
	position.longitude
	position.latitude
	position.course
	position.heading
	position.timestamp
	position.ship_id
	position.wind_angle

Debugging

If you want to debug your code using the data regarding the API call.

# initialize with debug=True
api = MarineTrafficApi(api_key="...", debug=True)

# after every API call the client library will automatically print all the data to standard output
api.routes(...)

# and you can always have all debug data in your code
debug_data = api.request.debug.show()

Official documentation

For more information visit official documentation: https://www.marinetraffic.com/en/ais-api-services/

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

Marine Traffic API-0.2.2.tar.gz (9.6 kB view details)

Uploaded Source

File details

Details for the file Marine Traffic API-0.2.2.tar.gz.

File metadata

  • Download URL: Marine Traffic API-0.2.2.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.3

File hashes

Hashes for Marine Traffic API-0.2.2.tar.gz
Algorithm Hash digest
SHA256 1c1ffd05defdbf3794fbd57c87312dd4514dc0c0d5c552eba3c2c62a42249fba
MD5 4635bb1267368ee35c6d904fe3f8321b
BLAKE2b-256 e64d7784ee1e2b07b39c7910d15bebe99ff5766185a8007371db43612531e40b

See more details on using hashes here.

Supported by

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