skillfed

ntplib

Python NTP library

ntplib v0.4.0 1.3M downloads/30d#4,092 on PyPI82
Permissive license MIT DORMANT released

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 ntplib

uv

uv add ntplib

poetry

poetry add ntplib

Installing 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

License :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 2.7Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: System :: Networking :: Time Synchronization

Tags

ntp client library pythonnetwork time protocol querytime synchronization pythonntp server requestsystem time sync libraryntp leap indicatornetwork time offset
time-syncnetwork-protocol

More Networking packages