CodeCarbon Emissions API

The Emissions API from CodeCarbon — 3 operation(s) for emissions.

GitHub OpenAPI

Operations 3

POST /emissions Add Emission #
GET /emissions/{emission_id} Read Emission #
GET /runs/{run_id}/emissions Get Emissions From Run #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/codecarbon:codecarbon-emissions-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

codecarbon-emissions-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Codecarbon Emissions API
  version: 0.1.0
  x-refined-note:
  - x-original-title differs across the merged source definitions and was not carried
  description: 'Operations tagged Emissions across 2 of this provider''s published API definitions: codecarbon-openapi.json, codecarbon-openapi.yml. Each path carries the servers of the definition it was published in.'
servers:
- url: /api/
- url: https://api.codecarbon.io/api
  description: Resolved from the relative server /api/ as served at https://api.codecarbon.io/openapi.json
tags:
- name: Emissions
paths:
  /emissions:
    post:
      tags:
      - Emissions
      summary: Add Emission
      operationId: add_emission_emissions_post
      parameters:
      - name: x-api-token
        in: header
        required: false
        schema:
          type: string
          title: X-Api-Token
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EmissionCreate'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                type: string
                format: uuid
                title: Response Add Emission Emissions Post
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
    servers:
    - url: /api/
  /emissions/{emission_id}:
    get:
      tags:
      - Emissions
      summary: Read Emission
      operationId: read_emission_emissions__emission_id__get
      security:
      - APIKeyCookie: []
      - HTTPBearer: []
      parameters:
      - name: emission_id
        in: path
        required: true
        schema:
          type: string
          title: Emission Id
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Emission'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
    servers:
    - url: /api/
  /runs/{run_id}/emissions:
    get:
      tags:
      - Emissions
      summary: Get Emissions From Run
      operationId: get_emissions_from_run_runs__run_id__emissions_get
      security:
      - APIKeyCookie: []
      - HTTPBearer: []
      parameters:
      - name: run_id
        in: path
        required: true
        schema:
          type: string
          title: Run Id
      - name: page
        in: query
        required: false
        schema:
          type: integer
          minimum: 1
          default: 1
          title: Page
      - name: size
        in: query
        required: false
        schema:
          type: integer
          maximum: 10000
          minimum: 1
          default: 100
          title: Size
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Page_Emission_'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
    servers:
    - url: /api/
components:
  schemas:
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
            - type: string
            - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
      - loc
      - msg
      - type
      title: ValidationError
    EmissionCreate:
      properties:
        timestamp:
          type: string
          format: date-time
          title: Timestamp
        run_id:
          type: string
          format: uuid
          title: Run Id
        duration:
          type: number
          exclusiveMinimum: 0.0
          title: Duration
          description: The duration must be greater than zero
        emissions_sum:
          anyOf:
          - type: number
            minimum: 0.0
          - type: 'null'
          title: Emissions Sum
          description: The emissions must be greater than zero
        emissions_rate:
          anyOf:
          - type: number
            minimum: 0.0
          - type: 'null'
          title: Emissions Rate
          description: The emissions rate must be greater than zero
        energy_consumed:
          anyOf:
          - type: number
            minimum: 0.0
          - type: 'null'
          title: Energy Consumed
          description: The energy_consumed must be greater than zero
        cpu_power:
          anyOf:
          - type: number
            minimum: 0.0
          - type: 'null'
          title: Cpu Power
          description: The cpu_power must be greater than zero
        gpu_power:
          anyOf:
          - type: number
            minimum: 0.0
          - type: 'null'
          title: Gpu Power
          description: The gpu_power must be greater than zero
        ram_power:
          anyOf:
          - type: number
            minimum: 0.0
          - type: 'null'
          title: Ram Power
          description: The ram_power must be greater than zero
        cpu_energy:
          anyOf:
          - type: number
            minimum: 0.0
          - type: 'null'
          title: Cpu Energy
          description: The cpu_energy must be greater than zero
        gpu_energy:
          anyOf:
          - type: number
            minimum: 0.0
          - type: 'null'
          title: Gpu Energy
          description: The gpu_energy must be greater than zero
        ram_energy:
          anyOf:
          - type: number
            minimum: 0.0
          - type: 'null'
          title: Ram Energy
          description: The ram_energy must be greater than zero
        cpu_utilization_percent:
          anyOf:
          - type: number
            maximum: 100.0
            minimum: 0.0
          - type: 'null'
          title: Cpu Utilization Percent
          description: The CPU utilization must be between 0 and 100
        gpu_utilization_percent:
          anyOf:
          - type: number
            maximum: 100.0
            minimum: 0.0
          - type: 'null'
          title: Gpu Utilization Percent
          description: The GPU utilization must be between 0 and 100
        ram_utilization_percent:
          anyOf:
          - type: number
            maximum: 100.0
            minimum: 0.0
          - type: 'null'
          title: Ram Utilization Percent
          description: The RAM utilization must be between 0 and 100
        wue:
          anyOf:
          - type: number
            minimum: 0.0
          - type: 'null'
          title: Wue
          description: The WUE (Water Usage Effectiveness) must be greater than or equal to zero
          default: 0
      type: object
      required:
      - timestamp
      - run_id
      - duration
      - emissions_sum
      - emissions_rate
      - energy_consumed
      - cpu_power
      - gpu_power
      - ram_power
      - cpu_energy
      - gpu_energy
      - ram_energy
      title: EmissionCreate
      example:
        cpu_energy: 55.21874
        cpu_power: 0.3
        duration: 98745
        emissions_rate: 1.548444
        emissions_sum: 1544.54
        energy_consumed: 57.21874
        gpu_energy: 0.0
        gpu_power: 0.0
        ram_energy: 2.0
        ram_power: 0.15
        run_id: 40088f1a-d28e-4980-8d80-bf5600056a14
        timestamp: '2021-04-04T08:43:00+02:00'
        wue: 0
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    Page_Emission_:
      properties:
        items:
          items:
            $ref: '#/components/schemas/Emission'
          type: array
          title: Items
        total:
          type: integer
          minimum: 0.0
          title: Total
        page:
          type: integer
          minimum: 1.0
          title: Page
        size:
          type: integer
          minimum: 1.0
          title: Size
        pages:
          type: integer
          minimum: 0.0
          title: Pages
      type: object
      required:
      - items
      - total
      - page
      - size
      - pages
      title: Page[Emission]
    Emission:
      properties:
        timestamp:
          type: string
          format: date-time
          title: Timestamp
        run_id:
          type: string
          format: uuid
          title: Run Id
        duration:
          type: number
          exclusiveMinimum: 0.0
          title: Duration
          description: The duration must be greater than zero
        emissions_sum:
          anyOf:
          - type: number
            minimum: 0.0
          - type: 'null'
          title: Emissions Sum
          description: The emissions must be greater than zero
        emissions_rate:
          anyOf:
          - type: number
            minimum: 0.0
          - type: 'null'
          title: Emissions Rate
          description: The emissions rate must be greater than zero
        energy_consumed:
          anyOf:
          - type: number
            minimum: 0.0
          - type: 'null'
          title: Energy Consumed
          description: The energy_consumed must be greater than zero
        cpu_power:
          anyOf:
          - type: number
            minimum: 0.0
          - type: 'null'
          title: Cpu Power
          description: The cpu_power must be greater than zero
        gpu_power:
          anyOf:
          - type: number
            minimum: 0.0
          - type: 'null'
          title: Gpu Power
          description: The gpu_power must be greater than zero
        ram_power:
          anyOf:
          - type: number
            minimum: 0.0
          - type: 'null'
          title: Ram Power
          description: The ram_power must be greater than zero
        cpu_energy:
          anyOf:
          - type: number
            minimum: 0.0
          - type: 'null'
          title: Cpu Energy
          description: The cpu_energy must be greater than zero
        gpu_energy:
          anyOf:
          - type: number
            minimum: 0.0
          - type: 'null'
          title: Gpu Energy
          description: The gpu_energy must be greater than zero
        ram_energy:
          anyOf:
          - type: number
            minimum: 0.0
          - type: 'null'
          title: Ram Energy
          description: The ram_energy must be greater than zero
        cpu_utilization_percent:
          anyOf:
          - type: number
            maximum: 100.0
            minimum: 0.0
          - type: 'null'
          title: Cpu Utilization Percent
          description: The CPU utilization must be between 0 and 100
        gpu_utilization_percent:
          anyOf:
          - type: number
            maximum: 100.0
            minimum: 0.0
          - type: 'null'
          title: Gpu Utilization Percent
          description: The GPU utilization must be between 0 and 100
        ram_utilization_percent:
          anyOf:
          - type: number
            maximum: 100.0
            minimum: 0.0
          - type: 'null'
          title: Ram Utilization Percent
          description: The RAM utilization must be between 0 and 100
        wue:
          anyOf:
          - type: number
            minimum: 0.0
          - type: 'null'
          title: Wue
          description: The WUE (Water Usage Effectiveness) must be greater than or equal to zero
          default: 0
        id:
          type: string
          format: uuid
          title: Id
      type: object
      required:
      - timestamp
      - run_id
      - duration
      - emissions_sum
      - emissions_rate
      - energy_consumed
      - cpu_power
      - gpu_power
      - ram_power
      - cpu_energy
      - gpu_energy
      - ram_energy
      - id
      title: Emission
      example:
        cpu_energy: 55.21874
        cpu_power: 0.3
        duration: 98745
        emissions_rate: 1.548444
        emissions_sum: 1544.54
        energy_consumed: 57.21874
        gpu_energy: 0.0
        gpu_power: 0.0
        ram_energy: 2.0
        ram_power: 0.15
        run_id: 40088f1a-d28e-4980-8d80-bf5600056a14
        timestamp: '2021-04-04T08:43:00+02:00'
        wue: 0
  securitySchemes:
    APIKeyCookie:
      type: apiKey
      in: cookie
      name: user_session
    HTTPBearer:
      type: http
      scheme: bearer
x-refined-from:
- codecarbon-openapi.json
- codecarbon-openapi.yml