Asynchronous Core API#
Like the synchronous API Usage section, this section demonstrates how to use the asynchronous version of the DataSignals API. The asynchronous DataSignals API is useful for handling multiple requests concurrently, which can significantly speed up data retrieval processes, especially when dealing with large datasets or multiple concurrent requests.
Importing the AsyncAPI class#
# %%
# Package Imports
from api_24sea.datasignals.core import AsyncAPI
# %%
# **Authentication**
api = AsyncAPI()
#
# The rest of the code is the same as in the synchronous example
# %%
Checking the available metrics#
# %%
# **Metrics Overview**
# The metrics overview is a summary of the metrics available in the API and
# can be accessed from a hidden method in the DataSignals class.
await api.get_metrics_overview()
# It will show all the available metrics with the corresponding units
# and the time window for which the user is allowed to get Data
Getting sample data from the API#
# **Data Retrieval**
sites = ["wf"]
locations = ["a01", "a02"]
metrics = ["mean WinDSpEed", "mean pitch", "mean-Yaw", "mean_power"]
start_timestamp = "2020-03-01T00:00:00Z"
end_timestamp = "2020-06-01T00:00:00Z"
data = await api.get_data(sites, locations, metrics,
start_timestamp, end_timestamp)
print(data)
# You can use all the same options as the synchronous API,
# e.g. as_dict, as_star_schema, etc.