Documentation of DAHITI-API (Version 2) - "download-water-level"
DAHITI-API arguments
Argument Value Description
api_key ---' DAHITI API-Key
(Where can I get the API key?)
dahiti_id e.g. '8813' DAHITI ID
format e.g. 'json', 'ascii', 'netcdf' or 'csv' Output format (optional, default: 'json')
API-Request URL
https://dahiti.dgfi.tum.de/api/v2/download-water-level/
JSON response from DAHITI server
{
	'code': 200,
	'message': 'Request successful!'
	'target': {
		'id': '8813',
		'target_name': 'Tawakoni, Lake',
		'location': None,
		'country': 'United States of America',
		'continent': 'North America',
		'longitude': -95.9748,
		'latitude': 32.8696,
		'points': 259,
		'software': '8.0',
		'download': '2024-01-31 14:50:48',
	},
	'data': [
		{
			'date': '2008-07-20T00:00:00',
			'height': 133.087,
			'error': 0.009,
			'data': 'jason2_hf 219 001',
		},{
			'date': '2008-07-30T00:00:00',
			'height': 133.238,
			'error': 0.136,
			'data': 'jason2_hf 219 002',
		},
		...,
		{
			'date': '2023-12-21T00:00:00',
			'height': 133.247,
			'error': 0.0,
			'data': 'sentinel6a_LR_NTC_F08_hf 219 114',
		},{
			'date': '2023-12-31T00:00:00',
			'height': 133.464,
			'error': 0.044,
			'data': 'sentinel6a_LR_NTC_F08_hf 219 115',
		}
	]
}
API-Request Examples:

Python request using POST method:

import requests
import json
import pprint

url = "https://dahiti.dgfi.tum.de/api/v2/download-water-level/"

args = {}
args['api_key'] = '### ADD HERE API_KEY ###'
args['dahiti_id'] = 8813
args['format'] = 'json'

response = requests.post(url, json=args)

if response.status_code == 200:
	if args['format'] == "ascii":
		data_ascii = response.text
		print(data_ascii)		
	if args['format'] == "json":
		data_ascii = json.loads(response.text)
		pprint.pprint(data_ascii)
	if args['format'] == "netcdf":
		path_netcdf = "/tmp/"+str(args['dahiti_id'])+"_water_level_altimetry.nc"
		print ('writing ... '+path_netcdf)
		with open(path_netcdf, 'wb') as f:
			for chunk in response.iter_content(chunk_size=1024): 
				if chunk:
					f.write(chunk)
		print ('done!')
	if args['format'] == "csv":
		data_csv = response.text
		print(data_csv)				
else:
	print (response.text)
	print (response.status_code)				
				

Python request using GET method:

import requests
import json
import pprint

url = "https://dahiti.dgfi.tum.de/api/v2/download-water-level/"

args = {}
args['api_key'] = '### ADD HERE API_KEY ###'
args['dahiti_id'] = 8813
args['format'] = 'json'

response = requests.get(url,params=args)

if response.status_code == 200:
	if args['format'] == "ascii":
		data_ascii = response.text
		print(data_ascii)		
	if args['format'] == "json":
		data_ascii = json.loads(response.text)
		pprint.pprint(data_ascii)
	if args['format'] == "netcdf":
		path_netcdf = "/tmp/"+str(args['dahiti_id'])+"_water_level_altimetry.nc"
		print ('writing ... '+path_netcdf)
		with open(path_netcdf, 'wb') as f:
			for chunk in response.iter_content(chunk_size=1024): 
				if chunk:
					f.write(chunk)
		print ('done!')
	if args['format'] == "csv":
		data_csv = response.text
		print(data_csv)				
else:
	print (response.text)
	print (response.status_code)				
				

CURL request using POST method:

curl --data "api_key=### ADD HERE API_KEY ###&dahiti_id=8813" -X POST https://dahiti.dgfi.tum.de/api/v2/download-water-level/
			

CURL request using GET method:

curl -X GET "https://dahiti.dgfi.tum.de/api/v2/download-water-level/?api_key=### ADD HERE API_KEY ###&dahiti_id=8813"