Get account usage metrics
package main
import ( "fmt" "net/http" "io")
func main() {
url := "https://api.wpengineapi.com/v1/accounts/eeda3227-9a39-46ae-9e14-20958bb4e6c9/usage?limit=100"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Basic <credentials>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close() body, _ := io.ReadAll(res.Body)
fmt.Println(res) fmt.Println(string(body))
}const url = 'https://api.wpengineapi.com/v1/accounts/eeda3227-9a39-46ae-9e14-20958bb4e6c9/usage?limit=100';const options = {method: 'GET', headers: {Authorization: 'Basic <credentials>'}};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url 'https://api.wpengineapi.com/v1/accounts/eeda3227-9a39-46ae-9e14-20958bb4e6c9/usage?limit=100' \ --header 'Authorization: Basic <credentials>'Get usage metrics for all environments in an account.
If the optional first_date and last_date arguments are omitted, the response will include metrics for the last 30 days.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”ID of account
Example
eeda3227-9a39-46ae-9e14-20958bb4e6c9Query Parameters
Section titled “Query Parameters”The start date for the requested metrics range (inclusive).
Format: YYYY-mm-dd. Cannot be older than 13 months.
If first_date is provided, last_date must also be provided.
The end date for the requested metrics range (inclusive).
Format: YYYY-mm-dd.
If last_date is provided, first_date must also be provided.
The maximum number of environments to return. A maximum of 1000 environments can be requested per page
String-encoded offset for pagination. The next_page_token from the response can be used to paginate accordingly.
Responses
Section titled “Responses”A successful response.
object
Usage metrics for each environment in the account
object
The name of the environment
Daily usage metrics for this environment
Usage metrics collected over the period of one day.
In JSON format, the DailyUsageMetrics int64 values are encoded as a string rather than a number, following the proto3 specification.
object
The date (ISO 8601).
Total visits.
Data served over HTTP by the origin server.
This does not include cached data served from a CDN.
Storage used by this environment’s files.
This includes all files in the web root directory.
Storage used by this environment’s database.
Billable visits.
The total number of HTTP requests received by the origin server.
This does not include cached requests that were served from a CDN.
The data served by the CDN.
The most recent storage usage measurement time (in UTC).
The sum of CDN and origin network bytes.
The source of the traffic metrics.
- TRAFFIC_METRICS_SOURCE_UNSPECIFIED: The source of the traffic metrics is unknown.
- ONHOST: The traffic metrics is sourced from onhost logcrunch (legacy).
- BIGQUERY: The traffic metrics is sourced from BigQuery logcrunch.
The number of tables in the install’s database.
The sum of bytes of the database content in MySQL for an install.
The sum of bytes that is automatically loaded on each request to the install.
A rollup of usage metrics.
object
A metric rollup.
object
The average value of the metric.
The total sum value of the metric.
The latest information.
object
The date (ISO 8601).
The value.
A metric rollup.
object
The average value of the metric.
The total sum value of the metric.
The latest information.
object
The date (ISO 8601).
The value.
A metric rollup.
object
The average value of the metric.
The total sum value of the metric.
The latest information.
object
The date (ISO 8601).
The value.
A metric rollup.
object
The average value of the metric.
The total sum value of the metric.
The latest information.
object
The date (ISO 8601).
The value.
A metric rollup.
object
The average value of the metric.
The total sum value of the metric.
The latest information.
object
The date (ISO 8601).
The value.
A metric rollup.
object
The average value of the metric.
The total sum value of the metric.
The latest information.
object
The date (ISO 8601).
The value.
A metric rollup.
object
The average value of the metric.
The total sum value of the metric.
The latest information.
object
The date (ISO 8601).
The value.
A metric rollup.
object
The average value of the metric.
The total sum value of the metric.
The latest information.
object
The date (ISO 8601).
The value.
The expected time when the storage refresh will complete for this environment
Total number of environments
Token for the next page of results
Whether all environments can be returned based on account permissions
The time when the account storage was last refreshed
The expected time when the account storage refresh will complete
Example
{ "environment_metrics": [ { "metrics": [ { "traffic_metrics_source": "TRAFFIC_METRICS_SOURCE_UNSPECIFIED" } ] } ]}Bad Request. The request was improperly formatted or contained invalid parameters.
object
A message explaining the error.
Example
{ "message": "Must provide or omit both first_date and last_date."}Authentication Error
object
A message regarding the error that occurred on the server
(Optional) A URL where documentation regarding this specific error can be found
Example
{ "message": "Bad Credentials"}Not Authorized
object
A message regarding the error that occurred on the server
(Optional) A URL where documentation regarding this specific error can be found
Example
{ "message": "You don't have permission to perform that action"}Not Found. The requested account id does not exist.
object
A message regarding the error that occurred on the server
(Optional) A URL where documentation regarding this specific error can be found
Example
{ "message": "Not Found"}Too many requests
default
Section titled “default”An unexpected error response.
object
A message regarding the error that occurred on the server
Example
{ "message": "An unexpected error occurred, please try again in a few minutes"}