Skip to content

Conversation

champignoom
Copy link

@champignoom champignoom commented Aug 11, 2025

Add all APIs (78 in total) listed in the official doc for all NFC technologies (NfcA, NfcB, NfcF, NfcV, IsoDep, Ndef, MifareClassic, MifareUltralight, NfcBarcode, NdefFormatable).

The API call request in JSON format is passed into stdin of termux-api in the format of:

  • either {"op": "discoverTag"}
  • or {"op": "api", "class": "<CLASSNAME>", "method": "<METHODNAME>", "args": [<ARG1>, <ARG2>, ...]}

All APIs have a corresponding wrapper. The only exceptions are the static get() functions, which are combined into the corresponding connect() functions.

A new activity with NFC figure will pop up during {"op": "discoverTag"} which indicates that it's scanning for a new tag. After successfully discovering a new tag, the activity goes to background.

Command-line Examples

See termux/termux-api-package#214.

Breaking Changes

Ndef

The previously hard-coded custom commands (-r, -w, -t) for Ndef are replaced by raw API wrappers for getNdefMessage and writeNdefMessage.

Stateful helper activity

To support stateful cards, NfcAPI now takes continuous input from stdin instead of one-time input as intent extras.

Future works

  • support more data format: currently all messages with type byte[] or NdefMessage etc can only be passed and returned in hex format. It might be helpful to support more formats like base64, ascii string, NdefRecord as json dictionary, etc.

@champignoom champignoom marked this pull request as ready for review August 14, 2025 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant