openapi: 3.0.3
servers:
  - url: https://prod.api.market/api/v1/connectearth/connect
info:
  title: Pollution Calculator API
  description: API to calculate pollution for different modes of transport and transactions.
  version: 1.0.0
paths:
  /flight:
    post:
      tags:
        - Flights API
      summary: Calculate flight emissions
      description: Calculates the emissions for a flight based on the origin,
        destination, and number of passengers.
      requestBody:
        description: Flight details for emissions calculation
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                origin:
                  type: string
                  example: LAX
                destination:
                  type: string
                  example: DFW
                numberOfPassengers:
                  type: integer
                  example: 2
              required:
                - origin
                - destination
                - numberOfPassengers
      responses:
        "200":
          description: Successful response with calculated emissions
          content:
            application/json:
              schema:
                type: object
                properties:
                  distance_km:
                    type: number
                    format: float
                    example: 4166.35
                  emissions_kg_co2e:
                    type: number
                    format: float
                    example: 765.02
        "400":
          description: Bad request, possibly due to invalid input parameters
        "500":
          description: Internal server error
    parameters:
      - &a1
        description: API.market API Key
        in: header
        name: x-api-market-key
        value: Please Login/Signup to get an API Key
        required: true
        schema:
          type: string
  /transaction:
    post:
      tags:
        - Connect CO2
      summary: Calculate emissions for transactions
      description: Calculates the emissions for a transaction based on various parameters.
      requestBody:
        description: Transaction details for emissions calculation
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                currencyISO:
                  type: string
                  example: USD
                categoryType:
                  type: string
                  example: mcc
                categoryValue:
                  type: string
                  example: "5411"
                description:
                  type: string
                  example: TESCO 12345
                merchant:
                  type: string
                  example: Tesco
                price:
                  type: number
                  format: float
                  example: 20.22
                transactionId:
                  type: string
                  example: 12356_id
                transactionDate:
                  type: string
                  format: date
                  example: 2022-03-02
                userType:
                  type: string
                  example: PERSONAL
                geo:
                  type: string
                  example: US
                group:
                  type: string
                  example: Food
              required:
                - currencyISO
                - categoryType
                - categoryValue
                - description
                - merchant
                - price
                - transactionId
                - transactionDate
                - userType
                - geo
                - group
      responses:
        "200":
          description: Successful response with calculated emissions for the transaction
          content:
            application/json:
              schema:
                type: object
                properties:
                  transactionId:
                    type: string
                    example: 12356_id
                  transactionDate:
                    type: string
                    format: date
                    example: 2022-03-02
                  emissions_level:
                    type: string
                    example: category
                  name:
                    type: string
                    example: Grocery Stores and Supermarkets
                  kg_of_CO2e_emissions:
                    type: number
                    format: float
                    example: 8.44
                  mt_of_CO2e_emissions:
                    type: number
                    format: float
                    example: 0.0084
                  similar_to:
                    type: array
                    items:
                      type: string
                    example:
                      - This is equivalent to the emissions from using 4 litres
                        of petrol to fuel your car.
                      - This is equivalent to the emissions from running a
                        propane bbq for 5 hours.
                      - This is equivalent to the emissions from burning 3 kgs
                        of coal.
                  factor_version:
                    type: string
                    example: v1_1
                  disclaimer:
                    type: string
      security:
        - ApiKeyAuth: []
    parameters:
      - *a1
components:
  securitySchemes: {}
security: {}
tags:
  - name: Flights API
    description: Endpoints related to flight emissions calculations
  - name: Connect CO2
    description: Endpoints related to calculating emissions for transactions
  - name: carbon-sustainability
    description: Operations related to carbon-sustainability
  - name: business-intelligence
    description: Operations related to business-intelligence
  - name: company-data
    description: Operations related to company-data
