Get nearest DAHITI target
DAHITI-API arguments
Argument | Value | Description |
username | e.g. 'username' | Username to login on the DAHITI website |
password | e.g. 'password' | Password to login on the DAHITI website |
action | 'get-nearest-target' | Action of the request |
longitude | e.g. '11.0' | Longitude |
latitude | e.g. '46.0' | Latitude |
JSON response from DAHITI server
{
'id': 10148,
'distance': 57.7755,
'latitude': 45.5497,
'longitude': 10.63
}
import requests
import json
import pprint
url = 'https://dahiti.dgfi.tum.de/api/v1/'
args = {}
""" required options """
args['username'] = 'username'
args['password'] = 'password'
args['action'] = 'get-nearest-target'
args['longitude'] = 11.0
args['latitude'] = 46.0
""" optional """
args['mission'] = 'jason2_hf'
""" send request as method POST """
response = requests.post(url, data=args)
if response.status_code == 200:
""" convert json string in python list """
data = json.loads(response.text)
pprint.pprint(data)
else:
print response.status_code