Goldmine
Profit and Loss

Get profit and loss over time periods

POST
/contracts.v1.Contracts/GetPnLPeriods

Returns a workspace's profit and loss bucketed into day, week, or month periods across a time range, for plotting trends. Optionally scoped to a single contract.

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://loading/contracts.v1.Contracts/GetPnLPeriods" \  -H "Content-Type: application/json" \  -d '{    "workspaceId": "AAECAwQFBgcICQoLDA0ODw==",    "startTime": "2026-04-01T00:00:00Z",    "endTime": "2026-06-30T23:59:59Z",    "granularity": "month"  }'
{
  "periods": [
    {
      "periodStart": "2026-04-01T00:00:00Z",
      "periodEnd": "2026-04-30T23:59:59Z",
      "buyCostCents": "420000",
      "sellRevenueCents": "510000",
      "pnlCents": "90000",
      "purchaseCount": "104"
    },
    {
      "periodStart": "2026-05-01T00:00:00Z",
      "periodEnd": "2026-05-31T23:59:59Z",
      "buyCostCents": "380000",
      "sellRevenueCents": "445000",
      "pnlCents": "65000",
      "purchaseCount": "96"
    }
  ]
}
{
  "code": "invalid_argument",
  "message": "The request was malformed, such as a missing required field or an unparseable cursor."
}
{
  "code": "unauthenticated",
  "message": "The request lacks a valid API key in the Authorization header."
}
{
  "code": "permission_denied",
  "message": "The API key is not allowed to perform this action on this workspace."
}
{
  "code": "resource_exhausted",
  "message": "The request was rate limited. Slow down and retry later."
}
{
  "code": "internal",
  "message": "An internal server error occurred."
}