Referencing
Referencing is a Python library that facilitates JSON referencing, enabling efficient handling of JSON references within Python applications. The current version is 0.37.0, released on March 28, 2026. The library maintains a regular release cadence, with updates addressing compatibility and feature enhancements.
Warnings
- breaking Dropped support for Python 3.9 in version 0.37.0.
- gotcha Ensure that schemas registered with the Registry have unique "$id" fields to avoid conflicts.
- gotcha When using references, ensure that the referenced schemas are registered in the registry to resolve them correctly.
Install
-
pip install referencing
Imports
- Registry
from referencing import Registry
- Resource
from referencing import Resource
Quickstart
from referencing import Registry, Resource
# Create a new registry
registry = Registry()
# Define a JSON schema with a reference
schema = {
"$id": "https://example.com/person.schema.json",
"type": "object",
"properties": {
"name": {"type": "string"},
"age": {"type": "integer"},
"address": {"$ref": "https://example.com/address.schema.json"}
}
}
# Register the schema
resource = Resource.from_contents(schema)
registry.register(resource)
# Retrieve the registered schema
retrieved_schema = registry.contents("https://example.com/person.schema.json")
print(retrieved_schema)