jsonapi-requests

raw JSON →
0.8.0 verified Fri May 01 auth: no python

A Python client implementation for JSON API (http://jsonapi.org/) specifications. Version 0.8.0 supports only Python >=3.9. Follows the JSON API standard for building API clients. Release cadence is low; maintainer activity is sparse.

pip install jsonapi-requests
error ModuleNotFoundError: No module named 'jsonapi_requests'
cause Import typo: using dashes instead of underscores.
fix
Use import jsonapi_requests (underscore).
error AttributeError: module 'jsonapi_requests' has no attribute 'Api'
cause Importing submodule directly instead of package root.
fix
Use from jsonapi_requests import Api.
error jsonapi_requests.exceptions.InvalidConfigurationException: api_url is required
cause Api.config() called without 'api_url' key.
fix
Set 'api_url': 'https://...' in the config dictionary.
gotcha The library uses synchronous requests (requests library). It does not support async/await natively. Blocking I/O can be an issue in async applications.
fix Wrap calls in async executor or use a different async-compatible JSON API client.
deprecated Methods like `get_object` and `get_list` on the Api object are deprecated in favor of using JsonApiObject and JsonApiList statically.
fix Use `JsonApiObject.from_api(api, id, type)` and `JsonApiList.from_api(api, type)` instead.
breaking Python 3.8 and below are no longer supported. Requires Python >=3.9.
fix Upgrade Python to 3.9+.

Initializes the API client and fetches a JSON API resource. Replace api_url and id with actual values.

from jsonapi_requests import Api, JsonApiObject

api = Api.config({
    'api_url': 'https://example.com/api',
    'auth': ('user', 'pass')  # optional
})
# Example: fetch a single resource
object = JsonApiObject.from_api(api, id='1', type='articles')
print(object.attributes)