> Annual Internet Energy / Annual End User Traffic = 0.81 kWh/GB
> Carbon factor (global grid): 442 g/kWh
Probably just checking how many bytes the response is. While that's a good idea to remove unused data from your response, this test may promote wrong patterns such as spreading data over multiple request/response. This would consume more energy but won't be visible with a naive CO2 computation.
Raising awareness on such topic and providing visibility to devs is a good thing. Unfortunately, numbers may be off by multiple orders of magnitude. It's really hard to get any meaningful CO2 number for a single API call. I'd suspect API burn much more CO2/byte than streaming.
Streaming is dumb, cacheable near end-users and heavy in bandwidth. API uses little bandwidth but often requires calls to multiple remote backend systems heavy in CPU, including subrequests to databases and other stuff. When you mix all usage and get an average KPI, it's no longer representative.
Its’s neither obvious from your post nor your GitHub landing page, which is a shame.
The other question I would have is: who is the target audience, and why are API calls specifically so important?