Renovus-Tech / solarec-python

GNU Affero General Public License v3.0
0 stars 0 forks source link

Add endpoints for exposing CO2 avoided data, certificates and sales #17

Closed fcggamou closed 7 months ago

fcggamou commented 7 months ago

New endpoints:

Certificates

Endpoint /solar/certificates

Example request

{
    "from": "2024-01-15",
    "to": "2024-04-17",
    "location": 1,
    "client": 1,
    "groupBy": "week"
}

Example response

{
  "chart": {
    "from": "2024/01/15 00:00:00",
    "to": "2024/04/17 23:59:59",
    "resultCode": 200,
    "resultText": "",
    "groupBy": "week"
  },
  "data": [
    {
      "from": "2024/01/15 00:00:00",
      "to": "2024/01/21 23:59:59",
      "co2Avoided": 0,
      "certGenerated": 1.112,
      "certSold": 0.556
    }
  ]
}

Emissions

Endpoint /solar/emissions

Example request

{
    "from": "2024-01-15",
    "to": "2024-04-17",
    "location": 1,
    "client": 1,
    "groupBy": "week"
}

Example response

{
  "chart": {
    "from": "2024/04/07 00:00:00",
    "to": "2024/04/17 23:59:59",
    "resultCode": 200,
    "resultText": "",
    "groupBy": "week"
  },
  "data": [
    {
      "from": "2024/04/07 00:00:00",
      "to": "2024/04/14 23:59:59",
      "co2Avoided": 0,
      "co2PerKwh": 0
    },
    {
      "from": "2024/04/08 00:00:00",
      "to": "2024/04/14 23:59:59",
      "co2Avoided": 0.14427,
      "co2PerKwh": 0.094
    },
    {
      "from": "2024/04/15 00:00:00",
      "to": "2024/04/17 23:59:59",
      "co2Avoided": 0.02159,
      "co2PerKwh": 0.044
    }
  ]
}

Sales

Endpoint /solar/sales

Example request

{
    "from": "2024-01-15",
    "to": "2024-04-17",
    "location": 1,
    "client": 1,
    "groupBy": "week"
}

Example response

{
  "chart": {
    "from": "2024/04/15 00:00:00",
    "to": "2024/04/17 23:59:59",
    "resultCode": 200,
    "resultText": "",
    "groupBy": "week"
  },
  "data": [
    {
      "from": "2024/04/15 00:00:00",
      "to": "2024/04/17 23:59:59",
      "co2Avoided": 0.02159,
      "certGenerated": 0.491,
      "certPrice": 9.815,
      "certSold": 0.245,
      "certIncome": 4.908
    }
  ]
}