Getting started overview
Integrating with the GrünstromIndex API involves a series of steps designed to provide developers with access to data on green energy availability and forecasts. The primary objective is to enable applications to query the API for real-time or predicted green energy percentages, which can then be used for optimizing energy consumption, scheduling smart device charging, or informing carbon emission reduction strategies. The process begins with account creation, followed by API key generation, and culminates in making authenticated requests to the API endpoints.
GrünstromIndex offers a Developer Plan, which includes 5,000 requests per month and a 1-day forecast horizon, suitable for initial testing and development. Paid plans provide increased request limits and longer forecast horizons, starting with the Basic Plan at 25€ per month for 100,000 requests. The API utilizes standard HTTP GET requests and returns data in JSON format, making it compatible with most modern programming environments. Authentication is handled via API keys, which are passed in the request headers.
This guide focuses on the practical steps to get the API operational quickly, covering account setup, obtaining necessary credentials, and executing a successful initial API call. For comprehensive details on all available endpoints and data models, developers should refer to the GrünstromIndex API reference documentation.
Here's a quick reference table outlining the essential steps:
| Step | What to do | Where |
|---|---|---|
| 1. Sign up | Register for a GrünstromIndex account. | GrünstromIndex homepage |
| 2. Get API key | Generate your unique API key from the dashboard. | GrünstromIndex user dashboard |
| 3. Make request | Construct an API call with your key. | Your preferred development environment (e.g., cURL, Python) |
| 4. Parse response | Process the JSON data returned by the API. | Your application logic |
Create an account and get keys
Accessing the GrünstromIndex API requires an active account and an associated API key. This key serves as your authentication credential for all API interactions.
-
Register for an account: Navigate to the GrünstromIndex official website and locate the registration or sign-up option. You will typically need to provide an email address and create a password. Once registered, you may need to verify your email address to activate your account.
-
Log in to your dashboard: After successful registration and email verification, log in to your GrünstromIndex user dashboard. This dashboard is your central hub for managing your account, viewing usage statistics, and accessing your API keys.
-
Generate an API key: Within the dashboard, look for a section related to 'API Keys', 'Credentials', or 'Developer Settings'. Follow the instructions to generate a new API key. It is common for platforms to allow the creation of multiple keys for different projects or environments (e.g., development, staging, production). For your first request, a single key will suffice.
- Important: Treat your API key as a sensitive credential. Do not embed it directly in client-side code, commit it to public version control repositories, or share it unnecessarily. Best practices for securing API keys include using environment variables or a secure secret management system, as outlined in general API security guidelines like those provided by Google Cloud's API key security documentation.
-
Copy your API key: Once generated, copy the API key to a secure location. You will need to include this key in the header of every API request you make to GrünstromIndex.
Your first request
With your API key in hand, you can now make your first request to the GrünstromIndex API. We will demonstrate this using both cURL for a quick command-line test and Python for a programmatic example. The goal is to retrieve the current green energy index for a specific location.
The base URL for the GrünstromIndex API is typically https://api.gruenstromindex.de/v1/. For this example, we'll target the /live endpoint, which provides real-time data.
API Endpoint for Live Data: https://api.gruenstromindex.de/v1/live
This endpoint requires a geographic coordinate (latitude and longitude) to return relevant data. Let's use example coordinates for Berlin: Latitude 52.5200, Longitude 13.4050.
cURL Example
Open your terminal or command prompt and execute the following cURL command. Replace YOUR_API_KEY with the actual API key you obtained from your dashboard.
curl -X GET \
'https://api.gruenstromindex.de/v1/live?lat=52.5200&lon=13.4050' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Accept: application/json'
A successful response will return a JSON object similar to this (actual values will vary):
{
"timestamp": "2026-05-29T10:30:00Z",
"latitude": 52.5200,
"longitude": 13.4050,
"green_energy_percentage": 78.5,
"forecast_horizon_minutes": 0
}
Python Example
For Python, you can use the requests library. If you don't have it installed, you can install it via pip: pip install requests.
import requests
import os
# It's recommended to store your API key in an environment variable
API_KEY = os.getenv('GRUENSTROMINDEX_API_KEY', 'YOUR_API_KEY') # Replace 'YOUR_API_KEY' for testing, but use os.getenv in production
BASE_URL = "https://api.gruenstromindex.de/v1/"
ENDPOINT = "live"
params = {
"lat": 52.5200,
"lon": 13.4050
}
headers = {
"Authorization": f"Bearer {API_KEY}",
"Accept": "application/json"
}
response = requests.get(f"{BASE_URL}{ENDPOINT}", params=params, headers=headers)
if response.status_code == 200:
data = response.json()
print("Successfully retrieved live green energy data:")
print(data)
else:
print(f"Error: {response.status_code} - {response.text}")
Remember to set the GRUENSTROMINDEX_API_KEY environment variable or replace 'YOUR_API_KEY' directly in the script for initial testing. The Python script will output the JSON response to your console.
Common next steps
Once you've successfully made your first API call, consider these next steps to further integrate GrünstromIndex into your application:
-
Explore other endpoints: The GrünstromIndex API reference details additional endpoints beyond
/live, such as/forecastfor predictive data and/historicalfor past data analysis. Understanding the different data available can help you design more comprehensive energy management solutions. -
Implement error handling: Production applications should always include robust error handling. The API will return various HTTP status codes (e.g., 400 for bad request, 401 for unauthorized, 403 for forbidden, 429 for rate limiting, 500 for internal server error). Your application should gracefully handle these responses and provide informative feedback or retry mechanisms where appropriate.
-
Manage API key securely: Transition from hardcoding your API key to using environment variables or a dedicated secret management service. This practice enhances security and makes your application more portable. For example, AWS offers AWS Secrets Manager, and Google Cloud provides Secret Manager for secure credential storage.
-
Monitor usage: Regularly check your API usage within the GrünstromIndex dashboard to stay within your plan's limits and anticipate when an upgrade might be necessary. This helps avoid service interruptions due to exceeding request quotas.
-
Integrate into your application logic: Begin incorporating the green energy data into your application's core functionality. This could involve dynamically adjusting smart device charging schedules, informing users about optimal times for energy consumption, or contributing to carbon footprint calculations.
-
Review pricing and plans: As your application scales, evaluate the GrünstromIndex pricing plans to ensure your subscription aligns with your usage requirements and forecast needs.
Troubleshooting the first call
If your first API request doesn't return the expected data, here are common issues and troubleshooting steps:
-
401 Unauthorized: This is almost always an issue with your API key. Double-check that:
- You have copied the entire API key correctly.
- The key is included in the
Authorizationheader with theBearerprefix (e.g.,Authorization: Bearer YOUR_API_KEY). - Your API key is still active in your GrünstromIndex dashboard.
-
400 Bad Request: This indicates an issue with your request parameters.
- Verify that the
latandlonparameters are numerical and within valid ranges (latitude: -90 to +90, longitude: -180 to +180). - Ensure there are no typos in the endpoint URL or parameter names.
- Consult the API reference documentation for the specific endpoint you are calling to confirm required parameters and their formats.
- Verify that the
-
403 Forbidden: This could mean your account or API key does not have the necessary permissions for the requested resource, or your free tier limits have been reached for the specific forecast horizon. Check your plan details in the dashboard.
-
429 Too Many Requests: You have exceeded the rate limits for your current plan. Wait for a short period and try again, or consider upgrading your plan if this is a recurring issue.
-
No response or network error:
- Check your internet connection.
- Verify the base URL (
https://api.gruenstromindex.de/v1/) is spelled correctly and accessible. - Temporarily disable any VPNs or firewalls that might be blocking the request, then re-enable them carefully.
-
Incorrect JSON parsing: If you receive a successful response but cannot parse the data, ensure your code correctly handles JSON. Most programming languages have built-in or library functions (like Python's
json.loads()orresponse.json()) to parse JSON strings into native data structures. -
Refer to documentation: The most comprehensive resource for troubleshooting specific API issues is the official GrünstromIndex documentation. It often provides detailed error codes and explanations.