Emissions Calculation

These apps are used to calculate emissions of a trip by plane, train, car or bus, given a cabin class, the distance, the origin IATA code and the destination IATA code.

When is Troop calling my endpoint?

Troop will query your endpoint during a meeting analysis, after fetching the transport options from one of our providers. For performance reasons, your endpoint needs to accept segments in bulk, to minimize the number of HTTP calls required.

JSON Payload

The JSON payload must accept the following fields:

FieldDescriptionRequiredTypeExample

mode

The transport mode.

true

One of AIRCRAFT, TRAIN, BUS or CAR

AIRCRAFT

segments

The segments of the trip.

true

An array of RequestedSegment

See below

methodologyRequested

The methodology used to calculate the emissions.

true

String

defra

Type of RequestedSegment:

FieldDescriptionRequiredTypeExample

origin

The origin IATA code.

true

String

PAR

destination

The destination IATA code.

true

String

MAD

distance

The distance of the segment.

true

Float

4325

cabinClass

The cabin class.

true

One of BUSINESS, ECONOMY, FIRST or PREMIUM_ECONOMY

ECONOMY

flgithNumber

The flight number.

true

String

IB2233

Example:

{
  "mode": "AIRCRAFT",
  "methodologyRequested": "defra",
  "segments": [
    {
      "origin": "MAD",
      "destination": "CDG",
      "distance": 2345,
      "cabinClass": "ECONOMY",
      "flightNumber": "IB2233"
    },
    {
      "origin": "MAD",
      "destination": "LHT",
      "distance": 1755,
      "cabinClass": "BUSINESS",
      "flightNumber": "IB3488"
    }
  ]
}

JSON Response

The response payload must be similar to the following. I'ts very important that the output objects inside result.data are ordered the same way as the input objects.

The JSON response must contain an attribute data which consists of an array of ResponseSegment:

Type of ResponseSegment:

FieldDescriptionRequiredTypeExample

origin

The origin IATA code.

true

String

PAR

destination

The destination IATA code.

true

String

MAD

distance

The distance of the segment.

true

Float

4325

cabinClass

The cabin class.

true

One of BUSINESS, ECONOMY, FIRST or PREMIUM_ECONOMY

ECONOMY

flgithNumber

The flight number.

true

String

IB2233

emissions

The tonnes of CO2 emitted.

true

Float

249.5

equivalencies

The equivalencies of the calculated emissions.

true (although it can be empty)

An array of EmissionsEquivalency.

See below

Type of EmissionsEquivalency:

FieldDescriptionRequiredTypeExample

type

The type.

true

String

plastic-bag, tree, video-call, etc

unit

The unit.

true

String

plastic bags, trees, video calls, etc

amount

The equivalent amount of unit.

true

Integer

13

values

Human-readable description of the above.

true

String[]

This is the carbon absorbed by 13 trees in 1 year.

{
    "result": {
        "statusCode": 200,
        "data": [
            {
                "origin": "MAD",
                "destination": "CDG",
                "distance": 2345,
                "cabinClass": "ECONOMY",
                "flightNumber": "IB2233",
                "emissions": 249.5,
                "equivalencies": [
                    {
                        "type": "tree",
                        "unit": "trees",
                        "amount": 13,
                        "values": [
                            "This is the carbon absorbed by 13 trees in 1 year."
                        ]
                    }
                ]
            },
            {
                "origin": "MAD",
                "destination": "LHT",
                "distance": 1755,
                "cabinClass": "BUSINESS",
                "flightNumber": "IB3488",
                "emissions": 277.7777777,
                "equivalencies": [
                    {
                        "type": "tree",
                        "unit": "trees",
                        "amount": 14,
                        "values": [
                            "This is the carbon absorbed by 14 trees in 1 year."
                        ]
                    }
                ]
            }
        ]
    }
}

Last updated