Marine Traffic Client Api
Project description
Marine Traffic API Client Python Library
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__")
Default params
response = api.__api_call_method__(protocol='json'|'jsono'|'csv'|'xml', # default is jsono
msg_type='simple'|'extended', # default is simple
timeout=10) # default is 5 (5 seconds)
# protocol and msg_type are call params
# that could be used in any api call.
# json protocol is not supported by models, for now.
# extended msg_type returns a lot more data but cost
# a lot more api credits as well.
response.raw_data # raw data from api call (json, csv or xml)
response.formatted_data # data list
response.models # list of Client models representing the data
Vessels Positions
[PS01] Vessel History Track
vessel_positions = api.vessel_historical_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
[PS02] Vessel Positions of a Static Fleet
vessels = api.static_fleet_vessel_positions(time_span=10)
for vessel in vessels.models:
vessel.mmsi
vessel.imo
vessel.ship_id
vessel.longitude
vessel.latitude
vessel.speed
vessel.heading
vessel.status
vessel.course
vessel.timestamp
vessel.dsrc
vessel.utc_seconds
vessel.ship_name
vessel.ship_type
vessel.call_sign
vessel.flag
vessel.length
vessel.width
vessel.grt
vessel.dwt
vessel.draught
vessel.year_built
vessel.rot
vessel.type_name
vessel.ais_type_summary
vessel.destination
vessel.eta
vessel.current_port
vessel.last_port
vessel.last_port_time
vessel.current_port_id
vessel.current_port_unlocode
vessel.current_port_country
vessel.last_port_id
vessel.last_port_unlocode
vessel.last_port_country
vessel.next_port_id
vessel.next_port_unlocode
vessel.next_port_name
vessel.next_port_country
vessel.eta_calc
vessel.eta_updated
vessel.distance_to_go
vessel.distance_travelled
vessel.awg_speed
vessel.max_speed
[PS03] Vessel Positions of a Dynamic Fleet
vessels = api.dynamic_fleet_vessel_positions(time_span=10)
for vessel in vessels.models:
vessel.mmsi
vessel.imo
vessel.ship_id
vessel.longitude
vessel.latitude
vessel.speed
vessel.heading
vessel.status
vessel.course
vessel.timestamp
vessel.dsrc
vessel.utc_seconds
vessel.ship_name
vessel.ship_type
vessel.call_sign
vessel.flag
vessel.length
vessel.width
vessel.grt
vessel.dwt
vessel.draught
vessel.year_built
vessel.rot
vessel.type_name
vessel.ais_type_summary
vessel.destination
vessel.eta
vessel.current_port
vessel.last_port
vessel.last_port_time
vessel.current_port_id
vessel.current_port_unlocode
vessel.current_port_country
vessel.last_port_id
vessel.last_port_unlocode
vessel.last_port_country
vessel.next_port_id
vessel.next_port_unlocode
vessel.next_port_name
vessel.next_port_country
vessel.eta_calc
vessel.eta_updated
vessel.distance_to_go
vessel.distance_travelled
vessel.awg_speed
vessel.max_speed
Voyage Info
[VI03] Port Distance and Routes
routes = api.port_distances_and_routes(port_start_id=1,
port_target_id=10,
include_alternatives=True,
include_in_land=True)
for route in routes.models:
route.distance
route.panama
route.suez
route.final_path
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.vessel_historical_track(...)
# 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
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
Marine Traffic API-0.4.0.tar.gz
(14.1 kB
view details)
File details
Details for the file Marine Traffic API-0.4.0.tar.gz
.
File metadata
- Download URL: Marine Traffic API-0.4.0.tar.gz
- Upload date:
- Size: 14.1 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5183f0b42f22e59206707f59f0828b3ec290c3147fc20e07c1c156e42fb7a1fd |
|
MD5 | 93ecb1925c309e959ff56999c266bf42 |
|
BLAKE2b-256 | 8f0be82e2885112128e8024372ba9ab91debf9fdfffd60013afea266fc011517 |