Skip to content
Start here

List core web vital metrics trend

client.Speed.Pages.Trend(ctx, url, params) (*Trend, error)
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
ZoneID param.Field[string]

Path param: Identifier.

maxLength32
DeviceType param.Field[PageTrendParamsDeviceType]

Query param: The type of device.

const PageTrendParamsDeviceTypeDesktop PageTrendParamsDeviceType = "DESKTOP"
const PageTrendParamsDeviceTypeMobile PageTrendParamsDeviceType = "MOBILE"
Metrics param.Field[string]

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

Region param.Field[PageTrendParamsRegion]

Query param: A test region.

const PageTrendParamsRegionAsiaEast1 PageTrendParamsRegion = "asia-east1"
const PageTrendParamsRegionAsiaNortheast1 PageTrendParamsRegion = "asia-northeast1"
const PageTrendParamsRegionAsiaNortheast2 PageTrendParamsRegion = "asia-northeast2"
const PageTrendParamsRegionAsiaSouth1 PageTrendParamsRegion = "asia-south1"
const PageTrendParamsRegionAsiaSoutheast1 PageTrendParamsRegion = "asia-southeast1"
const PageTrendParamsRegionAustraliaSoutheast1 PageTrendParamsRegion = "australia-southeast1"
const PageTrendParamsRegionEuropeNorth1 PageTrendParamsRegion = "europe-north1"
const PageTrendParamsRegionEuropeSouthwest1 PageTrendParamsRegion = "europe-southwest1"
const PageTrendParamsRegionEuropeWest1 PageTrendParamsRegion = "europe-west1"
const PageTrendParamsRegionEuropeWest2 PageTrendParamsRegion = "europe-west2"
const PageTrendParamsRegionEuropeWest3 PageTrendParamsRegion = "europe-west3"
const PageTrendParamsRegionEuropeWest4 PageTrendParamsRegion = "europe-west4"
const PageTrendParamsRegionEuropeWest8 PageTrendParamsRegion = "europe-west8"
const PageTrendParamsRegionEuropeWest9 PageTrendParamsRegion = "europe-west9"
const PageTrendParamsRegionMeWest1 PageTrendParamsRegion = "me-west1"
const PageTrendParamsRegionSouthamericaEast1 PageTrendParamsRegion = "southamerica-east1"
const PageTrendParamsRegionUsCentral1 PageTrendParamsRegion = "us-central1"
const PageTrendParamsRegionUsEast1 PageTrendParamsRegion = "us-east1"
const PageTrendParamsRegionUsEast4 PageTrendParamsRegion = "us-east4"
const PageTrendParamsRegionUsSouth1 PageTrendParamsRegion = "us-south1"
const PageTrendParamsRegionUsWest1 PageTrendParamsRegion = "us-west1"
Start param.Field[Time]

Query param

formatdate-time
Tz param.Field[string]

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

End param.Field[Time]optional

Query param

formatdate-time
ReturnsExpand Collapse
type Trend struct{…}
CLS []float64optional

Cumulative Layout Shift trend.

FCP []float64optional

First Contentful Paint trend.

LCP []float64optional

Largest Contentful Paint trend.

PerformanceScore []float64optional

The Lighthouse score trend.

Si []float64optional

Speed Index trend.

TBT []float64optional

Total Blocking Time trend.

TTFB []float64optional

Time To First Byte trend.

TTI []float64optional

Time To Interactive trend.

List core web vital metrics trend

package main

import (
  "context"
  "fmt"
  "time"

  "github.com/cloudflare/cloudflare-go"
  "github.com/cloudflare/cloudflare-go/option"
  "github.com/cloudflare/cloudflare-go/speed"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  trend, err := client.Speed.Pages.Trend(
    context.TODO(),
    "example.com",
    speed.PageTrendParams{
      ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
      DeviceType: cloudflare.F(speed.PageTrendParamsDeviceTypeDesktop),
      Metrics: cloudflare.F("performanceScore,ttfb,fcp,si,lcp,tti,tbt,cls"),
      Region: cloudflare.F(speed.PageTrendParamsRegionUsCentral1),
      Start: cloudflare.F(time.Now()),
      Tz: cloudflare.F("tz"),
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", 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
    ]
  }
}