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

# Get Database Metrics

> Get the metrics of your hosted database.

<ParamField header="Authorization" type="string" placeholder="API Key" required>
  The API key for your account. You can find this in your [account settings](https://squarecloud.app/en/account/security).
</ParamField>

Returns historical CPU, RAM and network usage for a database, sampled every 5 minutes over the last 24 hours (up to 288 points). Use it to plot usage graphs or to decide whether the database needs more memory before calling [Edit Database](/en/api-reference/endpoint/databases/edit).

For a single current reading instead of a time series, use [Get Database Status](/en/api-reference/endpoint/databases/status). Responses are cached for 2.5 minutes per user and database, and the endpoint is rate limited to 10 requests per 5 seconds per user, with a 60-second block once that cap is hit. A database with no recent samples returns an empty array rather than an error.

### Parameters

<ParamField path="database_id" type="string" placeholder="Database ID" required>
  The ID of the database.
</ParamField>

### Response

<ResponseField name="status" type="string">
  Indicates whether the call was successful.. `success` if successful, `error` if not.
</ResponseField>

<ResponseField name="response" type="array">
  The contents of the response.

  <Expandable title="Toggle object">
    <ResponseField name="date" type="string">
      The date in ISO format.
    </ResponseField>

    <ResponseField name="cpu" type="number">
      The current CPU usage percentage.
    </ResponseField>

    <ResponseField name="ram" type="number">
      The current RAM usage in MB.
    </ResponseField>

    <ResponseField name="net" type="int[]">
      An array representing total network used. First the input, second the output.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseExample>
  ```json theme={null}
  {
      "status": "success",
      "response": [
          {
              "date": "2025-08-13T12:55:01.348Z",
              "cpu": 0.45,
              "ram": 111.27,
              "net": [
                  16834,
                  126
              ]
          },
          {
              "date": "2025-08-13T12:50:01.349Z",
              "cpu": 0.45,
              "ram": 111.22,
              "net": [
                  16834,
                  126
              ]
          },
          {
              "date": "2025-08-13T12:45:01.350Z",
              "cpu": 0.58,
              "ram": 111.36,
              "net": [
                  16834,
                  126
              ]
          },
          {
              "date": "2025-08-13T12:40:01.348Z",
              "cpu": 0.43,
              "ram": 118.44,
              "net": [
                  16834,
                  126
              ]
          }
      ]
  }
  ```
</ResponseExample>

### Common errors

| Code                 | HTTP | Meaning                                                    |
| -------------------- | ---- | ---------------------------------------------------------- |
| `DATABASE_NOT_FOUND` | 404  | The database does not exist or is not owned by the caller. |
