This document describes the REST API endpoints provided by the NTP Pool data API server.
The API server runs on port 8030. All endpoints are accessible at:
- Production:
https://www.ntppool.org/api/... - Local development:
http://localhost:8030/api/...
All API responses include:
Server: Version information (e.g.,data-api/1.2.3+abc123)Cache-Control: Caching directivesAccess-Control-Allow-Origin: CORS configuration
GET /api/usercc
Returns DNS query statistics by user country code and NTP pool zone statistics.
{
"UserCountry": [
{
"CC": "us",
"IPv4": 42.5,
"IPv6": 12.3
}
],
"ZoneStats": {
"zones": [
{
"zone_name": "us",
"netspeed_active": 1000,
"server_count": 450
}
]
}
}UserCountry: Array of country statisticsCC: Two-letter country codeIPv4: IPv4 query percentageIPv6: IPv6 query percentage
ZoneStats: NTP pool zone information
Cache-Control: Varies based on data freshness
GET /api/dns/counts
Returns aggregated DNS query counts from ClickHouse analytics.
{
"total_queries": 1234567,
"by_country": {
"us": 456789,
"de": 234567
},
"by_query_type": {
"A": 987654,
"AAAA": 345678
}
}Cache-Control:s-maxage=30,max-age=60
GET /api/server/dns/answers/{server} (by client country)
GET /api/server/dns/answers/zone/{server} (by answering zone)
Returns DNS answer statistics for a specific NTP server, in one of two formats picked by the path. A client can also tell them apart by the top-level key: Server in the first, Zones in the second.
A request with a query string, or with the IP not written in its canonical form, is redirected (308) to the canonical URL on www.ntppool.org.
server: Server IP address (IPv4 or IPv6)
{
"Server": [
{
"CC": "us",
"Count": 12345,
"Points": 1234.5,
"Netspeed": 567.8
}
],
"PointSymbol": "‱"
}Server: Array of country-specific statisticsCC: Country code where DNS queries originatedCount: Number of DNS answers servedPoints: Calculated scoring points (basis: 10,000)Netspeed: Network speed score relative to zone capacity
PointSymbol: Symbol used for point calculations ("‱" = per 10,000)
{
"Global": { "Count": 123456, "Points": 1.23 },
"Zones": [
{ "Zone": "dk", "Count": 98765, "Points": 45.6, "Netspeed": 44.1 }
],
"PointSymbol": "‱"
}The numbers cover a fixed 72-hour window ending at the last 5-minute boundary (UTC). Answers are counted for the query type that matches the server's IP version (A for IPv4, AAAA for IPv6).
GlobalCount: All the server's answers of the query type, from every zone, including zones it has since leftPoints:Countas a share of all answers of the query type (basis: 10,000)
Zones: One entry per current zone of the server, sorted byCount, largest first, except the global zone@(Globalcovers all of the server's answers) and zones that don't answer DNS queries. A zone the server got no answers from is included withCountandPoints0, so itsNetspeedcan be compared against them. Empty ([]) for a server in no other zone.Zone: Zone name, a country (dk) or a continent (europe)Count: The server's answers from the zonePoints:Countas a share of all answers from the zone (basis: 10,000)Netspeed: The share the server's netspeed history leads us to expect, using the server's and the zone's netspeed in each 5-minute bucket (basis: 10,000). Left out when the zone has no netspeed history in the window.
PointSymbol: Symbol used for point calculations ("‱" = per 10,000)
400 Bad Request: Invalid server IP format404 Not Found: Server not found500 Internal Server Error: Database error
- Success:
public,max-age=1800 - Errors:
public,max-age=300
Redirects to canonical IP format with 308 Permanent Redirect if:
- IP format is not canonical
- Query parameters are present
GET /api/server/scores/{server}/{mode}
server: Server IP address or IDmode: Response format (jsonorlog)
limit: Maximum number of records (default: 100, max: 10000)monitor: Monitor ID or name prefix (default: "recentmedian.scores.ntp.dev")- Use
*for all monitors - Use monitor ID number
- Use monitor name prefix (e.g., "recentmedian")
- Use
since: Unix timestamp for start timesource: Data source (mfor PostgreSQL,cfor ClickHouse)full_history: Include full history (private IPs only)
{
"history": [
{
"ts": 1640995200,
"offset": 0.001234,
"step": 0.5,
"score": 20.0,
"monitor_id": 123,
"rtt": 45.6
}
],
"monitors": [
{
"id": 123,
"name": "recentmedian.scores.ntp.dev",
"type": "monitor",
"ts": "2022-01-01T12:00:00Z",
"score": 19.5,
"status": "active",
"avg_rtt": 45.2
}
],
"server": {
"ip": "192.0.2.1"
}
}monitors has one entry per monitor in history, sorted by id.
type:monitororscore. For a monitor ID with no monitor record (which shouldn't happen),nameis the ID andtypeis"".ts,score,status: the monitor's current values for the server, not values for the requested window. All three arenullwhen the monitor no longer has an assignment for the server.statusis one ofactive,testing,candidate,reserveorpaused(when notnull).reserveis a monitor that isn't currently a candidate for the server and gets no work from it.avg_rtt: average RTT in milliseconds over the returnedhistory; omitted when there is no RTT data for the monitor.
Returns CSV data with headers:
ts_epoch,ts,offset,step,score,monitor_id,monitor_name,rtt,leap,error
1640995200,2022-01-01 12:00:00,0.001234,0.5,20.0,123,recentmedian.scores.ntp.dev,45.6,,
ts_epoch: Unix timestampts: Human-readable timestampoffset: Time offset in secondsstep: NTP step valuescore: Computed scoremonitor_id: Monitor identifiermonitor_name: Monitor display namertt: Round-trip time in millisecondsleap: Leap second indicatorerror: Error message (sanitized for CSV)
404 Not Found: Invalid mode, server not found, or monitor not found500 Internal Server Error: Database error
Dynamic based on data freshness:
- Recent data:
s-maxage=90,max-age=120 - Older data:
s-maxage=260,max-age=360
GET /api/zone/counts/{zone_name}
Returns historical server count and network capacity data for an NTP pool zone.
zone_name: Zone name (e.g., "us", "europe", "@" for global)
limit: Maximum number of date entries to return
{
"history": [
{
"d": "2022-01-01",
"ts": 1640995200,
"rc": 450,
"ac": 380,
"w": 12500,
"iv": "v4"
}
]
}history: Array of historical data pointsd: Date in YYYY-MM-DD formatts: Unix timestamprc: Registered server countac: Active server countw: Network capacity (netspeed active)iv: IP version ("v4" or "v6")
When limit is specified, the API intelligently samples data points to provide representative historical coverage while staying within the limit.
404 Not Found: Zone not found500 Internal Server Error: Database error
s-maxage=28800, max-age=7200
GET /graph/{server}/{type}
Returns generated graph images for server visualization.
server: Server IP addresstype: Graph type (currently only "offset.png" supported)
- Content-Type:
image/pngor upstream service content type - Body: Binary image data
- Canonical URL enforcement (redirects if server IP format is non-canonical)
- Query parameter removal (redirects to clean URLs)
- Upstream service integration via HTTP proxy
404 Not Found: Invalid image type or server not found500 Internal Server Error: Upstream service error
- Success:
public,max-age=1800,s-maxage=1350 - Errors:
public,max-age=240
GET /api/v2/server/scores/{server}/{mode}
🆕 Recommended API - Returns historical scoring data for an NTP server in Grafana-compatible table format with enhanced time range support and relative time expressions.
server: Server IP address or IDmode: Response format (jsononly)
from: Start time (required) - Unix timestamp or relative time (e.g., "-3d", "-2h", "-30m")to: End time (required) - Unix timestamp or relative time (e.g., "-1d", "-1h", "0s")maxDataPoints: Maximum data points to return (default: 50000, max: 50000)monitor: Monitor filter (ID, name prefix, or "*" for all monitors)interval: Future downsampling interval (not implemented)
The v2 API supports both Unix timestamps and relative time expressions:
Unix Timestamps:
from=1753500964&to=1753587364- Standard Unix seconds
Relative Time Expressions:
from=-3d&to=-1d- From 3 days ago to 1 day agofrom=-2h&to=-30m- From 2 hours ago to 30 minutes agofrom=-1d&to=0s- From 1 day ago to now
Supported Units:
s- secondsm- minutesh- hoursd- days
Format: [-]<number><unit> (negative sign for past, no sign for future)
Grafana table format optimized for visualization:
[
{
"target": "monitor{name=zakim1-yfhw4a}",
"tags": {
"monitor_id": "126",
"monitor_name": "zakim1-yfhw4a",
"type": "monitor",
"status": "active"
},
"columns": [
{"text": "time", "type": "time"},
{"text": "score", "type": "number"},
{"text": "rtt", "type": "number", "unit": "ms"},
{"text": "offset", "type": "number", "unit": "s"}
],
"values": [
[1753431667000, 20.0, 18.865, -0.000267],
[1753431419000, 20.0, 18.96, -0.000390],
[1753431151000, 20.0, 18.073, -0.000768]
]
}
]- One series per monitor: Efficient grouping by monitor ID
- Table format: All metrics (time, score, rtt, offset) in columns
- Timestamps: Converted to milliseconds for Grafana compatibility
- Null handling: Null RTT/offset values preserved as
null
- Data points: Maximum 50,000 records per request
- Time range: Maximum 90 days per request
- Minimum range: 1 second
- Data source: ClickHouse only (for better time range performance)
Recent data with relative times:
GET /api/v2/server/scores/192.0.2.1/json?from=-3d&to=-1h&monitor=*
Specific time range:
GET /api/v2/server/scores/192.0.2.1/json?from=1753500000&to=1753586400&monitor=recentmedian
All monitors, last 24 hours:
GET /api/v2/server/scores/192.0.2.1/json?from=-1d&to=0s&monitor=*&maxDataPoints=10000
400 Bad Request: Invalid time format, range too large/small, or invalid parameters404 Not Found: Server not found, invalid mode, or monitor not found500 Internal Server Error: Database or internal error
Dynamic caching based on data characteristics:
- Recent data:
s-maxage=90,max-age=120 - Older data:
s-maxage=260,max-age=360 - Empty results:
s-maxage=260,max-age=360
The v2 API offers significant improvements over /api/server/scores/{server}/{mode}:
| Feature | Legacy API | v2 API |
|---|---|---|
| Record limit | 10,000 | 50,000 |
| Time format | Unix timestamps only | Unix timestamps + relative time |
| Response format | Legacy JSON/CSV | Grafana table format |
| Time range | Limited by since parameter |
Full from/to range support |
| Maximum range | No explicit limit | 90 days |
| Performance | MySQL + ClickHouse | ClickHouse optimized |
To migrate from legacy API to v2:
Legacy:
/api/server/scores/192.0.2.1/json?limit=10000&since=1753500000&monitor=*
V2 equivalent:
/api/v2/server/scores/192.0.2.1/json?from=1753500000&to=0s&monitor=*&maxDataPoints=10000
V2 with relative time:
/api/v2/server/scores/192.0.2.1/json?from=-3d&to=-1h&monitor=*
- GET
/api/vendor/dns/queries/{zone}: queries per 5-minute or 1-hour window - GET
/api/vendor/dns/summary/{zone}: totals and peaks for the last 7, 30, 365 and 1095 days
Through the website: https://www.ntppool.org/api/data/vendor/dns/....
These routes exist only when DATA_API_TOKEN_ISSUER and DATA_API_TOKEN_JWKS_URL are both set (the production deployment); otherwise they are a 404. Setting only one, or a value that isn't an https URL, stops the server at startup.
Send a data token from ntp/api: Authorization: Bearer <JWT>. The token is an RFC 9068 access token (typ: at+jwt or application/at+jwt) from the configured issuer, signed with ES384 or RS256, with a kid header. It needs aud data-api, scope data:read, and sub, client_id, jti, iat and exp. There is no clock leeway: exp must be in the future and after iat, and iat may be at most 15 seconds in the future.
Keys come from the JWKS URL, refetched every 5 minutes and when a token names an unknown kid (at most every 10 seconds). A key in the set that can't verify tokens (for example a symmetric key) is skipped.
A caller may read a zone when the token has the vendor_admin role, or a vendor_zone grant for the zone's FQDN. A grant holder gets no data from before the grant's since; vendor_admin reads are not limited.
zone: a bare label (examplecorp, meaningexamplecorp.pool.ntp.org) or an FQDN (examplecorp.pool.ntp.org). ASCII case and one trailing dot are ignored. The label is 3–63 characters ofa-z,0-9and-. Numbered names (2.examplecorp.pool.ntp.org) are a 400; their queries are counted in the bare name's series.
from,to: Unix seconds or relative time (-7d,-24h), as for the v2 score history. Relative times count from now, not fromto; a value without a sign (1h) is in the future. Defaults:to= now,from=to− 24h.frommust be beforetoand before now, and not before 2000-01-01.step:5m(range up to 7 days) or1h(up to 366 days). Default5mfor ranges up to 48 hours, else1h.
from is rounded down and to up to the step; a to in the future is clamped to now. Windows are [from, to).
{
"zone": "examplecorp.pool.ntp.org",
"step": "5m",
"from": "2026-11-23T00:00:00Z",
"to": "2026-11-24T00:00:00Z",
"points": [
{"ts": "2026-11-23T00:00:00Z", "queries": 123456, "peak_qps": 980, "p95_qps": 702},
{"ts": "2026-11-23T23:55:00Z", "queries": 40211, "peak_qps": null, "p95_qps": null}
]
}fromis the effective start, after thesincelimit.tsis the window start.- Windows without queries are left out; an unknown zone and a zone without traffic both give
"points": []. peak_qps(highest queries in one second) andp95_qpsare filled by an hourly refresh; until then they arenull.
{
"zone": "examplecorp.pool.ntp.org",
"to": "2026-11-26T08:00:00Z",
"periods": [
{"period": "7d", "from": "2026-11-19T08:00:00Z", "queries": 10450000,
"avg_qps": 17.278439153439153, "peak_qps": 980, "peak_at": "2026-11-20T14:00:00Z",
"max_p95_qps": 702}
]
}tois the start of the current hour. Periods:7d,30d,365d,1095d.avg_qpsisqueriesdivided by the seconds in[from, to), not rounded: one query in 1095 days is1.0569930661254863e-8.peak_atis the start of the hour with the highest peak;max_p95_qpsis the highest hourly 95th percentile.peak_qps,peak_atandmax_p95_qpsarenullwhen no hour in the period has a peak yet.- A period's
fromis no earlier than the zone's first hour with queries, in all the data, not only the period. For a zone with a shorter history,avg_qpsis over the hours since its traffic started, and hours without queries after that count as zero. A zone with no queries keeps the full periods. - For a grant holder, a period's
fromis also no earlier thansince(rounded up to the hour). A period that then starts at or aftertohasqueries: 0andavg_qps: null.
Checked in this order:
401 Unauthorized: missing, invalid or expired token;WWW-Authenticate: Bearer error="invalid_token"503 Service Unavailable: the server hasn't loaded the signing keys yet400 Bad Request: invalidzone,from,to,stepor range403 Forbidden: the token doesn't cover the zone;WWW-Authenticate: Bearer error="insufficient_scope"404 Not Found: no DNS data for the zone's root (onlypool.ntp.orghas data)500 Internal Server Error:{"message": "internal error"}
Error bodies are {"message": "..."}.
Cache-Control: private, no-storeon every response, errors included.
Authorization is an allowed request header for the CORS origins, and preflight responses can be cached for 7,200 seconds (Access-Control-Max-Age).
GET :9019/health
Returns server health status by testing database connections.
reset: Boolean to reset database connection pool
200 OK: "ok" - All systems healthy503 Service Unavailable: "db ping err" - Database connectivity issues
GET :9020/metrics
Prometheus metrics endpoint for monitoring and observability.
200 OK: Successful request308 Permanent Redirect: URL canonicalization400 Bad Request: Invalid request parameters401 Unauthorized: Missing or invalid token (vendor DNS endpoints)403 Forbidden: Token doesn't cover the resource (vendor DNS endpoints)404 Not Found: Resource not found500 Internal Server Error: Server-side error503 Service Unavailable: Service temporarily unavailable
Most endpoints return plain text error messages for non-2xx responses. Some endpoints may return JSON error objects.
The API integrates multiple data sources:
- MySQL: Operational data (servers, zones, accounts, current scores)
- ClickHouse: Analytics data (DNS query logs, historical scoring data)
Different endpoints may use different data sources, and some endpoints allow source selection via query parameters.
The API implements extensive caching at multiple levels:
- Response-level caching: Each endpoint sets appropriate
Cache-Controlheaders - Database query optimization: Efficient queries with proper indexing
- CDN integration: Headers configured for CDN caching
Cache durations vary by endpoint and data freshness, ranging from 30 seconds for real-time data to 8 hours for historical data.