thegreenwebfoundation / grid-intensity

A simple API to build awareness of carbon intensity into javascript programs
Apache License 2.0
11 stars 3 forks source link

Use Electricity Map Free API: co2signal.com #1

Open Jolg42 opened 4 years ago

Jolg42 commented 4 years ago

Hi Chris!

It looks like it's really easy to get a token, signup on http://www.co2signal.com/ then confirm and you should get a token a minute after.

Docs are here: https://docs.co2signal.com/

Big limitation is The API has a rate limit of 30 requests per hour. (I can share my API key with you if needed)

So the carbon intensity can be either queried by lat & lon or country code:

Example from https://api.co2signal.com/v1/latest?countryCode=DE (the auth-token hedader must be set)

{
    "_disclaimer": "This data is the exclusive property of Tomorrow and/or related parties. If you're in doubt about your rights to use this data, please contact hello@tmrow.com",
    "status": "ok",
    "countryCode": "DE",
    "data": {
        "carbonIntensity": 389.48884558290564,
        "fossilFuelPercentage": 51.749247934801886
    },
    "units": {
        "carbonIntensity": "gCO2eq/kWh"
    }
}
Jolg42 commented 4 years ago

I guess we would need to define what is "low", "moderate", "high":

From https://carbon-intensity.github.io/api-definitions/#intensity-1

The index is a measure of the Carbon Intensity represented on a scale between 'very low', 'low', 'moderate', 'high', 'very high'.

It's poorly documented, only thing I could find is in this PDF https://raw.githubusercontent.com/carbon-intensity/methodology/master/Carbon%20Intensity%20Forecast%20Methodology.pdf found on https://carbonintensity.org.uk/

Screenshot 2020-09-20 at 21 43 42
mrchrisadams commented 4 years ago

Hmm…

The figures for 'low' to 'high' are likely to change for each country, simple because they have such different fuel mixes and the mixes change over time too.

You could do it with percentile approaches for each country, as right now, my understanding is that serverside more of an ask to move a job through space, than it is to move it through time.

If you're using a browser, the bulk of the emissions from transmission will be at the last few hops (especially if on mobile), and as an end user, you don't have so much control where in the world you consume it from.

So again, moving the work through time with something like web workers or applying local-first design principles would be a thing you can plausibly design for.

I think the simplest option is to have 3 options for now, for compatibility, and make some conversion using the 2019 figures.

Once we have that, it's simple to sanity check them with the Electricity Map gang.

mrchrisadams commented 4 years ago

For implementation, I had the idea of a pluggable adapter style approach in mind.

So you might have a UK Grid intensity adapter, say… a CO2 Signal adapter and so on.

mrchrisadams commented 3 years ago

hey @Jolg42 seen this on one of the other TGWF repos?

Danilo Velasquez, has been working on a similar project, an he shared this gem with me:

I've spoke to them (Tmrow.com) and they told me that I could use the data for Open Source projects. The data they are showing is real time, so he suggest me to get the data every hour and make a daily average (since they don't have any type of averages).

I've been doing that since then here: https://github.com/dvelasquez/electricity-data
I also have this small library with the data of 1 day: https://github.com/dvelasquez/carbon-tools/tree/main/packages/co2-data

https://github.com/thegreenwebfoundation/co2.js/issues/2#issuecomment-719330799

This could give us a cacheable figure, even if we aren't using the day-ahead figures to project batch compute jobs into the greener near future , when there are more renewables on the grid.