---
title: "Get print spending split into filament, electricity and maintenance, grouped by material type and brand, with the cost of failed prints."
method: GET
path: "/api/Analytics/costs"
tags: ["Analytics"]
---

# Get print spending split into filament, electricity and maintenance, grouped by material type and brand, with the cost of failed prints.

`GET /api/Analytics/costs`

## Request

- Base URL: `https://api.3dprintlog.com`
- URL: `https://api.3dprintlog.com/api/Analytics/costs`
- Auth: one of:
  - OAuth 2 (authorization code, authorization URL `https://3dprintlog.auth0.com/authorize`, token URL `https://3dprintlog.auth0.com/oauth/token`)
  - API key in header `X-Api-Key`
  - API key in query parameter `api_key`

Covers the authenticated user's own prints only. Every analytics endpoint takes the same
filter: a half-open `fromDate`/`toDate` range (omit both for all time), an IANA
`timeZone` for bucketing (default UTC), optional `printerIds`,
`filamentIds`, `projectIds` and `statuses`, a `granularity`
(Auto, Day, Week or Month) and `comparePrevious` to add the preceding window of the
same length. Ids the caller does not own match nothing.

## Query parameters

- `FromDate` string, date-time
- `ToDate` string, date-time
- `TimeZone` string
- `PrinterIds` integer[]
- `FilamentIds` string[]
- `ProjectIds` string[]
- `Statuses` PrintLogApiModelsPrintPrintStatus[]
- `Granularity` 0 | 1 | 2 | 3: Sent as an integer: `0` = Auto, `1` = Day, `2` = Week, `3` = Month.
- `ComparePrevious` boolean
- `HasRange` boolean

## Response `200`

Cost totals, groups and series for the filtered window.

- PrintLogApiModelsDTOsAnalyticsCostsResponse: The Costs tab payload. CostOfFailureSharePercent is null when total spend is 0 — a share of nothing is undefined, not 0%, and 0% would read as "no failures".
  - `from` string, date-time, nullable
  - `to` string, date-time, nullable
  - `timeZone` string, nullable
  - `granularity` string, nullable
  - `currency` string, nullable
  - `totalSpend` PrintLogApiModelsDTOsAnalyticsMoneyMetric: Money is decimal, never double, and always carries its currency.
    - `value` number, double, nullable
    - `previous` number, double, nullable
    - `currency` string, nullable
    - `coverage` PrintLogApiModelsDTOsAnalyticsCoverage: Population is named explicitly ("prints", "spools", "printers") because a count of excluded spools is not a count of excluded prints.
      - `population` string, nullable
      - `counted` integer
      - `total` integer
      - `undatedCount` integer
      - `exclusions` PrintLogApiModelsDTOsAnalyticsCoverageExclusion[], nullable
        - `reason` string, nullable
        - `count` integer
  - `filamentSpend` PrintLogApiModelsDTOsAnalyticsMoneyMetric: Money is decimal, never double, and always carries its currency.
    - `value` number, double, nullable
    - `previous` number, double, nullable
    - `currency` string, nullable
    - `coverage` PrintLogApiModelsDTOsAnalyticsCoverage: Population is named explicitly ("prints", "spools", "printers") because a count of excluded spools is not a count of excluded prints.
      - `population` string, nullable
      - `counted` integer
      - `total` integer
      - `undatedCount` integer
      - `exclusions` PrintLogApiModelsDTOsAnalyticsCoverageExclusion[], nullable
        - `reason` string, nullable
        - `count` integer
  - `electricitySpend` PrintLogApiModelsDTOsAnalyticsMoneyMetric: Money is decimal, never double, and always carries its currency.
    - `value` number, double, nullable
    - `previous` number, double, nullable
    - `currency` string, nullable
    - `coverage` PrintLogApiModelsDTOsAnalyticsCoverage: Population is named explicitly ("prints", "spools", "printers") because a count of excluded spools is not a count of excluded prints.
      - `population` string, nullable
      - `counted` integer
      - `total` integer
      - `undatedCount` integer
      - `exclusions` PrintLogApiModelsDTOsAnalyticsCoverageExclusion[], nullable
        - `reason` string, nullable
        - `count` integer
  - `maintenanceSpend` PrintLogApiModelsDTOsAnalyticsMoneyMetric: Money is decimal, never double, and always carries its currency.
    - `value` number, double, nullable
    - `previous` number, double, nullable
    - `currency` string, nullable
    - `coverage` PrintLogApiModelsDTOsAnalyticsCoverage: Population is named explicitly ("prints", "spools", "printers") because a count of excluded spools is not a count of excluded prints.
      - `population` string, nullable
      - `counted` integer
      - `total` integer
      - `undatedCount` integer
      - `exclusions` PrintLogApiModelsDTOsAnalyticsCoverageExclusion[], nullable
        - `reason` string, nullable
        - `count` integer
  - `spendOverTime` PrintLogApiModelsDTOsAnalyticsCostSeriesBucket[], nullable
    - `index` integer
    - `localStart` string, date
    - `filament` number, double, nullable
    - `electricity` number, double, nullable
    - `maintenance` number, double, nullable
  - `costPerPrint` PrintLogApiServicesAnalyticsHistogramBucket[], nullable
    - `label` string, nullable
    - `lowerSeconds` integer
    - `upperSeconds` integer, nullable
    - `count` integer
  - `byMaterialType` PrintLogApiModelsDTOsAnalyticsCostGroup[], nullable
    - `key` string, nullable
    - `label` string, nullable
    - `amount` number, double
    - `printCount` integer
  - `byBrand` PrintLogApiModelsDTOsAnalyticsCostGroup[], nullable
    - `key` string, nullable
    - `label` string, nullable
    - `amount` number, double
    - `printCount` integer
  - `costOfFailure` PrintLogApiModelsDTOsAnalyticsMoneyMetric: Money is decimal, never double, and always carries its currency.
    - `value` number, double, nullable
    - `previous` number, double, nullable
    - `currency` string, nullable
    - `coverage` PrintLogApiModelsDTOsAnalyticsCoverage: Population is named explicitly ("prints", "spools", "printers") because a count of excluded spools is not a count of excluded prints.
      - `population` string, nullable
      - `counted` integer
      - `total` integer
      - `undatedCount` integer
      - `exclusions` PrintLogApiModelsDTOsAnalyticsCoverageExclusion[], nullable
        - `reason` string, nullable
        - `count` integer
  - `costOfFailureSharePercent` number, double, nullable
  - `mostExpensive` PrintLogApiModelsDTOsAnalyticsPrintCostRef[], nullable
    - `printId` integer
    - `title` string, nullable
    - `date` string, date, nullable
    - `amount` number, double
  - `leastExpensive` PrintLogApiModelsDTOsAnalyticsPrintCostRef[], nullable
    - `printId` integer
    - `title` string, nullable
    - `date` string, date, nullable
    - `amount` number, double
  - `coverage` PrintLogApiModelsDTOsAnalyticsCoverage: Population is named explicitly ("prints", "spools", "printers") because a count of excluded spools is not a count of excluded prints.
    - `population` string, nullable
    - `counted` integer
    - `total` integer
    - `undatedCount` integer
    - `exclusions` PrintLogApiModelsDTOsAnalyticsCoverageExclusion[], nullable
      - `reason` string, nullable
      - `count` integer

## Other responses

- `400`: The filter is invalid, for example a one-sided or reversed date range.
- `401`: Unauthorized
- `403`: Forbidden

---

[API](https://skmtc.dev/3dprintlog/apis/3d-print-log-api.md) · [All operations](https://skmtc.dev/3dprintlog/apis/3d-print-log-api/llms.txt) · [OpenAPI document](https://skmtc.dev/3dprintlog/apis/3d-print-log-api/revisions/dfc3a4df4e38?raw)
