API/Methods: Difference between revisions

From Zaparoo Wiki

< API

No edit summary
No edit summary
Line 41: Line 41:


==== Result ====
==== Result ====
This method returns null on success.
This method returns <code>null</code> on success.


Currently, it is not reported if the launched TapScript encounters an error during launching.
Currently, it is not reported if the launched TapScript encounters an error during launching.


==== Example ====
==== Example ====
===== Request =====
<syntaxhighlight lang="json">
{
    "jsonrpc": "2.0",
    "id": "52f6242e-7a5a-11ef-bf93-020304050607",
    "method": "launch",
    "params": {
        "text": "**launch.system:snes"
    }
}
</syntaxhighlight>
===== Response =====
<syntaxhighlight lang="json">
{
    "jsonrpc": "2.0",
    "id": "52f6242e-7a5a-11ef-bf93-020304050607",
    "result": null
}
</syntaxhighlight>


=== stop ===
=== stop ===
Kill any active launcher, if possible.
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 playing media.


==== Parameters ====
==== Parameters ====
Line 54: Line 78:


==== Result ====
==== Result ====
This method returns null on success.
This method returns <code>null</code> on success.


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


==== Example ====
==== Example ====
===== Request =====
<syntaxhighlight lang="json">
{
    "jsonrpc": "2.0",
    "id": "176b4558-7a5b-11ef-b318-020304050607",
    "method": "stop"
}
</syntaxhighlight>
===== Response =====
<syntaxhighlight lang="json">
{
    "jsonrpc": "2.0",
    "id": "176b4558-7a5b-11ef-b318-020304050607",
    "result": null
}
</syntaxhighlight>


=== history ===
=== history ===
Line 67: Line 111:


==== Result ====
==== Result ====
{| class="wikitable"
!Key
!Type
!Required
!Description
|-
|entries
|LaunchEntry[]
|Yes
|A list of recorded token launches.
|}
===== Launch entry object =====
{| class="wikitable"
!Key
!Type
!Required
!Description
|-
|data
|string
|No
|Same as [[API/Methods#launch|launch parameter]].
|-
|success
|boolean
|Yes
|True if the launch was successful.
|-
|text
|string
|No
|Same as [[API/Methods#launch|launch parameter]].
|-
|time
|string
|Yes
|Timestamp of the launch time in RFC3339 format.
|-
|type
|string
|No
|Same as [[API/Methods#launch|launch parameter]].
|-
|uid
|string
|No
|Same as [[API/Methods#launch|launch parameter]].
|}


==== Example ====
==== Example ====
===== Request =====
<syntaxhighlight lang="json">
{
    "jsonrpc": "2.0",
    "id": "5e9f3a0e-7a5b-11ef-8084-020304050607",
    "method": "history"
}
</syntaxhighlight>
===== Response =====
<syntaxhighlight lang="json">
{
    "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": ""
            }
        ]
    }
}
</syntaxhighlight>


== Media ==
== Media ==
Line 76: Line 200:


==== Parameters ====
==== Parameters ====
This request accepts the following parameters object:
An object:
{| class="wikitable"
{| class="wikitable"
!Key
!Key
Line 100: Line 224:


==== Result ====
==== Result ====
And a response with the following results object:
{| class="wikitable"
{| class="wikitable"
!Key
!Key

Revision as of 10:07, 24 September 2024

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

Launching

launch

Emulate the scanning of a token.

Parameters

This method accepts two types of parameters:

  • A single string, in which case the string will be treated as the token text.
  • Or an object with the following keys:
Key Type Required Description
type string No An internal category of the type of token being scanned. Not currently in use outside of logging.
uid string No* The UID of the token being scanner. For example, the UID of an NFC tag. Used for matching mappings.
text string No* The main text to be processed from a scan, should contain TapScript.
data string No* The raw data read from a token, converted to a hexadecimal string. Used in mappings and detection of NFC toys such as Amiibos and Lego Dimensions.

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

This method returns null on success.

Currently, it is not reported if the launched TapScript encounters an error during launching.

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 playing media.

Parameters

None.

Result

This method 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
}

history

Returns a list of the last recorded token launches.

Parameters

None.

Result

Key Type Required Description
entries LaunchEntry[] Yes A list of recorded token launches.
Launch entry object
Key Type Required Description
data string No Same as launch parameter.
success boolean Yes True if the launch was successful.
text string No Same as launch parameter.
time string Yes Timestamp of the launch time in RFC3339 format.
type string No Same as launch parameter.
uid string No Same 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:

Key Type Required Description
query string Yes Case-insensitive search by filename. By default, query is split by white space and results are found which contain every word.
system string[] No Case-sensitive list of system IDs to restrict search to. A missing key or empty list will search all systems.
maxResults number No Max number of results to return. Default is 250.

Result

Key Type Required Description
results Media[] Yes A list of all search results from the given query.
total number Yes Total number of search results.
Media object
Key Type Required Description
system System Yes System which the media has been indexed under.
name string Yes A human-readable version of the result's filename without a file extension.
path string Yes Path to the media file. If possible, this path will be compressed into the <system>/<path> launch format.
System object
Key Type Required Description
id string Yes Internal system ID for this system.
name string Yes Display name of the system.
category string Yes Category of system. This field is not yet formalised.

Example

media.index

Start a new media database index.

This method does not block and wait for the index to complete. It will return a response immediately and start in the background. media.indexing notifications will be sent to show progress of current indexing process.

Parameters

This method can, optionally, take a list of strings of system IDs to restrict the index to just those systems.

Result

Example

systems

List all currently indexed systems.

Parameters

This method has no parameters.

Result

Returns a response results object of a list of System objects.

Example

Settings

settings

List currently set configuration settings.

This method will list values set in the Config File. Values may be hidden which are not appropriate to be read remotely.

Parameters

This method has no parameters.

Result

Key Type Required Description
reader string[] Yes A list of manually configured reader driver connection strings. See reader.
audioFeedback boolean Yes
detectReaders boolean Yes
insertMode boolean Yes
insertModeBlocklist string[] Yes
insertModeExitDelay number Yes
consoleLogging boolean Yes
debug boolean Yes See debug.
systems Systems config Yes The systems section of the config file.
Systems config
Key Type Required Description
rootFolder string[] Yes

Example

settings.update

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

Parameters

Result

Example

Mappings

mappings

List all mappings.

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

Parameters

Result

Example

mappings.new

Create a new mapping.

Parameters

Result

Example

mappings.delete

Delete an existing mapping.

Parameters

Result

Example

mappings.update

Change an existing mapping.

Parameters

Result

Example

Readers

readers

List all currently connected readers.

Parameters

Result

Example

readers.write

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

Parameters

Result

Example

Clients

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

clients

List all clients (including disconnected) and associated data.

Parameters

Result

Example

clients.new

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

Parameters

Result

Example

clients.delete

Delete an existing client.

Parameters

Result

Example

Service

version

Return server's current version and platform.

Parameters

Result

Example