GET /api/stats

The company's numbers: per day, accounts made, orders placed and how they stand, deliveries, deposits, revenue and earnings; now, accounts, professionals on standby, open orders, the pots and the time to review. Counts and sums only.

Surface: stats. Who may call: stats. Key: stats.read.

Example request

curl -X GET https://caremcp.com/api/stats?days=7 \
  -H "Authorization: Bearer <stats token>"

Example input

{
  "days": 7
}

Input schema

{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "type": "object",
 "properties": {
  "days": {
   "anyOf": [
    {
     "type": "integer",
     "minimum": -9007199254740991,
     "maximum": 9007199254740991
    },
    {
     "type": "string",
     "pattern": "^[1-9][0-9]*$"
    }
   ]
  }
 }
}

Output schema

{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "type": "object",
 "properties": {
  "from": {
   "$ref": "#/$defs/__schema0"
  },
  "to": {
   "$ref": "#/$defs/__schema0"
  },
  "time_zone": {
   "type": "string",
   "const": "Europe/Stockholm"
  },
  "days": {
   "type": "array",
   "items": {
    "type": "object",
    "properties": {
     "date": {
      "$ref": "#/$defs/__schema0"
     },
     "clients_new": {
      "$ref": "#/$defs/__schema1"
     },
     "clients_new_by_channel": {
      "$ref": "#/$defs/__schema2"
     },
     "orders_placed": {
      "$ref": "#/$defs/__schema1"
     },
     "orders_by_status": {
      "$ref": "#/$defs/__schema2"
     },
     "orders_by_protocol": {
      "$ref": "#/$defs/__schema2"
     },
     "orders_by_professions": {
      "$ref": "#/$defs/__schema2"
     },
     "reviews_delivered": {
      "$ref": "#/$defs/__schema1"
     },
     "top_ups": {
      "$ref": "#/$defs/__schema3"
     },
     "charges": {
      "$ref": "#/$defs/__schema3"
     },
     "earnings": {
      "type": "object",
      "properties": {
       "count": {
        "$ref": "#/$defs/__schema1"
       },
       "cents": {
        "type": "integer",
        "minimum": -9007199254740991,
        "maximum": 9007199254740991
       }
      },
      "required": [
       "count",
       "cents"
      ],
      "additionalProperties": false
     },
     "refused": {
      "$ref": "#/$defs/__schema2"
     }
    },
    "required": [
     "date",
     "clients_new",
     "clients_new_by_channel",
     "orders_placed",
     "orders_by_status",
     "orders_by_protocol",
     "orders_by_professions",
     "reviews_delivered",
     "top_ups",
     "charges",
     "earnings",
     "refused"
    ],
    "additionalProperties": false
   }
  },
  "now": {
   "type": "object",
   "properties": {
    "clients": {
     "$ref": "#/$defs/__schema1"
    },
    "organisations": {
     "$ref": "#/$defs/__schema1"
    },
    "professionals": {
     "type": "object",
     "properties": {
      "approved": {
       "$ref": "#/$defs/__schema1"
      },
      "pending": {
       "$ref": "#/$defs/__schema1"
      },
      "standby": {
       "$ref": "#/$defs/__schema1"
      }
     },
     "required": [
      "approved",
      "pending",
      "standby"
     ],
     "additionalProperties": false
    },
    "orders_open": {
     "$ref": "#/$defs/__schema2"
    },
    "pot_balance": {
     "$ref": "#/$defs/__schema4"
    },
    "median_hours_to_review": {
     "anyOf": [
      {
       "type": "number",
       "minimum": 0
      },
      {
       "type": "null"
      }
     ]
    }
   },
   "required": [
    "clients",
    "organisations",
    "professionals",
    "orders_open",
    "pot_balance",
    "median_hours_to_review"
   ],
   "additionalProperties": false
  },
  "notes": {
   "type": "object",
   "propertyNames": {
    "type": "string"
   },
   "additionalProperties": {
    "type": "string"
   }
  }
 },
 "required": [
  "from",
  "to",
  "time_zone",
  "days",
  "now",
  "notes"
 ],
 "additionalProperties": false,
 "$defs": {
  "__schema0": {
   "type": "string",
   "format": "date",
   "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])))$"
  },
  "__schema1": {
   "type": "integer",
   "minimum": 0,
   "maximum": 9007199254740991
  },
  "__schema2": {
   "type": "object",
   "propertyNames": {
    "type": "string"
   },
   "additionalProperties": {
    "$ref": "#/$defs/__schema1"
   }
  },
  "__schema3": {
   "type": "object",
   "properties": {
    "count": {
     "$ref": "#/$defs/__schema1"
    },
    "cents": {
     "$ref": "#/$defs/__schema4"
    }
   },
   "required": [
    "count",
    "cents"
   ],
   "additionalProperties": false
  },
  "__schema4": {
   "type": "object",
   "propertyNames": {
    "type": "string"
   },
   "additionalProperties": {
    "type": "integer",
    "minimum": -9007199254740991,
    "maximum": 9007199254740991
   }
  }
 }
}