Tutorial to Get Started with Rebase API
Get started with Rebase API in a few simple steps:
Create a new site
Explore different site options.
Upload generation data
See also how to upload capacity changes.
Train ML model
See what training settings are available.
Query forecasts
Find out how to query historical forecasts.
Step 1. Create a new site
Create a solar site to forecast. You will need to provide some site parameters like location, capacity, etc. More information about the parameters for every type of site are provided in the site set-up guides and in the API Reference.
import requests
api_key = "Your API key" # Set your API key
payload = {
"type": "solar",
"name": "New solar site",
"latitude": 52.5,
"longitude": 13.4,
"settings": {
"model_resolution": "1h",
"usePhysicalModels": True,
"trainNearTermModels": False,
"trainLongTermModels": False
},
"assets": [
{
"azimuth": 180,
"tilt": 30,
"capacity": 1000,
"install_date": "2024-01-01"
}
]
}
url = "https://api.rebase.energy/platform/v2/sites"
headers = {"Authorization": api_key, "Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
response.raise_for_status()
response = response.json()
As response you get the ID of the newly created site.
{
"site_id": "a923653c-26f1-1b29-955d-ffde5d182276"
}
Step 2. Upload generation data
To train an ML model you need to upload measured power generation data from the site. A good practice for better performance of the ML model is that the data cover a period of one year at least with hourly or more frequent resolution.
site_id = "a923653c-26f1-1b29-955d-ffde5d182276" # This is the ID of the new site
payload = {"data": [
{
"valid_time": "2024-01-01T12:00:00Z",
"value": 300.5
},
{
"valid_time": "2024-01-01T13:00:00Z",
"value": 320.2
}
]
}
url = f"https://api.rebase.energy/platform/v2/sites/{site_id}/actual"
response = requests.post(url, json=payload, headers=headers)
response.raise_for_status()
response = response.json()
When the upload is successful you get an OK response.
{
"message": "Ok"
}
Step 3. Train ML model
url = "https://api.rebase.energy/platform/v2/sites/models/train"
payload = {
"site_ids": ["a923653c-26f1-1b29-955d-ffde5d182276"],
"output_backtest_data": True,
"splits": [
{
"end_date": "2023-08-01T00:00Z",
"start_date": "2023-01-01T00:00Z"
},
{
"end_date": "2024-01-01T00:00Z",
"start_date": "2023-10-01T00:00Z"
}
]
}
response = requests.post(url, json=payload, headers=headers)
response.raise_for_status()
response = response.json()
Step 4. Query forecast
Query the latest available forecast.
url = f"https://api.rebase.energy/platform/v2/sites/{site_id}/forecast"
response = requests.get(url, headers=headers)
response.raise_for_status()
response = response.json()
The response is a serialized table with the following columns:
valid_time
: It contains the target times, i.e. the periods which are forecasted.
forecast
: It contains the forecast values.
model_name
: It contains the names of the models which create the forecasts.
model_version
: It contains the versions of the models which create the forecasts.
update_time
: It contains the issue/update time, i.e. the time when the forecasts were updated.
{
"valid_time": [
"2024-01-01T00:00:00Z",
"2024-01-01T01:00:00Z",
"2024-01-01T02:00:00Z",
"2024-01-01T03:00:00Z",
"2024-01-01T04:00:00Z",
"2024-01-01T05:00:00Z",
"2024-01-01T06:00:00Z",
"2024-01-01T07:00:00Z",
"2024-01-01T08:00:00Z",
"2024-01-01T09:00:00Z"
],
"forecast": [
6000,
6000,
6000,
6000,
6000,
6000,
6000,
6000,
6000,
6000
],
"model_name": [
"My model",
"My model",
"My model",
"My model",
"My model",
"My model",
"My model",
"My model",
"My model",
"My model"
],
"model_version": [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
],
"update_time": [
"2024-01-01T00:00:00Z",
"2024-01-01T00:00:00Z",
"2024-01-01T00:00:00Z",
"2024-01-01T00:00:00Z",
"2024-01-01T00:00:00Z",
"2024-01-01T00:00:00Z",
"2024-01-01T00:00:00Z",
"2024-01-01T00:00:00Z",
"2024-01-01T00:00:00Z",
"2024-01-01T00:00:00Z"
]
}