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

# Histórico de Uso

> Retorna estatísticas de uso de um usuário da proxy em um determinado período.

Retorna estatísticas de uso (requisições, tráfego, hosts acessados) de um usuário da proxy em um determinado período.

## Headers

<ParamField header="X-API-Key" type="string" required>
  Sua chave de API no formato `gm_SUA_CHAVE`.
</ParamField>

## Body

<ParamField body="user_id" type="string" required>
  ID do usuário da proxy a ser consultado.
</ParamField>

<ParamField body="period" type="string" required>
  Período das estatísticas. Valores aceitos: `day`, `week`, `month`, `3months` ou `6months`.
</ParamField>

<ParamField body="limit" default="100" type="integer">
  Quantidade máxima de registros retornados.
</ParamField>

<ParamField body="offset" default="0" type="integer">
  Deslocamento para paginação.
</ParamField>

<ParamField body="datetime_aggregate" default="minute" type="string">
  Granularidade da agregação temporal. Valores aceitos: `minute`, `hour` ou `day`.
</ParamField>

## Resposta

<ResponseField name="usage" type="array">
  Lista de registros de uso do proxy.

  <Expandable title="Propriedades">
    <ResponseField name="host" type="string | null">
      Host acessado pela requisição. Pode ser `null` em caso de erro de conexão.
    </ResponseField>

    <ResponseField name="datetime" type="string">
      Data e hora do registro (UTC).
    </ResponseField>

    <ResponseField name="requests" type="integer">
      Quantidade de requisições realizadas.
    </ResponseField>

    <ResponseField name="traffic" type="integer | string">
      Tráfego consumido no período (formatado).
    </ResponseField>

    <ResponseField name="extra_traffic" type="string">
      Tráfego adicional consumido.
    </ResponseField>

    <ResponseField name="status" type="string">
      Status da requisição. Valores possíveis: `success` ou `error`.
    </ResponseField>

    <ResponseField name="message" type="string | null">
      Mensagem de erro, quando `status` for `error`.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="total_count" type="integer">
  Total de registros disponíveis.
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X GET https://api.gmproxys.com/v1/usage \
    -H "X-API-Key: gm_SUA_CHAVE" \
    -H "Content-Type: application/json" \
    -d '{
      "user_id": "6712",
      "period": "day",
      "limit": 100,
      "offset": 0,
      "datetime_aggregate": "minute"
    }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch("https://api.gmproxys.com/v1/usage", {
    method: "GET",
    headers: {
      "X-API-Key": "gm_SUA_CHAVE",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      user_id: "6712",
      period: "day",
      limit: 100,
      offset: 0,
      datetime_aggregate: "minute",
    }),
  });

  const data = await response.json();
  ```

  ```python Python theme={null}
  import requests

  response = requests.get(
      "https://api.gmproxys.com/v1/usage",
      headers={
          "X-API-Key": "gm_SUA_CHAVE",
          "Content-Type": "application/json",
      },
      json={
          "user_id": "6712",
          "period": "day",
          "limit": 100,
          "offset": 0,
          "datetime_aggregate": "minute",
      },
  )

  print(response.json())
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "usage": [
      {
        "host": null,
        "datetime": "2023-09-15 09:27:00 UTC",
        "requests": 0,
        "traffic": 0,
        "extra_traffic": "0 bytes",
        "status": "error",
        "message": "NO_HOST_CONNECTION"
      },
      {
        "host": "api.ipify.",
        "datetime": "2023-09-15 09:27:00 UTC",
        "requests": 1,
        "traffic": 0,
        "extra_traffic": "0 bytes",
        "status": "success",
        "message": null
      },
      {
        "host": "google.com",
        "datetime": "2023-09-15 09:25:00 UTC",
        "requests": 1,
        "traffic": "8.08 KB",
        "extra_traffic": "21.57 KB",
        "status": "success",
        "message": null
      },
      {
        "host": "api.ipify.org",
        "datetime": "2023-09-15 09:25:00 UTC",
        "requests": 3,
        "traffic": "20.41 KB",
        "extra_traffic": "600.8 KB",
        "status": "success",
        "message": null
      }
    ],
    "total_count": 4
  }
  ```

  ```json 401 Token inválido theme={null}
  {
    "success": false,
    "message": "Invalid API token."
  }
  ```

  ```json 404 Proxy inexistente theme={null}
  {
    "success": false,
    "message": "Proxy user not found."
  }
  ```
</ResponseExample>
