ntplib
Python NTP library
What it is and what it does
ntplib is a pure-Python NTP (Network Time Protocol) client that queries NTP servers and retrieves time synchronization data. It provides a simple interface to request time information from any NTP server and includes utility functions to decode NTP protocol fields—such as leap indicators, reference IDs, and mode values—into human-readable text. Because it depends only on Python's standard library, it runs on any platform with a Python interpreter.
The package is typically used to fetch accurate network time, calculate clock offset, or verify time synchronization in applications that need to know the precise time or detect clock drift. It returns structured response objects containing offset, delay, version, and other NTP metrics that applications can use directly or for logging and diagnostics.
Use it for:
- Fetch current network time and clock offset to synchronize or verify system time in applications.
- Detect and measure clock drift by querying multiple NTP servers and comparing their responses.
- Log or display NTP diagnostic information (leap warnings, reference IDs, root delay) for time-sensitive systems.
- Validate that a system's clock is synchronized within acceptable bounds before running time-critical operations.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Query NTP servers to retrieve network time synchronization data and translate NTP protocol fields into human-readable text.
Yes, if you need a lightweight, dependency-free NTP client for Python. The low install friction and permissive license make it straightforward to add. However, be aware that maintenance is dormant—the last release was in 2021 and the repository has not been updated since April 2024. If you require active support or compatibility guarantees with the latest Python versions, verify that the package works in your environment first.
Install
ntplib on PyPI
pip
pip install ntplibuv
uv add ntplibpoetry
poetry add ntplibInstalling ntplib
Before you install
Low install friction with no runtime dependencies beyond Python's standard library. Maintenance is dormant—last release was in 2021 and the repository has not been updated since April 2024, though it remains unarchived and receives occasional attention.
License in practice
MIT license permits free use, modification, and distribution with minimal restrictions, making it suitable for both open-source and commercial projects.
Quickstart
import ntplib
from time import ctime
c = ntplib.NTPClient()
response = c.request('pool.ntp.org', version=3)
print(response.offset)
print(ctime(response.tx_time))
print(ntplib.leap_to_text(response.leap))
Verify before relying
- Whether the package works reliably with modern Python versions beyond 3.9, given the last release was in 2021.
- Current compatibility with contemporary NTP server implementations and protocol changes since 2021.
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | dormant — 1,904 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,297,087/month — #4,092 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: ntplib-0.4.0-py2.py3-none-any.whl
Tags
More Networking packages
h11 is a pure-Python HTTP/1.1 protocol…
permissive · top 100 on PyPI
psutilpsutil retrieves real-time information about…
permissive · top 1,000 on PyPI
pyOpenSSLpyOpenSSL wraps OpenSSL's SSL/TLS functionality…
permissive · top 1,000 on PyPI
uvloopuvloop is a drop-in replacement for Python's…
permissive · top 1,000 on PyPI
execnetexecnet lets you spawn and communicate with…
permissive · top 1,000 on PyPI
pyzmqPyZMQ provides Python bindings for ZeroMQ…
permissive · top 1,000 on PyPI
strict-rfc3339Converts Unix timestamps to and from RFC3339…
copyleft · top 5,000 on PyPI
aniso8601Parses ISO 8601 date, time, datetime, duration,…
permissive · top 5,000 on PyPI
zhdateConverts between Chinese lunar calendar dates…
copyleft · top 15,000 on PyPI
tonyg-rfc3339Parses and formats RFC 3339 date-time strings…
unclear · top 15,000 on PyPI
astropy-iers-dataProvides IERS Earth Rotation and Leap Second…
permissive · top 5,000 on PyPI
korean-lunar-calendarConverts dates between the Korean lunar…
permissive · top 5,000 on PyPI
lunardateConverts between Gregorian (solar) and Chinese…
copyleft · top 5,000 on PyPI
pylutron-casetaA Python API for controlling Lutron Caséta…
permissive · top 15,000 on PyPI
rfc3339-validatorValidates whether a string conforms to the…
permissive · top 1,000 on PyPI
timelibParses natural-language date and time…
permissive · top 15,000 on PyPI