The Administration Service offers a usage feature making it possible to follow the API usage per month.
Administration have the following endpoints:
A description of the input parameters, example input, HTTP return codes and response are available in Swagger GET /administration/usage
For further explanation of the fields see the Models section of the Swagger documentation.
The ‘text’ field from Usage output contains the following strings:
The ‘endpoint’ field from usage output contains the following strings:
Please note:
import json import requests request_data = {"user_id": "username", "password": "passWORD1234##"} data_json = json.dumps(request_data) response_auth = requests.post( "https://api-demo.oceanio.com/authentication/login", headers={ "content-type": "application/json", "X-Api-Key": "LVQEGHrM0P5CceeUbGWSO5gX0kZlOG877Kr.....", }, data=data_json, ) result = json.loads(response_auth.content) response = requests.get( "https://api-demo.oceanio.com/administration/usage?year=2022&month=11&page=1&page_size=10", headers={ "content-type": "application/json", "X-Api-Key": "LVQEGHrM0P5CceeUbGWSO5gX0kZlOG877Kr.....", "Authorization": f"Bearer {result.get('token')}", }, ) print(json.loads(response.content))
"last_updated_datetime": "2022-11-17T13:00:25.319935+00:00", "usage": [ { "user_id": null, "usage_year": 2022, "usage_month": 11, "usage_type": "PUSH", "usage_method": null, "endpoint": "Container with data count", "status": "SUCCESS", "unit": "REQUESTS", "usage_count": 2, "text": "Bill of lading number transports' container count" }, { "user_id": null, "usage_year": 2022, "usage_month": 11, "usage_type": "PUSH", "usage_method": null, "endpoint": "Total container count", "status": "SUCCESS", "unit": "CONTAINERS", "usage_count": 3, "text": null }, { "user_id": "kib", "usage_year": 2022, "usage_month": 11, "usage_type": "REQUEST", "usage_method": "GET", "endpoint": "/api/ports/port-congestions/statistics", "status": "ERROR", "unit": "REQUESTS", "usage_count": 2, "text": null }, { "user_id": "kib", "usage_year": 2022, "usage_month": 11, "usage_type": "REQUEST", "usage_method": "POST", "endpoint": "/api/transports", "status": "SUCCESS", "unit": "REQUESTS", "usage_count": 1, "text": "Carrier booking reference transports" }, { "user_id": "kib", "usage_year": 2022, "usage_month": 11, "usage_type": "REQUEST", "usage_method": "GET", "endpoint": "/api/ports/{un_location_code}/port-congestions/statistics", "status": "SUCCESS", "unit": "REQUESTS", "usage_count": 3, "text": null }, { "user_id": "kib", "usage_year": 2022, "usage_month": 11, "usage_type": "REQUEST", "usage_method": "GET", "endpoint": "/api/ports/port-congestions", "status": "SUCCESS", "unit": "REQUESTS", "usage_count": 5, "text": null }, { "user_id": "kib", "usage_year": 2022, "usage_month": 11, "usage_type": "REQUEST", "usage_method": "POST", "endpoint": "/api/transports", "status": "SUCCESS", "unit": "REQUESTS", "usage_count": 2, "text": "Bill of lading number transports" }, { "user_id": "kib", "usage_year": 2022, "usage_month": 11, "usage_type": "REQUEST", "usage_method": "GET", "endpoint": "/api/port-intelligence/dwell", "status": "SUCCESS", "unit": "REQUESTS", "usage_count": 1, "text": null }, { "user_id": null, "usage_year": 2022, "usage_month": 11, "usage_type": "PUSH", "usage_method": null, "endpoint": "Container with data count", "status": "SUCCESS", "unit": "REQUESTS", "usage_count": 1, "text": "Equipment reference transports' container count" }, { "user_id": "kib", "usage_year": 2022, "usage_month": 11, "usage_type": "REQUEST", "usage_method": "POST", "endpoint": "/api/transports", "status": "ERROR", "unit": "REQUESTS", "usage_count": 11, "text": null } ] }
The credits endpoint provides an accumulation of the credit usage per service.
Please note:
This credit endpoint statement is only to be considered as an indicative calculation of a customer’s consumption of credits at a given time.
In case of disputes, questions etc. regarding a customer’s consumption of credits on the basis of this credit endpoint statement, invoices issued for a given period to the customer will be valid rather than this statement.
This may, for example, apply in cases where several companies belonging to the same group are settled as one and the same company, but have been created as multiple companies in the OceanIO system.
import json
import requests
request_data = {“user_id”: “USERNAME”,
“password”: “PASSWORD!123”}
data_json = json.dumps(request_data)
response_auth = requests.post(
“https://api-demo.oceanio.com/authentication/login”,
headers={
‘content-type’: “application/json”,
‘x-api-key’: “XXXXXXXXXXXXXXXXXXXX”,
‘Content-Type’: ‘application/json’
},
data=data_json)
result = json.loads(response_auth.content)
response = requests.get(
“https://api-demo.oceanio.com/administration/usage/credits?page=1&page_size=10”,
headers={
“content-type”: “application/json”,
‘X-Api-Key’: “XXXXXXXXXXXXXXXXXXXX”,
“Authorization”: f”Bearer {result.get(‘token’)}“})
print(json.loads(response.content))
{
"total_credit_used": 5.0,
"usage": [
{
"title": "port_intelligence_anchorage_and_berthing_by_ports",
"usage": 4,
"credits": 1
},
{
"title": "container_tracks",
"usage": 2,
"credits": 4
}
]
}