skillfed

itemadapter

Common interface for data container classes

itemadapter v0.13.1 2.9M downloads/30d#2,812 on PyPI69
Permissive license BSD-3-Clause Active released

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 itemadapter

uv

uv add itemadapter

poetry

poetry add itemadapter

Installing 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

Development Status :: 3 - AlphaFramework :: ScrapyIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Internet :: WWW/HTTPTopic :: Software Development :: Libraries :: Application FrameworksTopic :: Software Development :: Libraries :: Python Modules

Tags

uniform interface for data containersdict-like wrapper for dataclassesscrapy item adapterabstract data container accessmulti-type object wrapperdataclass dict interfacepydantic attrs dict wrapper
data-container-abstractionscrapy-integrationdataclass-wrapper

More Python Modules packages