Skip to main content

Marine Traffic Client Api

Project description

Marine Traffic API Client Python Library

PyPI version

Installation

Works on python 3.x.

pip install Marine-Traffic-API

Usage

from marinetrafficapi import MarineTrafficApi

# initialize API
api = MarineTrafficApi(api_key="__your_api_key_here__")

# fetch ship routes
routes = api.routes(port_start_id=1, 
                    port_target_id=10, 
                    include_alternatives=True, 
                    include_in_land=True)

# Data could be fetched in 3 different ways:
routes.raw_data  # raw data from api call
routes.formatted_data  # json, xml (lxml etree) or csv (pandas csv) formatted
routes.models  # list of Client models representing the data

# iterate over the route models
for route in routes.models:
	route.distance
	route.panama
	route.suez
	route.final_path

# fetch vessel positions
vessel_positions = api.vessel_track(period='daily', 
                                    days=3, 
                                    mmsi=241486000)

# iterate over position models
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.0.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

Marine_Traffic_API-0.2.0-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: Marine Traffic API-0.2.0.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.7.2

File hashes

Hashes for Marine Traffic API-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2332e390b6ecf0f08b15a8be0120eb2e5f609624520fe2e25bd50b49325e1647
MD5 e1a366507d80216dbad3b0525c201486
BLAKE2b-256 73ff5eda6860ebc3588a658f3cf5f7ffbfc248be82c845190b0c86894f8348bc

See more details on using hashes here.

File details

Details for the file Marine_Traffic_API-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: Marine_Traffic_API-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.7.2

File hashes

Hashes for Marine_Traffic_API-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9a69560103035dc5aee6fd0cc09065d825421d64ae5e3edce47575e76aef9f25
MD5 8d9dc4a91c4666dbcbc3ae05ef4d4e96
BLAKE2b-256 508f6badcedde48b56c24d1379c9784ec9c52e6747825df01097914b2e85d821

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