Analysis

Submit one analysis

A JSON body declares exactly one input: a url, text, html with the url it came from, or structured items with the country they were bought in. Two inputs is a 422, and each answers 202 with the session id.

A multipart/form-data body is a file. country_code is required with it, because a file carries no country of its own and nothing is assumed: the footprint is calculated for the country the caller declares, and prices with no stated currency are read in that country's currency. kind chooses the backend, and is otherwise decided by the extension — .pdf .docx .doc .txt .md are documents, .csv .xlsx .xls .tsv .ofx .qfx .qif .iif are accounting files. A document over 100 KB or an accounting file over 1 MB is refused here with a 413 before it is forwarded.

The two kinds finish differently. An accounting file is analysed off the request and answers 202 with links.import beside the session links. A DOCUMENT IS ANALYSED INSIDE THE REQUEST by the main app's single worker process, so the request is held for the length of the analysis — up to 180 seconds — and answers 200 with status 'completed', because by then the work is done.

post/v1/analyses

Request

  • Base URL: https://carbonguru.io
  • URL: https://carbonguru.io/v1/analyses
  • Auth: HTTP bearer

Headers

Idempotency-Keystring

A key of the caller's choosing, held 24 hours and scoped to the account, the method and the path. The same key with the same body replays the stored response with Idempotent-Replayed: true. The same key with a different body is a 409 idempotency_key_reuse. A request still running under the key is a 409 idempotency_in_progress. A key longer than 255 characters or holding control characters is a 422. A write whose record cannot be stored is still processed once, without the replay guarantee. A response carrying a secret is never replayed: the second request receives a 409 idempotency_secret_not_replayable.

Request body

urlstring

A product or cart page the platform fetches, or the address html came from.

context_type'product' | 'cart' | 'multi_product' | 'order_list'
timeoutinteger
textstring

Freeform text: a shopping list, a receipt, an order confirmation.

htmlstring

Page html the caller already holds. Needs url.

source_namestring

A label for a text analysis.

country_codestring

The country these items were bought in. Required with items; nothing is defaulted.

Response

A document, analysed inside the request. status is 'completed'.

session_idstring required
status'processing' | 'completed' required

completed only for a document upload, which finishes inside the request.

Changes

No recorded changes to this operation across all 1 revision of this API.