> ## Documentation Index
> Fetch the complete documentation index at: https://docs.burokku.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Profit and loss

> Use this when the user asks how their net worth or profit and loss moved over a period. Returns the change in dollars and percent, the high, the low and up to 13 points; for 1D, 1W and 1M also what drove it (coins, accounts, realised perp PnL, funding and fees); and unrealised PnL on holdings whose cost Burokku knows. These are not tax figures.



## OpenAPI

````yaml /openapi.json get /pnl
openapi: 3.1.0
info:
  title: Burokku API
  version: '1'
  description: >-
    Read your Burokku portfolio: net worth, holdings, DeFi, perp and prediction
    market positions, liquidation risk, profit and loss, activity and alerts.
    Two writes only notify or watch: a price alert, and a watched address.
    Nothing in this API can trade, swap, send or sign. The same nine operations
    are the Burokku connector’s tools for AI apps.
servers:
  - url: https://api.burokku.app/v1
    description: Production
security:
  - oauth2:
      - portfolio.read
  - apiKey: []
tags:
  - name: Portfolio
    description: Net worth, holdings, positions, liquidation risk and profit and loss.
  - name: Activity
    description: Transactions and trades, newest first.
  - name: Alerts
    description: The account’s alerts, and price alerts that only notify.
  - name: Accounts
    description: Public addresses added watch-only.
paths:
  /pnl:
    get:
      tags:
        - Portfolio
      summary: Profit and loss
      description: >-
        Use this when the user asks how their net worth or profit and loss moved
        over a period. Returns the change in dollars and percent, the high, the
        low and up to 13 points; for 1D, 1W and 1M also what drove it (coins,
        accounts, realised perp PnL, funding and fees); and unrealised PnL on
        holdings whose cost Burokku knows. These are not tax figures.
      operationId: pnl
      parameters:
        - name: range
          in: query
          required: false
          schema:
            default: 1D
            type: string
            enum:
              - 1D
              - 1W
              - 1M
              - 1Y
              - All
      responses:
        '200':
          description: OK
          headers:
            X-RateLimit-Limit:
              $ref: '#/components/headers/X-RateLimit-Limit'
            X-RateLimit-Remaining:
              $ref: '#/components/headers/X-RateLimit-Remaining'
            X-RateLimit-Reset:
              $ref: '#/components/headers/X-RateLimit-Reset'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Pnl'
        '400':
          description: A value is missing, of the wrong type or out of range.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: bad-input
                  message: >-
                    Some of what was asked isn’t valid: limit: Too big: expected
                    number to be <=100
          headers:
            X-RateLimit-Limit:
              $ref: '#/components/headers/X-RateLimit-Limit'
            X-RateLimit-Remaining:
              $ref: '#/components/headers/X-RateLimit-Remaining'
            X-RateLimit-Reset:
              $ref: '#/components/headers/X-RateLimit-Reset'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '423':
          $ref: '#/components/responses/Locked'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/ServerError'
        '503':
          $ref: '#/components/responses/Off'
      security:
        - oauth2:
            - portfolio.read
        - apiKey: []
components:
  headers:
    X-RateLimit-Limit:
      description: >-
        The plan’s calls a day, shared by the REST API and the connector. Always
        the daily quota, never the per-minute limit or the read budget. On every
        answer from an operation, successes and errors alike, both 429s
        included; not on a 401, or an answer about the request itself (an
        unknown path, 405, 413, `bad-json`, a 403 for scope).
      schema:
        type: integer
    X-RateLimit-Remaining:
      description: >-
        Calls left today, after this call if it counted. Only calls that run are
        counted, and it never says more than is left.
      schema:
        type: integer
    X-RateLimit-Reset:
      description: >-
        When the count starts again: the end of the UTC day, in Unix epoch
        seconds.
      schema:
        type: integer
    Retry-After:
      description: >-
        Seconds to wait: until the UTC day ends for `daily-limit`, 60 for
        `rate-limited`.
      schema:
        type: integer
  schemas:
    Pnl:
      type: object
      properties:
        range:
          type: string
          enum:
            - 1D
            - 1W
            - 1M
            - 1Y
            - All
        start_usd:
          type:
            - number
            - 'null'
        end_usd:
          type: number
        change_usd:
          type:
            - number
            - 'null'
        change_pct:
          anyOf:
            - type: number
              description: Percent (12.5 is 12.5%).
            - type: 'null'
        high_usd:
          type:
            - number
            - 'null'
        low_usd:
          type:
            - number
            - 'null'
        points:
          type: array
          items:
            type: object
            properties:
              at:
                type: string
                format: date-time
                pattern: >-
                  ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$
              usd:
                type: number
            required:
              - at
              - usd
            additionalProperties: false
        drivers:
          description: 1D, 1W and 1M only.
          type: object
          properties:
            by_source:
              type: array
              items:
                type: object
                properties:
                  kind:
                    type: string
                  name:
                    type: string
                  usd:
                    type: number
                  venue:
                    type: string
                required:
                  - kind
                  - name
                  - usd
                additionalProperties: false
            coins:
              type: array
              items:
                type: object
                properties:
                  symbol:
                    type: string
                  usd:
                    type: number
                  pct:
                    type: number
                    description: Percent (12.5 is 12.5%).
                required:
                  - symbol
                  - usd
                  - pct
                additionalProperties: false
            perps:
              type: object
              properties:
                realised_usd:
                  type: number
                funding_usd:
                  type: number
                fees_usd:
                  type: number
                open_unrealised_usd:
                  type: number
              required:
                - realised_usd
                - funding_usd
                - fees_usd
              additionalProperties: false
            fees:
              type: object
              properties:
                network_usd:
                  type: number
                perp_trading_usd:
                  type: number
                bots_usd:
                  type: number
                funding_paid_usd:
                  type: number
                total_usd:
                  type: number
              required:
                - network_usd
                - perp_trading_usd
                - bots_usd
                - funding_paid_usd
                - total_usd
              additionalProperties: false
            activity_from:
              description: >-
                The activity read reaches back only to here: realised PnL and
                fees before it are not counted.
              type: string
              format: date-time
              pattern: >-
                ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$
          required:
            - coins
            - fees
          additionalProperties: false
        unrealised:
          anyOf:
            - type: object
              properties:
                pnl_usd:
                  type: number
                cost_usd:
                  type: number
                roi_pct:
                  anyOf:
                    - type: number
                      description: Percent (12.5 is 12.5%).
                    - type: 'null'
                coverage_pct:
                  type: number
                  description: >-
                    Share of holdings (by value, stablecoins aside) whose cost
                    is known.
                by_holding:
                  type: array
                  items:
                    type: object
                    properties:
                      symbol:
                        type: string
                      pnl_usd:
                        type: number
                      cost_usd:
                        type: number
                      roi_pct:
                        anyOf:
                          - type: number
                            description: Percent (12.5 is 12.5%).
                          - type: 'null'
                      partial:
                        type: boolean
                        description: Only part of what is held has a known cost.
                    required:
                      - symbol
                      - pnl_usd
                      - cost_usd
                      - roi_pct
                      - partial
                    additionalProperties: false
                  description: >-
                    The holdings with a known cost, largest PnL first (at most
                    10).
              required:
                - pnl_usd
                - cost_usd
                - roi_pct
                - coverage_pct
                - by_holding
              additionalProperties: false
            - type: 'null'
          description: >-
            Unrealised PnL on holdings whose cost Burokku knows; null when none
            is known.
        note:
          type: string
        read_at:
          type: string
          format: date-time
          pattern: >-
            ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$
          description: When these figures were read (ISO 8601, UTC).
        refreshing:
          type: boolean
          description: >-
            True while Burokku reads the accounts again behind this answer; a
            later call has newer figures.
        currency:
          type: object
          properties:
            code:
              type: string
              description: The currency the account shows money in (USD, EUR, JPY…).
            per_usd:
              type: number
              exclusiveMinimum: 0
              description: >-
                Units of that currency per US dollar, to convert the *_usd
                figures.
          required:
            - code
            - per_usd
          additionalProperties: false
      required:
        - range
        - start_usd
        - end_usd
        - change_usd
        - change_pct
        - high_usd
        - low_usd
        - points
        - unrealised
        - note
        - read_at
        - refreshing
        - currency
      additionalProperties: false
    Error:
      type: object
      description: >-
        Burokku’s errors: a code to branch on and a sentence that says what
        happened and what to do, in the language of the request’s
        Accept-Language (English when it names none Burokku speaks).
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: >-
                What went wrong, for code to branch on: bad-input, bad-json,
                bad-cursor, unknown-asset, not-address, secret,
                account-required, plan-limit, insufficient-scope, not-found,
                LOCKED, method-not-allowed, too-large, rate-limited,
                daily-limit, off or server-error; a 400 or 403 without its own
                code comes as bad-request or forbidden. New codes may be added.
            message:
              type: string
              description: >-
                What happened and what to do, for a person to read. Don’t parse
                it.
          required:
            - code
            - message
          additionalProperties: false
      required:
        - error
      additionalProperties: false
  responses:
    Unauthorized:
      description: >-
        No token (`unauthorized`), or a key or token that isn’t valid: made up,
        expired, revoked or issued for the MCP server (`invalid-token`). The
        `WWW-Authenticate` header says the same (`error="invalid_token"` when a
        token was sent) and names this API’s protected resource metadata. No
        rate headers: the account isn’t known.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            unauthorized:
              value:
                error:
                  code: unauthorized
                  message: >-
                    Send an API key or an access token as a Bearer token in the
                    Authorization header.
            invalid-token:
              value:
                error:
                  code: invalid-token
                  message: >-
                    This API key or access token isn’t valid. It may have
                    expired or been revoked.
      headers:
        WWW-Authenticate:
          description: >-
            For example: Bearer realm="OAuth",
            resource_metadata="https://api.burokku.app/.well-known/oauth-protected-resource/v1",
            error="invalid_token", scope="portfolio.read portfolio.write
            offline_access"
          schema:
            type: string
    Locked:
      description: >-
        The account is locked (Settings → Security). Every call is refused until
        it’s unlocked, before anything is counted.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: LOCKED
              message: >-
                Your account is locked. Security changes are on hold for 24
                hours from when it was locked.
      headers:
        X-RateLimit-Limit:
          $ref: '#/components/headers/X-RateLimit-Limit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/X-RateLimit-Remaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/X-RateLimit-Reset'
    RateLimited:
      description: >-
        Over a limit: 30 calls a minute per account (`rate-limited`,
        `Retry-After: 60`), or the plan’s calls for the UTC day, shared with the
        connector (`daily-limit`, which links only the pricing page;
        `Retry-After` is the seconds until the UTC day ends). Reads also count
        against the account’s read budget, which answers `rate-limited` with
        `Retry-After: 60`. A refused call isn’t counted, and the `X-RateLimit-*`
        headers still describe the day.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            rate-limited:
              value:
                error:
                  code: rate-limited
                  message: Too many calls in a minute. Try again in a minute.
            daily-limit:
              value:
                error:
                  code: daily-limit
                  message: >-
                    This account has used today’s 100 calls from AI apps and the
                    API; they start again at midnight UTC. Plans with more are
                    at https://burokku.app/pricing
      headers:
        Retry-After:
          $ref: '#/components/headers/Retry-After'
        X-RateLimit-Limit:
          $ref: '#/components/headers/X-RateLimit-Limit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/X-RateLimit-Remaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/X-RateLimit-Reset'
    ServerError:
      description: Something failed on Burokku’s side. Try again in a minute.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: server-error
              message: Something went wrong on Burokku’s side. Try again in a minute.
      headers:
        X-RateLimit-Limit:
          $ref: '#/components/headers/X-RateLimit-Limit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/X-RateLimit-Remaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/X-RateLimit-Reset'
    'Off':
      description: Burokku for AI apps and the API is switched off for now.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: 'off'
              message: >-
                Burokku for AI apps and the API isn’t available right now. Try
                again later.
      headers:
        X-RateLimit-Limit:
          $ref: '#/components/headers/X-RateLimit-Limit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/X-RateLimit-Remaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/X-RateLimit-Reset'
  securitySchemes:
    oauth2:
      type: oauth2
      description: >-
        OAuth 2.1 for apps that act for a Burokku user: the authorization code
        grant with PKCE (S256) required of every client. Clients use a Client ID
        Metadata Document, or register at /oauth/register (at most 20
        registrations an hour from one network). Set `resource` to
        https://api.burokku.app/v1: a token issued for the MCP server (the
        default without `resource`) is refused here with a 401
        (`invalid-token`); a token is for one resource, so authorize once for
        each and refresh with the same `resource` (another gets
        `invalid_target`). Every grant includes portfolio.read. Authorization
        server metadata:
        https://app.burokku.app/.well-known/oauth-authorization-server; this
        API’s protected resource metadata:
        https://api.burokku.app/.well-known/oauth-protected-resource/v1. Access
        tokens last 1 hour; each refresh returns a new refresh token (use the
        newest), and one unused for 30 days lapses. OAuth errors are JSON, `{
        error, error_description }`.
      flows:
        authorizationCode:
          authorizationUrl: https://app.burokku.app/oauth/authorize
          tokenUrl: https://app.burokku.app/oauth/token
          refreshUrl: https://app.burokku.app/oauth/token
          scopes:
            portfolio.read: Read balances, positions, activity and alerts. Every grant has it.
            portfolio.write: Create price alerts and add watched addresses.
            offline_access: >-
              Get a refresh token, to stay connected past the access token’s
              hour.
    apiKey:
      type: http
      scheme: bearer
      bearerFormat: bk_live_…
      description: >-
        A personal API key (`bk_live_` and 43 more characters), sent as
        `Authorization: Bearer bk_live_…`. A key reads only, unless it was made
        with write. Never put a key in a URL.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.