GET /api/keyword-logs
Retrieve search keyword analytics from Netlify Blobs
Keyword Logs API Specification
This document specifies the GET /api/keyword-logs Netlify serverless function for retrieving search keyword analytics.
Overview
| Property | Value |
|---|---|
| Endpoint | GET /api/keyword-logs |
| Authentication | None (public) |
| Rate Limiting | None (Netlify default) |
| Caching | Cache-Control: no-cache |
| CORS | Access-Control-Allow-Origin: * |
| Rewrite Rule | [[redirects]] in netlify.toml: /api/keyword-logs -> /.netlify/functions/keyword-logs |
Request
Method
GET
Query Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
from | string (ISO 8601) | No | 30 days ago | Start of date range filter |
to | string (ISO 8601) | No | now | End of date range filter |
limit | number | No | 1000 | Max entries to return (range: 1-5000) |
Examples
# Recent logs (last 30 days, up to 1000)
GET /api/keyword-logs
# Last 7 days
GET /api/keyword-logs?from=2026-02-28T00:00:00Z
# Specific date range with limit
GET /api/keyword-logs?from=2026-03-01T00:00:00Z&to=2026-03-07T23:59:59Z&limit=500
Response
Success (200)
{
"logs": [
{
"keyword": "eurorack power",
"timestamp": "2026-03-07T10:30:00.000Z",
"resultCount": 5
},
{
"keyword": "ADDAC",
"timestamp": "2026-03-07T09:15:00.000Z",
"resultCount": 12
}
],
"total": 2
}
Response Fields
| Field | Type | Description |
|---|---|---|
logs | array | Array of keyword log entries, sorted by timestamp descending (newest first) |
total | number | Total number of matching entries (before limit is applied) |
Log Entry Fields
| Field | Type | Description |
|---|---|---|
keyword | string | The search query |
timestamp | string | ISO 8601 timestamp of when the search was performed |
resultCount | number | Number of search results returned |
Data Source
Keyword logs are written by the Search function as a fire-and-forget side effect of every search query. Data is stored in Netlify Blobs store keyword-logs.
Both the writer (search function) and reader (this function) use context-based getStore('keyword-logs') for automatic Netlify runtime authentication.
Viewer App
The keyword-viewer sub-package (sub-packages/keyword-viewer/) provides a web UI for browsing keyword analytics. It includes:
- Dashboard with stats, top keywords, and daily volume
- Sortable keyword list with search counts
- Falls back to mock data when the API is unreachable (local development)
Implementation
- Function:
netlify/functions/keyword-logs.ts - Storage: Netlify Blobs store
keyword-logs