Getting Started

Sections

Theme switcher

How to analyze change of vessel’s draft in Goteborg (port)?

Are you willing to understand how vessels’ draft adapts based on port calls at all different berths of a port and for all types of vessels?

This code captures the variations of draft for all entries and exits of berths in the port of Goteborg for all drybulk, gas, tanker and container vessels over the time.

The result enables you to analyze and visualize easily on a graph (see screenshot) the variation based on berths and type of vessels.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 import requests import pandas as pd token = "INSERT MY TOKEN" # Enter your personal token provided by AXSMarine to use AXSMarine Data port_unlocode = 'SEGOT' # Enter the ‘UN Port Code’ of the port. This code will retrieve all berths being in the corresponding port. The ‘UN Port Code’ can also be found using the AXSMarine Locations APIs. polygon_types = ['berth'] # For all API calls to AXSMarine’s Data, the token is required in the Authorization header headers = { "Authorization": "Bearer {}".format(token) } # -------------------------------------------------------------------------- # Using the Global Events API # # Fetch all berth events for the specified UN port code (e.g. SEGOT) # # for every vessel tracked by AXSMarine, starting from 2020‑01‑01 # # and with a minimum duration of 1 hour. # # -------------------------------------------------------------------------- url = "https://apihub.axsmarine.com/global/events/v1" variables = { "pageSize": 2000, 'polygonTypes': polygon_types, 'ancestorPolygons': [port_unlocode], 'entryDate': { 'from': '2020-01-01' }, 'durationMinHour': 1 } query = """ query polygonEvents($pageSize: Int, $afterCursor: String, $polygonTypes: [String], $ancestorPolygons: [String], $entryDate: RangeDate, $durationMinHour: Int){ polygonEvents(first: $pageSize, after: $afterCursor, polygonTypes: $polygonTypes, ancestorPolygons: $ancestorPolygons, entryDate: $entryDate, duration: {from: $durationMinHour}) { pageInfo { endCursor hasNextPage } edges { node { polygon {_id, name} vessel {imo, name, type, draft} entryAis {time, draft} outAis {time, draft} } } } } """ data = None while True: print(f"Call GraphQL to {url, variables} ...") response = requests.post(url, json={'query': query, 'variables': variables}, headers=headers) response.raise_for_status() json = response.json()['data']['polygonEvents'] data = pd.concat([data, pd.json_normalize([i['node'] for i in json['edges']])]) if not json['pageInfo']['hasNextPage']: break variables['afterCursor'] = json['pageInfo']['endCursor'] data.to_csv(f'{port_unlocode}_events.csv', index=False)

POST

/

Select
1

Response