{"id":10123,"library":"pypi-json","title":"PyPI JSON API client","description":"pypi-json is a Python client library for accessing the PyPI JSON API. It allows programmatic retrieval of package metadata, including versions, summaries, dependencies, and more. The current version is 0.5.0.post1, and it has an infrequent but active release cadence, with the latest update in February 2026.","status":"active","version":"0.5.0.post1","language":"en","source_language":"en","source_url":"https://github.com/repo-helper/pypi-json","tags":["PyPI","API client","package management","metadata"],"install":[{"cmd":"pip install pypi-json","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Required for making HTTP requests to the PyPI API.","package":"httpx>=0.20.0"},{"reason":"Utility functions used internally by the library.","package":"domdf-python-tools"},{"reason":"Metadata parsing and handling.","package":"dist-meta"}],"imports":[{"symbol":"PyPIJSON","correct":"from pypi_json import PyPIJSON"}],"quickstart":{"code":"from pypi_json import PyPIJSON\n\npypi = PyPIJSON()\n\ntry:\n    # Example: Get metadata for the 'requests' package\n    package = pypi.get_package(\"requests\")\n    print(f\"Package Name: {package.name}\")\n    print(f\"Latest Version: {package.version}\")\n    print(f\"Summary: {package.summary}\")\n\n    # Accessing specific release information\n    if package.releases:\n        latest_release_info = package.releases[package.version]\n        print(f\"Upload Time of latest version: {latest_release_info.upload_time_iso_8601}\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to instantiate the PyPIJSON client and retrieve metadata for a specific package, such as 'requests'. It shows how to access basic package attributes and specific release information, including error handling for network or package not found issues."},"warnings":[{"fix":"Wrap calls to `pypi.get_package()` in a `try...except httpx.HTTPStatusError` block to gracefully handle non-existent packages.","message":"The `get_package` method raises an `httpx.HTTPStatusError` (specifically a 404 Not Found error) if the requested package does not exist on PyPI, rather than returning `None`. Users should implement error handling for this scenario.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Refer to the official PyPI JSON API documentation or inspect the object's available attributes (e.g., `dir(package)`) to ensure correct field access. Be prepared for schema changes in future PyPI API versions.","message":"The attributes of the returned `Package` object (and its nested objects like `Release`) directly mirror the structure of the raw PyPI JSON API response. If the PyPI API changes its schema, or if you attempt to access an attribute not present for a specific package/version, an `AttributeError` will be raised.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Verify the package name for correctness. Implement `try...except httpx.HTTPStatusError` to handle non-existent packages gracefully.","cause":"The package name provided to `get_package` does not exist on PyPI, or it is misspelled.","error":"httpx.HTTPStatusError: Client error '404 Not Found' for url 'https://pypi.org/pypi/nonexistent-package/json'"},{"fix":"Check the available attributes of the `Package` object (e.g., by printing `dir(package)`) or consult the PyPI JSON API documentation to find the correct attribute name.","cause":"You are attempting to access an attribute on the `Package` object that does not exist in the PyPI JSON API response or is misspelled.","error":"AttributeError: 'Package' object has no attribute 'some_nonexistent_field'"},{"fix":"Check your internet connection and DNS settings. Ensure no firewall is blocking access to `pypi.org`. If the issue persists, PyPI might be experiencing downtime, so try again later.","cause":"The client could not establish a network connection to PyPI. This can be due to a lack of internet connectivity, DNS resolution issues, a firewall blocking access, or PyPI being temporarily unavailable.","error":"httpx.ConnectError: [Errno 11001] getaddrinfo failed"}]}