Python module for near field communicationΒΆ

This documentation covers the ‘latest‘ version of nfcpy. There are also other versions.

The nfcpy module implements NFC Forum specifications for wireless short-range data exchange with NFC devices and tags. It is written in Python and aims to provide an easy-to-use yet powerful framework for applications integrating NFC. The source code is licensed under the EUPL and hosted at GitHub. The latest release version can be installed from PyPI with pip install -U nfcpy.

To send a web link to a smartphone:

>>> import nfc, nfc.snep, threading
>>> connected = lambda llc: threading.Thread(target=llc.run).start()
>>> uri = nfc.ndef.Message(nfc.ndef.UriRecord("http://nfcpy.org"))
>>> clf = nfc.ContactlessFrontend('usb')
>>> llc = clf.connect(llcp={'on-connect': connected})
>>> nfc.snep.SnepClient(llc).put(uri)
True
>>> clf.close()

There are also a number of Example Programs that can be used from the command line:

$ examples/beam.py send link http://nfcpy.org