openapi: 3.0.0 info: title: Altruistiq Datasource Export API x-logo: url: ./aq.svg altText: Altruistiq Logo version: 1.0.0 description: '# Definitions An **Activity** is a business process that has taken place, which is relevant for emissions measurement. Examples of an **Activity** in Altruistiq’s data model are **ElectricityUse** or **WasteGenerated**. A **Calculation Method** is an GHG Protocol compliant method to calculate emissions from Activity data. Calculation Methods have a unique set of data requirements, but are not unique to an **Activity**. A **Datasource** is a single data format that your data is shared with Altruistiq in. Alongside this function, a **Datasource** plays the role of linking a data format to key contextual information (e.g. relevant **Facilities**, relevant **Activities**, owner, chosen **Calculation Methods**, status). **Datasets** are then individual files ingested via that Datasource. Each **Dataset** has a live status for full data lineage and transparency that you can track in the application. # Datasource API Outline Primarily, Altruistiq’s Datasource API enables the creation and management of Datasources and the upload of new Datasets. Alongside this there are a number of supporting functions. The Datasource API is governed by the oauth2 protocol. The Datasource API by default does not expect sudden bursts of data upload (e.g. 25x5GB of data transferred at once), but instead delta datasets. When uploading to the upload endpoint the files uploaded must be chunked into chunks < 100mb and if there are more than 1 part then chunks must be > 5mb (the last part can be below this). If this is not the case for your business, do raise this at your Kick Off call and we will accommodate this. # PACT API Outline Primarily, Altruistiq’s PACT API allows customers to export Product Carbon Footprint (PCF) data in a PACT conformant way. PACT is the Partnership for Carbon Transparency, a WRI and WBCSD funded NGO that is setting the calculation and technological standard for the exchange for Product Carbon Footprints between businesses. Today, Altruistiq is 1 of ~10 PACT conformant solutions globally. The PACT API is is governed by the oauth2 protocol (see Security). For full documentation of our PACT API, please go to https://wbcsd.github.io/data-exchange-protocol/v2/#api-examples. This provides the full documentation for product data exports, and the associated data model.' servers: - url: https://app.altruistiq.com/ description: Altruistiq Server tags: - name: Export description: "### Altruistiq’s Export API enables you to:\n\n - Export corporate data\n\nExporting data is a key part of the Altruistiq platform. It allows you to take your data and use it in other systems, or to share it with other stakeholders.\n\nCurrently, our Export API allows you to export your Corporate Emissions data available in Altruistiq, down to a daily grain. We are working hard to also add Product Emissions data to your Export API. If you need to share Product emissions data today, see the PACT API.\n\nSchema of files which can be retrieved via this API (data dictionary):
\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
ColumnData TypeFormatOptionalDescription
fact_uuidstringuuidnoUnique identifier for emission record.
calendar_datestringdatenoDate of the emission record.
calendar_yearintegernoYear of the emission record.
emission_quantitynumber | stringdecimal(28, 10)noQuantity of the emission record.
emission_unitstringnoUnit the emissions are in.
calculation_input_quantitynumber | string | nulldecimal(28, 10)yesInput quantity used for the actual emission calculation (if applicable).
calculation_input_quantity_unitstring | nullyesUnit of the input quantity used for the actual emission calculation(if applicable).
spend_usdnumber | string | nulldecimal(28, 10)yesSpend in USD used for the actual emission calculation (if applicable).
spend_eurnumber | string | nulldecimal(28, 10)yesSpend in EUR used for the actual emission calculation (if applicable).
spend_gbpnumber | string | nulldecimal(28, 10)yesSpend in EUR used for the actual emission calculation (if applicable).
per_unitstringnoEmission Factor divisor.
input_dimensionalitystringnoDimensionality of the input quantity for the emission factor.
scope_categorystringnoScope categories are a subdivision of GHG Scopes with more detail about the emission’s cause. Scope categories are similar to, and overlapping with Activities.
scopestringnoRefers to the three scopes of the GHG Protocol.
activity_area_namestringnoActivity areas are groups of activities that have similar emissions calculation methodologies in the Altruistiq platform.
activity_namestringnoActivities areas are activities of a customer causing emissions.
sub_activity_namestringnoSub-Activities areas are a sub-dicision activities of a customer causing emissions.
aq_calc_methodstringnoCalculation Methodology used in the Altruistiq platform.
ghg_calc_methodstringnoCalculation Methodology according to the GHG protocol.
ef_specificitystringnoSpecificity level that Emission Factors refer to, e.g. Global Average or Country Average.
accuracy_scoreintegernoA measure of how accurate emissions calculations are for a particular activity, based on the quality of data available and the calculation methodology applied as a result.
accuracy_score_namestringnoA measure of how accurate emissions calculations are for a particular activity, based on the quality of data available and the calculation methodology applied as a result.
lifecyclestringnoEmissions caused by an activity can be further subdivided by the lifecycle they are associated with. For example, a business trip in a company car will cause emissions from vehicle use (i.e. burning the fuel) and well-to-tank emissions (i.e. drilling for oil, fuel production, and any other activities in the supply chain).
bu_uuidstringuuidnoUnique identifier for a BU.
bu_namestringnoName of the BU this record belongs to.
root_org_uuidstringuuidnoUnique identifier of the root organisation.
root_org_namestringnoName of the root organisation this record belongs to.
facility_namestring | nullyesName of the facility this record belongs to (if it is assigned at facility level).
facility_uuidstring | nullyesUnique identifier of the facility.
facility_country_namestring | nullyesCountry this facility belongs to.
facility_country_codestring | nullyesCountry code of the country this facility belongs to.
facility_post_codestring | nullyesPost code of this facility.
facility_typestring | nullyesType of this facility.
facility_capacity_rationumber | string | nulldecimal(28, 10)yesCapacity of this facility.
data_source_namestringyesName of the datasource which was used for this record.
file_namestringnoName of the file which was used for this record.
supplier_legal_namestring | nullyesSupplier legal name (if applicable).
supplier_country_codestring | nullyesSupplier country code (if applicable).
supplier_country_namestring | nullyesSupplier country name (if applicable).
supplier_vat_numberstring | nullyesSupplier VAT number (if applicable).
tagsobjectnoMapping of tag category -> value (e.g. energy_type -> mixed).\n

PREVIEW WARNING: THESE ARE CURRENTLY BEING CHANGED, SO ARE NOT STABLE!

\n

Categories:

\n
    \n
  • energy_type
  • \n
  • fuel_type
  • \n
  • fuel_net_or_gross_cv
  • \n
  • gas_type
  • \n
  • isic_section
  • \n
  • isic_division
  • \n
  • isic_group
  • \n
  • isic_class
  • \n
  • goods_service_type
  • \n
  • material_life_phase
  • \n
  • heating_type
  • \n
  • industry_type
  • \n
  • purchased_energy_type
  • \n
  • refrigerant_type
  • \n
  • renewable
  • \n
  • vehicle_type
  • \n
  • journey_type
  • \n
  • energy_generation_type
  • \n
  • vehicle_emission_type
  • \n
  • traffic_scenario
  • \n
  • vehicle_load
  • \n
  • waste_category
  • \n
  • wastewater_spend_type
  • \n
  • waste_treatment_type
  • \n
  • waste_type
  • \n
  • water_spend_type
  • \n
financial_yearintegerno
custom_analytics_fieldsobjectnoCustom Analytics Fields.
custom_tagsobjectnoFields used to tag/classify the record.
emission_factor_namestring | nullnoName of the emission factor used for this record.
emission_factor_specificitystring | nullnoSpecificity of the emission factor used for this record.
emission_factor_specificity_codestring | nullnoSpecificity Code of the emission factor used for this record.
emission_factor_sourcestring | nullnoSource of the emission factor used for this record.
emission_factor_source_versionstring | nullnoSource version of the emission factor used for this record.
created_atstringdate-timenoTimestamp when the record was created. NOTE: this might change if we do a full refresh in the backend.
updated_atstringdate-timenoTimestamp when the record was updated. NOTE: this might change if we do a full refresh in the backend.
" paths: /api/public/v1/export: post: security: - bearerAuth: [] tags: - Export summary: Create An Export operationId: createExport description: Use this endpoint to create and start an export. requestBody: content: application/json: schema: type: object required: - filters - format properties: format: type: object required: - type properties: type: type: string enum: - auto - brotli - bz2 - deflate - lzo - none - raw_deflate - snappy - gzip - zstd example: snappy description: "Not all compression types are supported for all file types.\nIn particular: \n * JSON supports: auto, brotli, bz2, deflate, raw_deflate, gzip and zstd\n * PARQUET supports: auto, lzo, none and snappy" partitionedBy: type: array items: type: string example: - facility_name filters: type: object required: - financial_years - endDate - startDate properties: financialYears: type: array items: type: integer example: - 2022 description: The financial years you want to export data for. endDate: type: string format: date description: The end date of the export. startDate: type: string format: date description: The start date of the export. x-codeSamples: - lang: python label: Python source: "import requests\n\n# needs token from /api/public/v1/oauth2/token\nresponse = requests.post(\n f\"https://app.altruistiq.com/api/public/v1/export\"\n headers={\n \"Authorization\": f\"Bearer {token}\"\n },\n json={\n \"filters\": {\"financialYears\": [2022]},\n \"format\": {\"type\": \"PARQUET\", \"compression\": \"snappy\"}\n }\n)\nresponse.raise_for_status()\n\nexport_id = response.json()[\"exportId\"]\n" responses: '201': description: Export Created content: application/json: schema: properties: status: $ref: '#/components/schemas/ExportStatus' exportId: type: number example: 3f0b7fbd-fa45-445a-8862-49cd1871eebc '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/401' '404': description: Not Found content: application/json: schema: $ref: '#/components/schemas/404' '500': description: Server Error content: application/json: schema: $ref: '#/components/schemas/500' '504': description: Not Implemented content: application/json: schema: $ref: '#/components/schemas/504' /api/public/v1/export/{exportId}: get: security: - bearerAuth: [] tags: - Export summary: Get Export Status And Download Urls operationId: getDownloadUrls description: Poll this endpoint to retrieve download URLs and the status of an export. x-codeSamples: - lang: python label: Python source: "# needs export_id from GET /api/public/v1/export\n# needs token from /api/public/v1/oauth2/token\n\nimport requests\nfrom time import sleep\n# if using pandas also\nimport pandas as pd\n\n\ndef wait_for_success(export_id: str):\n while True:\n response = requests.get(\n f\"https://app.altruistiq.com/api/public/v1/export/{export_id}\",\n headers={\n \"Authorization\": f\"Bearer {token}\"\n }\n )\n response.raise_for_status()\n export = response.json()\n status = export[\"status\"]\n if status in {\"FAILED\", \"CANCELLED\"}:\n raise RuntimeError(f\"Failed export {export}.\")\n if status == \"SUCCEEDED\":\n break\n sleep(5.0)\n return export\n\nexport = wait_for_success(export_id)\nfor i, url in enumerate(export[\"urls\"]):\n file_download = requests.get(url)\n file_download.raise_for_status()\n file_type = export['format']['type'].lower()\n compression = export['format'].get('compression', 'gz')\n with open(f\"my_folder/file_{i}.{file_type}.{compression}\", \"w\") as f:\n f.write(file_download.content)\n\n# alternatively if using pandas and you specified parquet format - this assumes data fits into memory\npd.concat((pd.read_parquet(url) for url in export[\"urls\"]))\n" responses: '200': description: Export Done content: application/json: schema: properties: status: $ref: '#/components/schemas/ExportStatus' exportId: type: number example: 3f0b7fbd-fa45-445a-8862-49cd1871eebc urls: type: array items: type: string example: https://app.altruistiq.com/api/public/v1/export/3f0b7fbd-fa45-445a-8862-49cd1871eebc/download '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/401' '404': description: Not Found content: application/json: schema: $ref: '#/components/schemas/404' '500': description: Server Error content: application/json: schema: $ref: '#/components/schemas/500' '504': description: Not Implemented content: application/json: schema: $ref: '#/components/schemas/504' components: schemas: '401': type: object properties: status: type: string example: Unauthorized description: Request was unauthorized ExportStatus: type: string enum: - QUEUED - RUNNING - SUCCEEDED - FAILED - CANCELLED example: QUEUED '404': type: object properties: status: type: string example: Not found description: Resource not found '500': type: object properties: status: type: string example: Server Error description: Internal Error '504': type: object properties: status: type: string example: Not Implemented description: Not Implemented securitySchemes: bearerAuth: type: apiKey name: Authorization in: header description: 'Enter the token with the `Bearer: ` prefix, e.g. `Bearer: apiKey`.' oauth2: type: oauth2 flows: clientCredentials: tokenUrl: https://app.altruistiq.com/api/public/v1/oauth2/token