You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+55-4Lines changed: 55 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,8 @@
4
4
5
5
Its main purpose is the integration into the Green Metrics Tool (GMT) to provide dynamic carbon intensity values.
6
6
7
+

8
+
7
9
## Installation
8
10
9
11
```bash
@@ -25,11 +27,13 @@ Before running Elephant, you need to configure your data providers:
25
27
```bash
26
28
# Copy the example configuration
27
29
cp config.example.yml config.yml
28
-
29
-
# Edit config.yml and add your API tokens
30
-
# For ElectricityMaps: Replace "your-electricitymaps-api-token-here" with your actual token
31
30
```
32
31
32
+
Edit config.yml and add your API tokens
33
+
34
+
For ElectricityMaps: Replace "your-electricitymaps-api-token-here" with your actual token. You don't need to modify anything to start collection. We use free endpoints per default.
35
+
36
+
33
37
## Running
34
38
35
39
You should just be able to do
@@ -49,7 +53,7 @@ You should be able to
49
53
50
54
```
51
55
pip install -r requirements-dev.txt
52
-
pylint elephant/**.py
56
+
pylint pylint --recursive=y elephant/
53
57
pytest tests
54
58
```
55
59
@@ -66,3 +70,50 @@ python3 -m elephant.database
66
70
python3 -m elephant.cron
67
71
python3 -m elephant --host 0.0.0.0 --port 8000
68
72
```
73
+
74
+
## API
75
+
76
+
Once Elephant is running (for example with `docker compose up --build`), the generated docs are available at:
77
+
78
+
- Swagger UI: `http://localhost:8000/docs`
79
+
- ReDoc: `http://localhost:8000/redoc`
80
+
81
+
### Core endpoints
82
+
83
+
-`GET /carbon-intensity/current` — Latest carbon intensities for a region. Query params: `region` (ISO 3166-1 alpha-2), optional `update` (force refresh) and `simulation_id` (serve simulated data).
84
+
-`GET /carbon-intensity/current/primary` — Latest carbon intensity from the configured primary provider for `region`; also accepts `update` and `simulation_id`.
85
+
-`GET /carbon-intensity/history` — Historical values between `startTime` and `endTime` (ISO 8601) for `region`.
86
+
-`GET /regions` — List of regions with stored data.
87
+
-`GET /health` — Service health, providers, DB record count, and regions.
88
+
89
+
### Simulation endpoints
90
+
91
+
Elephant includes a lightweight simulator so you can drive client integrations or demos without live provider data.
92
+
93
+
-`POST /simulation` with a JSON body `{"carbon_values": [120, [140, 2], [100, null]]}` registers a run and returns a `simulation_id`. Each entry is either a float or a `[value, calls]` pair; `calls` is how often that value is returned before automatically advancing (use `null` to disable auto-advance).
94
+
-`GET /simulation/get_carbon?simulation_id=...` returns the current simulated carbon intensity and will auto-advance when call thresholds are met.
95
+
-`POST /simulation/next?simulation_id=...` forces the next value.
96
+
-`GET /simulation/stats?simulation_id=...` shows the current index and call history for debugging.
97
+
98
+
You can plug a simulation into the core responses by passing `simulation_id`:
0 commit comments