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:
API Email + API Key
The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.
Example:
The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.
Example:
Accepted Permissions (at least one required)
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
]
}
}