Install & Compatibility
Where this runs
tested against v2.3.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.454s · 24.3MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 3.4s · import 0.378s · 25MB
22MB installed
● package 22MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Client
✓ from coreapi import Client
✗ from coreapi import Client
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.
import coreapi
import os
# The Core API library interacts with APIs based on their exposed schema/hypermedia.
# We'll use a public example service from coreapi.org for demonstration.
# Replace 'http://notes.coreapi.org/' with your actual Core API endpoint.
API_URL = os.environ.get('COREAPI_EXAMPLE_URL', 'http://notes.coreapi.org/')
try:
# 1. Create a client instance
client = coreapi.Client()
# 2. Retrieve the API document (schema/hypermedia description)
document = client.get(API_URL)
print(f"Successfully retrieved API document for: {document.title}")
# 3. Interact with the API using actions defined in the document
# This example assumes the 'notes' service at API_URL has a 'list' action.
# Adjust 'keys' and 'params' based on the specific API you are interacting with.
if 'notes' in document and 'list' in document['notes']:
print("\nAttempting to list notes...")
notes_list = client.action(document, ['notes', 'list'])
print(f"Retrieved {len(notes_list)} notes.")
for note in notes_list:
print(f"- {note.get('description', 'No description')}")
else:
print(f"'notes' or 'list' action not found in document from {API_URL}. Cannot demonstrate interaction.")
except coreapi.exceptions.NetworkError as e:
print(f"Error: Network issue connecting to {API_URL}. Details: {e}")
print("Please ensure the API endpoint is correct and accessible.")
except coreapi.exceptions.ErrorMessage as e:
print(f"Error: API returned an error message. Status: {e.status_code}, Detail: {e.error}")
except coreapi.exceptions.LinkLookupError as e:
print(f"Error: Invalid action path. Details: {e}")
print("Check the keys passed to client.action() match the API document structure.")
except Exception as e:
print(f"An unexpected error occurred: {e}")
Debug
Known issues
breakingDjango 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.fixMigrate 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.
affects: Django REST Framework >= 3.10
deprecatedThe `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.fixConsider 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.
affects: All versions
gotchaUsers 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.fixExplicitly 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`.
affects: Python 3.10+
gotchaCommon 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.fixAlways 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.
affects: All versions
Upgrade
Version history
2.3.3latest on PyPI · released Oct 5, 2017
Audit
Dependencies
No dependency data recorded yet.