Getting Started

Sections

Theme switcher

📊 Pagination

Simple code snippet to request all results for a query with more than 5 000 results

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 import requests import pandas as pd # Base url url = "https://apihub.axsmarine.com/tanker/ship-status/current/v2?" params = { "page_size" : "5000", } # Add token token = "INSERT MY TOKEN" headers = { "Authorization": "Bearer {}".format(token) } # Add parameters for name,value in params.items(): url = url + "&" + name + "=" + value response = requests.get(url, headers=headers).json() total = pd.DataFrame(response['results']) next_url = response['links']['next'] # Loop to get all results while next_url is not None: response = requests.get(next_url, headers=headers).json() df = pd.DataFrame(response['results']) next_url = response['links']['next'] total = pd.concat([total,df])