simple-nfc-tag
A tag-agnostic NFC data storage library built on PC/SC, abstracting away reader, tag and protocol details.
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_AUTHand 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=9000on an NTAG - Typed:
py.typed, no bareexcept, every non-90 00answer raisesApduError
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
554279b2e3b142ba2091fcf03bbd5337619c28bb104b652cf9b98026911fc11e
|
|
| MD5 |
8d8601880a1cefa84f95733e3ae92228
|
|
| BLAKE2b-256 |
07c9a2ac43cdb8581245dcb13ffe5c3e8c005b1af7f20132871586339a80839d
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
637df3f31e7a16e594d544455ff9049602f6dd1d1545c1afe385ee5d6730824f
|
|
| MD5 |
34562373f73f047cb02ca2de35135d61
|
|
| BLAKE2b-256 |
9c5d3ecb6d70ed745245def7093039ea9c31e61314501aa2cb21ecf701b0d7af
|