ninjaclient package

Submodules

ninjaclient.ninja_client module

class ninjaclient.ninja_client.NinjaClient(web_token: str | None)

Bases: object

A client for querying data from the Renewables Ninja API.

Parameters:

web_token (str) – A valid API token for authenticating requests.

The client handles querying wind and solar data, managing API rate limits, and parsing the responses into pandas DataFrames.

BASE_URI = 'https://www.renewables.ninja/api/'
COUNTRIES_URI = 'https://www.renewables.ninja/api/countries'
LIMITS_URI = 'https://www.renewables.ninja/api/limits'
PV_URI = 'https://www.renewables.ninja/api/data/pv'
WIND_URI = 'https://www.renewables.ninja/api/data/wind'
get_countries() DataFrame

Retrieves a list of countries available in the Renewables Ninja API.

Returns:

A pandas DataFrame containing the list of countries.

Return type:

pandas.DataFrame

get_limits() dict

Fetches the current API usage limits.

Returns:

A dictionary containing the API’s burst and sustained limits.

Return type:

dict

get_solar_dataframe(lat: float, lon: float, date_from, date_to, dataset='merra2', capacity: float = 1.0, system_loss: float = 0.1, tracking=0, tilt=35, azim=180, interpolate=False)

Retrieves solar data for a specified location and time period.

Parameters:
  • lat (float) – Latitude of the location.

  • lon (float) – Longitude of the location.

  • date_from (str) – Start date for the data retrieval (YYYY-MM-DD).

  • date_to (str) – End date for the data retrieval (YYYY-MM-DD).

  • dataset (str, optional) – The dataset to use. Default is “merra2”.

  • capacity (float, optional) – Installed capacity in kW. Default is 1.0.

  • system_loss (float, optional) – System losses in percentage. Default is 0.1.

  • tracking (int, optional) – Tracking type (0 for fixed, 1 for single-axis). Default is 0.

  • tilt (int, optional) – Tilt angle of the solar panel. Default is 35.

  • azim (int, optional) – Azimuth angle of the solar panel. Default is 180.

  • interpolate (bool, optional) – Whether to interpolate the data. Default is False.

Returns:

A tuple containing a pandas DataFrame of the solar data and a list of metadata for each query.

Return type:

tuple

get_wind_dataframe(lat, lon, date_from, date_to, dataset='merra2', capacity=1.0, height=100, turbine='Vestas V80 2000', interpolate=False)

Retrieves wind data for a specified location and time period.

Parameters:
  • lat (float) – Latitude of the location.

  • lon (float) – Longitude of the location.

  • date_from (str) – Start date for the data retrieval (YYYY-MM-DD).

  • date_to (str) – End date for the data retrieval (YYYY-MM-DD).

  • dataset (str, optional) – The dataset to use. Default is “merra2”.

  • capacity (float, optional) – Installed capacity in kW. Default is 1.0.

  • height (int, optional) – Hub height of the turbine in meters. Default is 100.

  • turbine (str, optional) – Model of the wind turbine. Default is “Vestas V80 2000”.

  • interpolate (bool, optional) – Whether to interpolate the data. Default is False.

Returns:

A tuple containing a pandas DataFrame of the wind data and a list of metadata for each query.

Return type:

tuple

wait_for_burst() None

Waits until the next burst of requests is allowed, based on the last query time and burst limit.

Module contents