Skip to main content

simple-nfc-tag

simple-nfc-tag banner

A tag-agnostic NFC data storage library built on PC/SC, abstracting away reader, tag and protocol details.

CI PyPI version Python versions License: MIT

This package is still experimental. Read and write are verified against real hardware (ACR122U, NTAG213, MIFARE Classic 1K), but the API and the data layout written to tags can still change between releases.

Install

uv add simple-nfc-tag
pip install simple-nfc-tag

Python 3.10+. Depends on pyscard. No driver swap: uses the PC/SC stack already present on Windows and macOS, and pcscd on Linux.

Usage

import simple_nfc_tag as snt

with snt.connect() as reader:
    tag = reader.wait_for_tag(timeout=5)
    print(tag.uid.hex(), tag.product, tag.user_size)

    tag.write(["ABC123", 42])   # values in
    print(tag.read())           # -> ["ABC123", 42]

Same code against a Classic 1K and an NTAG216. Sector trailers, page-granularity read-modify-write, Classic authentication and payload framing are handled internally.

Values are typed automatically: str, int, float, bool, bytes, anything else as JSON. read() with no format= detects what is on the tag.

Features

  • Readers: generic PC/SC, ACR122U (buzzer, LED, PN532 passthrough), in-memory fake
  • Tags: MIFARE Classic 1K/4K, Ultralight, NTAG213/215/216, identified automatically
  • Formats: compact TLV of typed values, and raw bytes
  • Auth: MIFARE Classic keys and trailers, NTAG21x PWD_AUTH and password setting
  • Monitor: background thread with per-UID debounce, blocking in the PC/SC driver
  • Write verification: on by default; a refused write reports SW=9000 on an NTAG
  • Typed: py.typed, no bare except, every non-90 00 answer raises ApduError

vs nfcpy

simple-nfc-tag nfcpy
Transport PC/SC libusb or serial, direct to the chip
Readers any PC/SC reader a fixed device list: PN531/PN532/PN533, RC-S956, Port100
ACR122U primary target, verified supported, but "it is not recommended to buy this device for use with nfcpy"
Tags MIFARE Classic 1K/4K, Ultralight, NTAG213/215/216 NFC Forum Type 1-4
API level values (write([...]) / read()) NDEF records, protocol operations
Tag differences hidden exposed per tag type
Scope storage on tags + peer-to-peer, card emulation, connection handover

Use nfcpy for NFC protocol work. Use this to store data.

Testing without hardware

from simple_nfc_tag.readers.fake import FakeReader, FakeNTAG213

reader = FakeReader(FakeNTAG213())
tag = reader.wait_for_tag()
tag.write(["ABC123", 42])
assert tag.read() == ["ABC123", 42]

The images reproduce the awkward parts: 4-page reads that wrap at end of memory, 63 00 past the last page, Classic sectors silent until authenticated, and a tag that stops answering after refusing a command.

Docs

  • USAGE.md: monitors, Classic keys and trailers, NTAG passwords, raw bytes, custom codecs, errors
  • examples/: roundtrip.py (manual hardware check), monitor.py, classic_keys.py

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simple_nfc_tag-0.1.0.tar.gz (46.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simple_nfc_tag-0.1.0-py3-none-any.whl (57.3 kB view details)

Uploaded Python 3

File details

Details for the file simple_nfc_tag-0.1.0.tar.gz.

File metadata

  • Download URL: simple_nfc_tag-0.1.0.tar.gz
  • Upload date:
  • Size: 46.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for simple_nfc_tag-0.1.0.tar.gz
Algorithm Hash digest
SHA256 554279b2e3b142ba2091fcf03bbd5337619c28bb104b652cf9b98026911fc11e
MD5 8d8601880a1cefa84f95733e3ae92228
BLAKE2b-256 07c9a2ac43cdb8581245dcb13ffe5c3e8c005b1af7f20132871586339a80839d

See more details on using hashes here.

File details

Details for the file simple_nfc_tag-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: simple_nfc_tag-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 57.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for simple_nfc_tag-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 637df3f31e7a16e594d544455ff9049602f6dd1d1545c1afe385ee5d6730824f
MD5 34562373f73f047cb02ca2de35135d61
BLAKE2b-256 9c5d3ecb6d70ed745245def7093039ea9c31e61314501aa2cb21ecf701b0d7af

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page