itemadapter
Common interface for data container classes
What it is and what it does
ItemAdapter is a wrapper class that normalizes access to different data container types—dicts, dataclasses, attrs objects, pydantic models, and Scrapy items—under a single dict-like interface. You wrap an object in ItemAdapter and then read, modify, and query it using standard dictionary operations (indexing, get, update, len) regardless of whether the underlying object is a plain dict, a dataclass, or a Scrapy Item.
The package is designed for code that needs to handle multiple container types uniformly, particularly in data pipelines and web scraping workflows. It implements Python's MutableMapping protocol, so adapters feel like dictionaries. It also provides utility methods like asdict() for recursive conversion to plain dicts, and class-level methods to inspect field names and metadata from item classes before instantiation.
Use it for:
- Normalize access to Scrapy items and plain dicts in a single pipeline without type-checking branches.
- Build generic data transformation code that works with dataclasses, attrs, or pydantic models interchangeably.
- Extract and convert nested item structures to plain dicts for JSON serialization or logging.
- Inspect field metadata and names from dataclass or pydantic models at runtime for validation or schema generation.
- Write middleware or utilities that accept multiple item types and treat them uniformly.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
ItemAdapter wraps data container objects (dicts, dataclasses, attrs, pydantic, Scrapy items) to provide a uniform dict-like interface for reading and modifying them regardless of their underlying type.
Yes. ItemAdapter is actively maintained, has no runtime dependencies, installs with low friction, carries no security vulnerabilities, and solves a real problem for anyone working with multiple data container types. It's particularly valuable in Scrapy projects but useful anywhere you need a uniform interface across dicts, dataclasses, attrs, and pydantic models.
Install
itemadapter on PyPI
pip
pip install itemadapteruv
uv add itemadapterpoetry
poetry add itemadapterInstalling itemadapter
Before you install
Low friction: pure Python wheel with no runtime dependencies. Actively maintained with recent commits; last release 218 days ago.
License in practice
BSD-3-Clause is permissive; you can use, modify, and distribute this package freely in commercial and open-source projects with minimal restrictions.
Quickstart
from dataclasses import dataclass
from itemadapter import ItemAdapter
@dataclass
class Item:
name: str
price: float
obj = Item(name='foo', price=20.5)
adapter = ItemAdapter(obj)
adapter['name'] = 'bar'
print(adapter.asdict())
Requires Python 3.9+; optional dependencies (scrapy, attrs, pydantic) needed only if working with those specific item types.
Verify before relying
- Whether the package is actively used in production Scrapy pipelines or primarily in standalone data-handling contexts.
- Performance characteristics when adapting deeply nested or large item structures.
Package facts
| License | BSD-3-Clause (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 218 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,948,020/month — #2,812 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: itemadapter-0.13.1-py3-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
itemloadersItemloaders extracts and standardizes…
permissive · top 5,000 on PyPI
dataclass-factoryConverts dataclasses to and from dictionaries…
permissive · top 15,000 on PyPI
adaptixAdaptix converts between data models,…
permissive · top 15,000 on PyPI
jax-dataclassesProvides a JAX-compatible wrapper around Python…
permissive · top 15,000 on PyPI
databind.jsonDeserializes and serializes Python dataclasses…
permissive · top 15,000 on PyPI
databindDatabind deserializes JSON-like nested data…
permissive · top 15,000 on PyPI
databind.coreDeserializes and serializes Python dataclasses…
permissive · top 15,000 on PyPI
serpyco-rsSerializes and deserializes Python dataclasses…
permissive · top 15,000 on PyPI
dataclass-wizardDataclass Wizard converts Python dataclasses to…
permissive · top 5,000 on PyPI
pyserdeSerialize and deserialize Python dataclasses to…
permissive · top 5,000 on PyPI