Pages

Get Page Trends

Returns pageviews over time for up to 50 paths and sections in one request.

GET /api/sites/:site/pages/trends

Returns a pageview time series for each requested path and section. A pageview counts toward its path and toward its section when both are requested.

Permissions: any role on the site (viewer and above). API keys need the analytics:read scope. Public sites and private links can read it without a key.

Path Parameters

Prop

Type

Query Parameters

Accepts all Common Parameters (time and filters). Time parameters are optional; omit them for all-time data.

Prop

Type

Pass at least one path or section, and at most 50 in total (each up to 2048 characters).

Response

Prop

Type

PageTrend Object

Prop

Type

Request
curl -X GET "https://app.rybbit.io/api/sites/123/pages/trends?start_date=2024-01-01&end_date=2024-01-03&time_zone=America/New_York&bucket=day&paths=%5B%22/pricing%22%5D&sections=%5B%22/docs%22%5D" \
  -H "Authorization: Bearer your_api_key_here"
Request
const response = await fetch(
  'https://app.rybbit.io/api/sites/123/pages/trends?start_date=2024-01-01&end_date=2024-01-03&time_zone=America/New_York&bucket=day&paths=%5B%22/pricing%22%5D&sections=%5B%22/docs%22%5D',
  {
    headers: {
      'Authorization': 'Bearer your_api_key_here'
    }
  }
);

const data = await response.json();
Request
import requests

response = requests.get(
    'https://app.rybbit.io/api/sites/123/pages/trends',
    params={
        'start_date': '2024-01-01',
        'end_date': '2024-01-03',
        'time_zone': 'America/New_York',
        'bucket': 'day',
        'paths': '["/pricing"]',
        'sections': '["/docs"]'
    },
    headers={
        'Authorization': 'Bearer your_api_key_here'
    }
)

data = response.json()
Request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://app.rybbit.io/api/sites/123/pages/trends?start_date=2024-01-01&end_date=2024-01-03&time_zone=America/New_York&bucket=day&paths=%5B%22/pricing%22%5D&sections=%5B%22/docs%22%5D');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer your_api_key_here'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
Request
require 'net/http'
require 'json'

uri = URI('https://app.rybbit.io/api/sites/123/pages/trends?start_date=2024-01-01&end_date=2024-01-03&time_zone=America/New_York&bucket=day&paths=%5B%22/pricing%22%5D&sections=%5B%22/docs%22%5D')
req = Net::HTTP::Get.new(uri)
req['Authorization'] = 'Bearer your_api_key_here'

res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }
data = JSON.parse(res.body)
Request
req, _ := http.NewRequest("GET", "https://app.rybbit.io/api/sites/123/pages/trends?start_date=2024-01-01&end_date=2024-01-03&time_zone=America/New_York&bucket=day&paths=%5B%22/pricing%22%5D&sections=%5B%22/docs%22%5D", nil)
req.Header.Set("Authorization", "Bearer your_api_key_here")

client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()

var data map[string]interface{}
json.NewDecoder(resp.Body).Decode(&data)
Request
let client = reqwest::Client::new();
let res = client
    .get("https://app.rybbit.io/api/sites/123/pages/trends?start_date=2024-01-01&end_date=2024-01-03&time_zone=America/New_York&bucket=day&paths=%5B%22/pricing%22%5D&sections=%5B%22/docs%22%5D")
    .header("Authorization", "Bearer your_api_key_here")
    .send()
    .await?;

let data: serde_json::Value = res.json().await?;
Request
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://app.rybbit.io/api/sites/123/pages/trends?start_date=2024-01-01&end_date=2024-01-03&time_zone=America/New_York&bucket=day&paths=%5B%22/pricing%22%5D&sections=%5B%22/docs%22%5D"))
    .header("Authorization", "Bearer your_api_key_here")
    .GET()
    .build();

HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
Request
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer your_api_key_here");

var response = await client.GetAsync("https://app.rybbit.io/api/sites/123/pages/trends?start_date=2024-01-01&end_date=2024-01-03&time_zone=America/New_York&bucket=day&paths=%5B%22/pricing%22%5D&sections=%5B%22/docs%22%5D");
var data = await response.Content.ReadAsStringAsync();
Response
{
  "data": [
    {
      "kind": "page",
      "key": "/pricing",
      "pageviews": 612,
      "series": [
        {
          "time": "2024-01-01 00:00:00",
          "pageviews": 158
        },
        {
          "time": "2024-01-02 00:00:00",
          "pageviews": 231
        },
        {
          "time": "2024-01-03 00:00:00",
          "pageviews": 223
        }
      ]
    },
    {
      "kind": "section",
      "key": "/docs",
      "pageviews": 1934,
      "series": [
        {
          "time": "2024-01-01 00:00:00",
          "pageviews": 402
        },
        {
          "time": "2024-01-02 00:00:00",
          "pageviews": 781
        },
        {
          "time": "2024-01-03 00:00:00",
          "pageviews": 751
        }
      ]
    }
  ]
}