{"id":3940,"library":"coreapi","title":"Core API Python Client","description":"The `coreapi` library is a Python client for interacting with web APIs that expose Core API schemas or hypermedia formats. It supports formats like CoreJSON, OpenAPI (for schema description), JSON Hyper-Schema, and HAL. The latest stable version, 2.3.3, was released in October 2017. This library is largely considered superseded, particularly within the Django REST Framework ecosystem where its schema generation was deprecated in favor of OpenAPI.","status":"deprecated","version":"2.3.3","language":"en","source_language":"en","source_url":"https://github.com/core-api/python-client","tags":["api client","rest","schema","hypermedia","deprecated"],"install":[{"cmd":"pip install coreapi","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"While `rest_framework.schemas.coreapi.AutoSchema` existed for Django REST Framework, it is deprecated in favor of OpenAPI. The coreapi.Client is for direct client interaction, not schema generation within DRF.","wrong":"from rest_framework.schemas.coreapi import AutoSchema","symbol":"Client","correct":"from coreapi import Client"}],"quickstart":{"code":"import coreapi\nimport os\n\n# The Core API library interacts with APIs based on their exposed schema/hypermedia.\n# We'll use a public example service from coreapi.org for demonstration.\n# Replace 'http://notes.coreapi.org/' with your actual Core API endpoint.\nAPI_URL = os.environ.get('COREAPI_EXAMPLE_URL', 'http://notes.coreapi.org/')\n\ntry:\n    # 1. Create a client instance\n    client = coreapi.Client()\n\n    # 2. Retrieve the API document (schema/hypermedia description)\n    document = client.get(API_URL)\n    print(f\"Successfully retrieved API document for: {document.title}\")\n\n    # 3. Interact with the API using actions defined in the document\n    # This example assumes the 'notes' service at API_URL has a 'list' action.\n    # Adjust 'keys' and 'params' based on the specific API you are interacting with.\n    if 'notes' in document and 'list' in document['notes']:\n        print(\"\\nAttempting to list notes...\")\n        notes_list = client.action(document, ['notes', 'list'])\n        print(f\"Retrieved {len(notes_list)} notes.\")\n        for note in notes_list:\n            print(f\"- {note.get('description', 'No description')}\")\n    else:\n        print(f\"'notes' or 'list' action not found in document from {API_URL}. Cannot demonstrate interaction.\")\n\nexcept coreapi.exceptions.NetworkError as e:\n    print(f\"Error: Network issue connecting to {API_URL}. Details: {e}\")\n    print(\"Please ensure the API endpoint is correct and accessible.\")\nexcept coreapi.exceptions.ErrorMessage as e:\n    print(f\"Error: API returned an error message. Status: {e.status_code}, Detail: {e.error}\")\nexcept coreapi.exceptions.LinkLookupError as e:\n    print(f\"Error: Invalid action path. Details: {e}\")\n    print(\"Check the keys passed to client.action() match the API document structure.\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")\n","lang":"python","description":"This quickstart demonstrates how to initialize a `coreapi.Client`, fetch an API document (schema), and perform an action (like listing resources) based on the document's structure. It uses `http://notes.coreapi.org/` as an example API endpoint."},"warnings":[{"fix":"Migrate DRF schema generation to OpenAPI-based solutions. For client interaction with Core API services, continue using `coreapi` library directly, but be aware of its maintenance status.","message":"Django REST Framework (DRF) officially deprecated CoreAPI-based schema generation in version 3.10, transitioning to OpenAPI. DRF 3.12 was planned to remove CoreAPI support entirely, meaning existing DRF applications relying on `rest_framework.schemas.coreapi` will break or require migration.","severity":"breaking","affected_versions":"Django REST Framework >= 3.10"},{"fix":"Consider alternatives like `requests` with a schema validation library or clients generated from OpenAPI specifications for new projects. For existing projects, proceed with caution and be prepared to fork or maintain the library internally.","message":"The `core-api/python-client` GitHub repository is marked as 'Public archive', indicating that the project is no longer actively maintained. The last PyPI release was in October 2017. Users should be aware of potential lack of updates, bug fixes, or security patches.","severity":"deprecated","affected_versions":"All versions"},{"fix":"Explicitly pin versions of transitive dependencies like `jinja2` and `markupsafe` to older, compatible versions (e.g., `jinja2<3.1`, `markupsafe<2.1`), if these are indeed the root cause. A full resolution might require using an older Python version or avoiding `coreapi`.","message":"Users have reported compatibility problems with `coreapi` on Python 3.10 and newer versions, often stemming from indirect dependencies like `markupsafe` or `jinja2`. This can lead to import errors or runtime exceptions.","severity":"gotcha","affected_versions":"Python 3.10+"},{"fix":"Always inspect the API document retrieved by `client.get()` to understand the available actions and their required/optional parameters. Implement robust error handling (e.g., `try...except coreapi.exceptions.LinkLookupError`) for API interactions.","message":"Common runtime errors include `coreapi.exceptions.LinkLookupError` if the specified keys do not map to an existing link in the API document, and `coreapi.exceptions.ParameterError` if action parameters are missing, invalid, or do not match the API's requirements.","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"}