Skip to content
Start here

List core web vital metrics trend

client.speed.pages.trend(stringurl, PageTrendParams { zone_id, deviceType, metrics, 4 more } params, RequestOptionsoptions?): Trend { cls, fcp, lcp, 5 more }
GET/zones/{zone_id}/speed_api/pages/{url}/trend

Lists the core web vital metrics trend over time for a specific page.

Security
API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
Accepted Permissions (at least one required)
Zone Settings WriteZone Settings Read
ParametersExpand Collapse
url: string

A URL.

params: PageTrendParams { zone_id, deviceType, metrics, 4 more }
zone_id: string

Path param: Identifier.

maxLength32
deviceType: "DESKTOP" | "MOBILE"

Query param: The type of device.

One of the following:
"DESKTOP"
"MOBILE"
metrics: string

Query param: A comma-separated list of metrics to include in the results.

region: "asia-east1" | "asia-northeast1" | "asia-northeast2" | 18 more

Query param: A test region.

One of the following:
"asia-east1"
"asia-northeast1"
"asia-northeast2"
"asia-south1"
"asia-southeast1"
"australia-southeast1"
"europe-north1"
"europe-southwest1"
"europe-west1"
"europe-west2"
"europe-west3"
"europe-west4"
"europe-west8"
"europe-west9"
"me-west1"
"southamerica-east1"
"us-central1"
"us-east1"
"us-east4"
"us-south1"
"us-west1"
start: string

Query param

formatdate-time
tz: string

Query param: The timezone of the start and end timestamps.

end?: string

Query param

formatdate-time
ReturnsExpand Collapse
Trend { cls, fcp, lcp, 5 more }
cls?: Array<number | null>

Cumulative Layout Shift trend.

fcp?: Array<number | null>

First Contentful Paint trend.

lcp?: Array<number | null>

Largest Contentful Paint trend.

performanceScore?: Array<number | null>

The Lighthouse score trend.

si?: Array<number | null>

Speed Index trend.

tbt?: Array<number | null>

Total Blocking Time trend.

ttfb?: Array<number | null>

Time To First Byte trend.

tti?: Array<number | null>

Time To Interactive trend.

List core web vital metrics trend

import Cloudflare from 'cloudflare';

const client = new Cloudflare({
  apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});

const trend = await client.speed.pages.trend('example.com', {
  zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
  deviceType: 'DESKTOP',
  metrics: 'performanceScore,ttfb,fcp,si,lcp,tti,tbt,cls',
  region: 'us-central1',
  start: '2014-01-01T05:20:00.12345Z',
  tz: 'tz',
});

console.log(trend.cls);
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "success": true,
  "result": {
    "cls": [
      0
    ],
    "fcp": [
      0
    ],
    "lcp": [
      0
    ],
    "performanceScore": [
      0
    ],
    "si": [
      0
    ],
    "tbt": [
      0
    ],
    "ttfb": [
      0
    ],
    "tti": [
      0
    ]
  }
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "success": true,
  "result": {
    "cls": [
      0
    ],
    "fcp": [
      0
    ],
    "lcp": [
      0
    ],
    "performanceScore": [
      0
    ],
    "si": [
      0
    ],
    "tbt": [
      0
    ],
    "ttfb": [
      0
    ],
    "tti": [
      0
    ]
  }
}