{"id":26301754,"url":"https://github.com/michealroberts/ntps","last_synced_at":"2026-02-14T23:07:06.862Z","repository":{"id":281645534,"uuid":"944432931","full_name":"michealroberts/ntps","owner":"michealroberts","description":"Modern, type-safe, zero-dependency python library for implementing a network time protocol (NTP) stratum 1 server, as well as a handy NTP client handler.","archived":false,"fork":false,"pushed_at":"2025-05-28T14:19:34.000Z","size":79,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-07T09:08:07.603Z","etag":null,"topics":["network-time-protocol","ntp","ntp-client","ntp-server"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/michealroberts.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-03-07T10:36:48.000Z","updated_at":"2025-05-28T15:01:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"a72f6863-1666-495c-a367-f1ccbd13a68b","html_url":"https://github.com/michealroberts/ntps","commit_stats":null,"previous_names":["michealroberts/ntps"],"tags_count":6,"template":false,"template_full_name":"michealroberts/astral-uv-python-package-template","purl":"pkg:github/michealroberts/ntps","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michealroberts%2Fntps","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michealroberts%2Fntps/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michealroberts%2Fntps/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michealroberts%2Fntps/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michealroberts","download_url":"https://codeload.github.com/michealroberts/ntps/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michealroberts%2Fntps/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29460142,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T22:42:09.113Z","status":"ssl_error","status_checked_at":"2026-02-14T22:42:05.053Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["network-time-protocol","ntp","ntp-client","ntp-server"],"created_at":"2025-03-15T07:16:34.922Z","updated_at":"2026-02-14T23:07:06.856Z","avatar_url":"https://github.com/michealroberts.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ntps\n\nModern, type-safe, zero-dependency python library for implementing a network time protocol (NTP) stratum 0 server.\n\n## Installation\n\n```bash\npip install ntps\n```\n\nor\n\nusing your preferred environment / package manager of choice, e.g., `poetry`, `conda` or `uv`:\n\n```bash\npoetry add ntps\n```\n\n```bash\nconda install ntps\n```\n\n```bash\nuv add ntps\n```\n\n## Usage\n\nThere are two main components in the ntps library: the NTP server and the NTP client.\n\nThe NTP server is used to create an NTP server that can be used to synchronize time across a network. The NTP client is used to query an NTP server for the current time.\n\nThe following is an example of how to use the ntps library to create an NTP server and client:\n\n### Server\n\n```python\nfrom asyncio import get_running_loop, run\nfrom time import time\n\nfrom ntps import NTPServer\n\n# Define a custom NTP server that uses GPS-synced time as the reference time, and a\n# stratum level of 0:\nclass GNSSStratum0NTPServer(NTPServer):\n    # Set the reference identifier of the NTP server:\n    refid = \"GPS\"\n    # Set the stratum level of the NTP server:\n    stratum = 0\n\n    def get_ntp_time(self) -\u003e float:\n        # Replace this with your actual GPS-synced time retrieval:\n        return time()\n\n\nasync def main() -\u003e None:\n    # Retrieve the current running asynchronous event loop:\n    loop = get_running_loop()\n\n    # Create a UDP server endpoint on all interfaces at port 123 using your\n    # custom implementation (e.g., GNSSStratum0NTPServer):\n    transport, _ = await loop.create_datagram_endpoint(\n        lambda: GNSSStratum0NTPServer(),\n        local_addr=('0.0.0.0', 123),\n    )\n```\n\n### Client\n\n```python\nfrom ntps import NTPClient, NTPPacket\n\nasync def main() -\u003e None:\n    # Create a new NTP client instance:\n    client = NTPClient(endpoint=\"0.0.0.0\", port=123)\n\n    # Send an NTP request to the specified NTP server (e.g., 0.pool.ntp.org):\n    packet: NTPPacket = client.query()\n\n    # Print the response packet from the NTP server:\n    print(packet)\n```\n\nAs the ntps instance is fully typed, you can use your IDE's autocompletion to see all the available methods and properties.\n\nWe have also provided further usage examples in the [examples](./examples) directory.\n\n## Milestones\n\n- [x] Implement NTP server\n- [x] Implement NTP client\n- [x] Implement NTP packet\n- [ ] Implement kiss-of-death (KoD) packet\n- [ ] Implement NTP authentication\n- [ ] Implement NTP broadcast\n- [ ] Implement NTP multicast\n- [ ] Implement NTP symmetric mode\n\n### Miscellaneous\n\nFor more information on the NTP protocol, please refer to the [RFC 5905](https://tools.ietf.org/html/rfc5905) document.\n\n### License\n\nThis project is licensed under the terms of the MIT license.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichealroberts%2Fntps","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichealroberts%2Fntps","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichealroberts%2Fntps/lists"}