Skip to main content

Methods

Methods are used to execute actions and request data back from the API.

Launching

launch

Emulate the scanning of a token.

Parameters

Accepts two types of parameters:

  • A string, in which case the string will be treated as the token text with all other options set as default.
  • An object:
KeyTypeRequiredDescription
typestringNoAn internal category of the type of token being scanned. Not currently in use outside of logging.
uidstringNo*The UID of the token being scanned. For example, the UID of an NFC tag. Used for matching mappings.
textstringNo*The main text to be processed from a scan, should contain ZapScript.
datastringNo*The raw data read from a token, converted to a hexadecimal string. Used in mappings and detection of NFC toys.

These parameters allow emulating a token exactly as it would be read directly from an attached reader on the server. A request's parameters must contain at least a populated uid, text or data value.

Result

Returns null on success.

Currently, it is not reported if the launched ZapScript encountered an error during launching, and the method will return before execution of ZapScript is complete.

Example

Request
{
"jsonrpc": "2.0",
"id": "52f6242e-7a5a-11ef-bf93-020304050607",
"method": "launch",
"params": {
"text": "**launch.system:snes"
}
}
Response
{
"jsonrpc": "2.0",
"id": "52f6242e-7a5a-11ef-bf93-020304050607",
"result": null
}

stop

Kill any active launcher, if possible.

This method is highly dependant on the platform and specific launcher used. It's not guaranteed that a launcher is capable of killing the playing process.

Parameters

None.

Result

Returns null on success.

Currently, it is not reported if a process was killed or not.

Example

Request
{
"jsonrpc": "2.0",
"id": "176b4558-7a5b-11ef-b318-020304050607",
"method": "stop"
}
Response
{
"jsonrpc": "2.0",
"id": "176b4558-7a5b-11ef-b318-020304050607",
"result": null
}

Tokens

tokens.history

Returns a list of the last recorded token launches.

Parameters

None.

Result

KeyTypeRequiredDescription
entriesLaunchEntry[]YesA list of recorded token launches.
Launch entry object
KeyTypeRequiredDescription
datastringNoSame as launch parameter.
successbooleanYesTrue if the launch was successful.
textstringNoSame as launch parameter.
timestringYesTimestamp of the launch time in RFC3339 format.
typestringNoSame as launch parameter.
uidstringNoSame as launch parameter.

Example

Request
{
"jsonrpc": "2.0",
"id": "5e9f3a0e-7a5b-11ef-8084-020304050607",
"method": "history"
}
Response
{
"jsonrpc": "2.0",
"id": "5e9f3a0e-7a5b-11ef-8084-020304050607",
"result": {
"entries": [
{
"data": "",
"success": true,
"text": "**launch.system:snes",
"time": "2024-09-24T17:49:42.938167429+08:00",
"type": "",
"uid": ""
}
]
}
}

Media

media.search

Query the media database and return all matching indexed media.

Parameters

An object:

KeyTypeRequiredDescription
querystringYesCase-insensitive search by filename. By default, query is split by white space and results are found which contain every word.
systemsstring[]NoCase-sensitive list of system IDs to restrict search to. A missing key or empty list will search all systems.
maxResultsnumberNoMax number of results to return. Default is 250.

Result

KeyTypeRequiredDescription
resultsMedia[]YesA list of all search results from the given query.
totalnumberYesTotal number of search results.
Media object
KeyTypeRequiredDescription
systemSystemYesSystem which the media has been indexed under.
namestringYesA human-readable version of the result's filename without a file extension.
pathstringYesPath to the media file. If possible, this path will be compressed into the <system>/<path> launch format.
System object
KeyTypeRequiredDescription
idstringYesInternal system ID for this system.
namestringYesDisplay name of the system.
categorystringYesCategory of system. This field is not yet formalised.

Example

Request
{
"jsonrpc": "2.0",
"id": "47f80537-7a5d-11ef-9c7b-020304050607",
"method": "media.search",
"params": {
"query": "240p"
}
}
Response
{
"jsonrpc": "2.0",
"id": "47f80537-7a5d-11ef-9c7b-020304050607",
"result": {
"results": [
{
"name": "240p Test Suite (PD) v0.03 tepples",
"path": "Gameboy/240p Test Suite (PD) v0.03 tepples.gb",
"system": {
"category": "Handheld",
"id": "Gameboy",
"name": "Gameboy"
}
}
],
"total": 1
}
}

media.index

Create a new media database index.

During an index, the server will emit media.indexing notifications showing progress of the index.

Parameters

Optionally, an object:

KeyTypeRequiredDescription
systemsstring[]NoList of system IDs to restrict indexing to. Other system indexes will remain as is.

An omitted or null value parameters key is also valid and will index every system.

Result

Returns null on success once indexing is complete.

Example

Request
{
"jsonrpc": "2.0",
"id": "6f20e07c-7a5e-11ef-84bb-020304050607",
"method": "media.index"
}
Response
{
"jsonrpc": "2.0",
"id": "6f20e07c-7a5e-11ef-84bb-020304050607",
"result": null
}

systems

List all currently indexed systems.

Parameters

None.

Result

KeyTypeRequiredDescription
systemsSystem[]YesA list of all indexed systems.

See System object.

Example

Request
{
"jsonrpc": "2.0",
"id": "dbd312f3-7a5f-11ef-8f29-020304050607",
"method": "systems"
}
Response
{
"jsonrpc": "2.0",
"id": "dbd312f3-7a5f-11ef-8f29-020304050607",
"result": {
"systems": [
{
"category": "Handheld",
"id": "GameboyColor",
"name": "Gameboy Color"
},
{
"category": "Computer",
"id": "EDSAC",
"name": "EDSAC"
}
]
}
}

Settings

settings

List currently set configuration settings.

This method will list values set in the Config File. Some config file options may be omitted which are not appropriate to be read or written remotely.

Parameters

None.

Result

KeyTypeRequiredDescription
readerstring[]YesA list of manually configured reader module connection strings.
audioFeedbackbooleanYes
detectReadersbooleanYes
insertModebooleanYes
insertModeBlockliststring[]Yes
insertModeExitDelaynumberYes
consoleLoggingbooleanYes
debugbooleanYesSee debug.
systemsSystems configYesThe systems section of the config file.
Systems config
KeyTypeRequiredDescription
rootFolderstring[]Yes

Example

Request
{
"jsonrpc": "2.0",
"id": "f208d996-7ae6-11ef-960e-020304050607",
"method": "settings"
}
Response
{
"jsonrpc": "2.0",
"id": "f208d996-7ae6-11ef-960e-020304050607",
"result": {
"readers": ["pn532_uart:/dev/ttyUSB0"],
"detectReaders": true,
"audioFeedback": true,
"insertMode": false,
"insertModeBlocklist": ["DOS"],
"insertModeExitDelay": 0,
"consoleLogging": false,
"debug": false,
"systems": {
"rootFolders": []
}
}
}

settings.update

Update one or more settings in-memory and save changes to disk.

This method will only write values which are supplied. Existing values will not be modified.

Parameters

An object:

KeyTypeRequiredDescription
readerstring[]YesA list of manually configured reader module connection strings.
audioFeedbackbooleanYes
detectReadersbooleanYes
insertModebooleanYes
insertModeBlockliststring[]Yes
insertModeExitDelaynumberYes
consoleLoggingbooleanYes
debugbooleanYesSee debug.
systemsSystems configYesThe systems section of the config file.
Systems config
KeyTypeRequiredDescription
rootFolderstring[]Yes

Result

Returns null on success.

Example

Request
{
"jsonrpc": "2.0",
"id": "562c0b60-7ae8-11ef-87d7-020304050607",
"method": "settings.update",
"params": {
"debug": false
}
}
Response
{
"jsonrpc": "2.0",
"id": "562c0b60-7ae8-11ef-87d7-020304050607",
"result": null
}

Mappings

Mappings are used to modify the contents of tokens before they're launched, based on different types of matching parameters. Stored mappings are queried before every launch and applied to the token if there's a match. This allows, for example, adding ZapScript to a read-only NFC tag based on its UID.

mappings

List all mappings.

Returns a list of all active and inactive mappings entries stored on server.

Parameters

None.

Result

KeyTypeRequiredDescription
mappingsMapping[]YesList of all stored mappings. See mapping object.
Mapping object
KeyTypeRequiredDescription
addedstringYesTimestamp of the time mapping was created in RFC3339 format.
enabledbooleanYesTrue if the mapping will be used when looking up matching mappings.
idnumberYesInternal database ID of mapping entry. Used to reference mapping for updates and deletions.
labelstringNoAn optional display name shown to the user.
typestringYesThe field which will be matched against:
_ uid: match on UID, if available. UIDs are normalized before matching to remove spaces, colons and convert to lowercase.
_ text: match on the stored text on token.
* data: match on the raw token data, if available. This is converted from bytes to a hexadecimal string and should be matched as this.
matchstringYesThe method used to match a mapping pattern:
_ exact: match the entire string exactly to the field.
_ partial: match part of the string to the field.
* regex: use a regular expression to match the field.
patternstringYesPattern that will be matched against the token, using the above settings.
overridestringYesFinal text that will completely replace the existing token text if a match was successful.

Example

Request
{
"jsonrpc": "2.0",
"id": "1a8bee28-7aef-11ef-8427-020304050607",
"method": "mappings"
}
Response
{
"jsonrpc": "2.0",
"id": "1a8bee28-7aef-11ef-8427-020304050607",
"result": {
"mappings": [
{
"added": "1970-01-21T06:08:18+08:00",
"enabled": true,
"id": "1",
"label": "barcode pokemon",
"match": "partial",
"override": "**launch.search:gbc/*pokemon*gold*",
"pattern": "9780307468031",
"type": "text"
}
]
}
}

mappings.new

Create a new mapping.

Parameters

An object:

KeyTypeRequiredDescription
enabledbooleanYesTrue if the mapping will be used when looking up matching mappings.
labelstringNoAn optional display name shown to the user.
typestringYesThe field which will be matched against:
_ uid: match on UID, if available. UIDs are normalized before matching to remove spaces, colons and convert to lowercase.
_ text: match on the stored text on token.
* data: match on the raw token data, if available. This is converted from bytes to a hexadecimal string and should be matched as this.
matchstringYesThe method used to match a mapping pattern:
_ exact: match the entire string exactly to the field.
_ partial: match part of the string to the field.
* regex: use a regular expression to match the field.
patternstringYesPattern that will be matched against the token, using the above settings.
overridestringYesFinal text that will completely replace the existing token text if a match was successful.

Result

KeyTypeRequiredDescription
idnumberYesDatabase ID of new mapping entry.

Example

(Example missing in source)

mappings.delete

Delete an existing mapping.

Parameters

KeyTypeRequiredDescription
idnumberYesDatabase ID of mapping.

Result

Returns null on success.

Example

(Example missing in source)

mappings.update

Change an existing mapping.

Parameters

An object:

KeyTypeRequiredDescription
idnumberYesInternal database ID of mapping entry.
enabledbooleanNoTrue if the mapping will be used when looking up matching mappings.
labelstringNoAn optional display name shown to the user.
typestringNoThe field which will be matched against:
_ uid: match on UID, if available. UIDs are normalized before matching to remove spaces, colons and convert to lowercase.
_ text: match on the stored text on token.
* data: match on the raw token data, if available. This is converted from bytes to a hexadecimal string and should be matched as this.
matchstringNoThe method used to match a mapping pattern:
_ exact: match the entire string exactly to the field.
_ partial: match part of the string to the field.
* regex: use a regular expression to match the field.
patternstringNoPattern that will be matched against the token, using the above settings.
overridestringNoFinal text that will completely replace the existing token text if a match was successful.

Only keys which are provided in the object will be updated in the database.

Result

Returns null on success.

Example

Request
{
"jsonrpc": "2.0",
"id": "e98fd686-7e62-11ef-8f8c-020304050607",
"method": "mappings.update",
"params": {
"enabled": false,
"id": 1
}
}
Response

(Response missing in source)

Readers

readers

List all currently connected readers.

Parameters

(Parameters missing in source)

Result

(Result missing in source)

Example

(Example missing in source)

readers.write

Attempt to write given text to the first available write-capable reader, if possible.

Parameters

An object:

KeyTypeRequiredDescription
textstringYesZapScript to be written to the token.

Result

Returns null on success.

Example

(Example missing in source)

Clients

Clients can only be managed through the API via a device-local connection.

clients

List all registered clients and associated data.

Parameters

None.

Result

KeyTypeRequiredDescription
clientsClient[]YesList of all registered clients.
Client object
KeyTypeRequiredDescription
idstringYesUnique ID of client.
namestringNoDisplay name of client.
secretstringYesSecret key of client.
addressstringNoLast connected address of client.

Example

Request
{
"jsonrpc": "2.0",
"id": "aae4aaa4-7e48-11ef-9e36-020304050607",
"method": "clients"
}
Response
{
"jsonrpc": "2.0",
"id": "aae4aaa4-7e48-11ef-9e36-020304050607",
"result": {
"clients": [
{
"address": "",
"id": "0b150eae-0f1b-4ede-9d7c-09c0ae0509ea",
"name": "Test",
"secret": "d3edfd14ce20e64f01c06932dcb5553560d0995a8871b7398c9a7b7fcc42e670"
}
]
}
}

clients.new

Create a new client with a newly generated ID and secret.

Parameters

Optionally, an object:

KeyTypeRequiredDescription
namestringNoDisplay name of client.

Result

(Result missing in source)

Example

(Example missing in source)

clients.delete

Delete an existing client.

Parameters

(Parameters missing in source)

Result

(Result missing in source)

Example

(Example missing in source)

Service

version

Return server's current version and platform.

Parameters

None.

Result

KeyTypeRequiredDescription
platformstringYesID of platform the service is currently running on.
versionstringYesCurrent version of the running Zaparoo service.

Example

Request
{
"jsonrpc": "2.0",
"id": "ca47f646-7e47-11ef-971a-020304050607",
"method": "version"
}
Response
{
"jsonrpc": "2.0",
"id": "ca47f646-7e47-11ef-971a-020304050607",
"result": {
"platform": "mister",
"version": "2.0.0-dev"
}
}