{"id":4332,"library":"yarg","title":"yarg: PyPI Client","description":"Yarg is a Python client library designed for programmatically querying the Python Package Index (PyPI). Built on top of the `requests` library, it offers a straightforward interface to retrieve package metadata, including release details, and interact with PyPI's RSS feeds for discovering new and recently updated packages. The current version, 0.1.10, was released in August 2024 primarily for Python 3.12 compatibility, indicating an infrequent release cadence focused on maintenance.","status":"maintenance","version":"0.1.10","language":"en","source_language":"en","source_url":"https://github.com/kura/yarg","tags":["PyPI","client","package management","metadata","requests"],"install":[{"cmd":"pip install yarg","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Yarg is built on top of the requests library for HTTP communication with PyPI.","package":"requests","optional":false}],"imports":[{"note":"The main entry point for all client functionality.","symbol":"yarg","correct":"import yarg"},{"symbol":"yarg.get","correct":"package = yarg.get('package_name')"},{"symbol":"yarg.newest_packages","correct":"new_packages = yarg.newest_packages()"},{"symbol":"yarg.latest_updated_packages","correct":"updated_packages = yarg.latest_updated_packages()"},{"note":"Can also be accessed directly via `yarg.HTTPError` as of 0.1.1.","symbol":"yarg.exceptions.HTTPError","correct":"from yarg.exceptions import HTTPError"}],"quickstart":{"code":"import yarg\n\ntry:\n    package = yarg.get(\"requests\")\n    print(f\"Package Name: {package.name}\")\n    print(f\"Author: {package.author.name} ({package.author.email})\")\n    print(f\"Latest Version: {package.latest_release.version}\")\nexcept yarg.exceptions.HTTPError as e:\n    print(f\"Error fetching package: {e}\")\n\nprint(\"\\n--- Newest Packages ---\")\nnewest = yarg.newest_packages()\nfor p in newest[:3]:\n    print(f\"- {p.name} ({p.version})\")","lang":"python","description":"This quickstart demonstrates how to fetch a specific package's information using `yarg.get()` and how to retrieve a list of the newest packages published to PyPI using `yarg.newest_packages()`."},"warnings":[{"fix":"Always use the exact case of the package name as registered on PyPI (e.g., `yarg.get('requests')` not `yarg.get('Requests')`).","message":"PyPI package names are case-sensitive. `yarg.get()` will return a 404 Not Found error if the casing doesn't match the official PyPI registration.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure `yarg` is updated to the latest version (0.1.10) for best compatibility, and avoid hardcoding `pypi.python.org` in `pypi_server` arguments.","message":"The PyPI domain transitioned from `pypi.python.org` to `pypi.org`. While `yarg` might handle redirects, older clients or custom `pypi_server` configurations might encounter issues if they hardcode the old domain.","severity":"deprecated","affected_versions":"<= 0.1.9 might be more susceptible, but generally affects interaction with PyPI infrastructure changes."},{"fix":"Upgrade to `yarg` version 0.1.2 or newer to ensure robustness against missing metadata fields.","message":"Older versions (pre-0.1.2) could raise `KeyError` if certain metadata fields like `home_page`, `bugtrack_url`, or `docs_url` were missing from PyPI's response for a package. This was fixed in 0.1.2.","severity":"gotcha","affected_versions":"< 0.1.2"},{"fix":"Be aware that `package.docs` might be empty for packages not on `pythonhosted.org`. Handle potential extra slashes in URLs if processing them programmatically.","message":"The `docs` attribute of a `Package` object is typically only populated for packages hosted on `pythonhosted.org`. Also, PyPI itself sometimes returns `docs_url` with an extra slash.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}