{"id":21937638,"url":"https://github.com/cap32/node-touch-sprite-remote","last_synced_at":"2026-04-16T12:41:47.575Z","repository":{"id":57378354,"uuid":"102846901","full_name":"Cap32/node-touch-sprite-remote","owner":"Cap32","description":"Touch sprite remote API for Node.js (Unofficial)","archived":false,"fork":false,"pushed_at":"2017-09-19T10:28:01.000Z","size":160,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-03T01:41:53.568Z","etag":null,"topics":["api","nodejs","touch-sprite","touch-sprite-remote"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Cap32.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-08T09:55:15.000Z","updated_at":"2017-09-16T09:42:37.000Z","dependencies_parsed_at":"2022-09-19T03:20:24.463Z","dependency_job_id":null,"html_url":"https://github.com/Cap32/node-touch-sprite-remote","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap32%2Fnode-touch-sprite-remote","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap32%2Fnode-touch-sprite-remote/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap32%2Fnode-touch-sprite-remote/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap32%2Fnode-touch-sprite-remote/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cap32","download_url":"https://codeload.github.com/Cap32/node-touch-sprite-remote/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap32%2Fnode-touch-sprite-remote/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259038279,"owners_count":22796592,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","nodejs","touch-sprite","touch-sprite-remote"],"created_at":"2024-11-29T01:21:01.133Z","updated_at":"2026-04-16T12:41:47.525Z","avatar_url":"https://github.com/Cap32.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# touch-sprite-remote\n\n[![Build Status](https://travis-ci.org/Cap32/node-touch-sprite-remote.svg?branch=master)](https://travis-ci.org/Cap32/node-touch-sprite-remote) [![License](https://img.shields.io/badge/license-MIT_License-blue.svg?style=flat)](https://github.com/Cap32/node-touch-sprite-remote/blob/master/LICENSE.md)\n\nTouch script remote API for Node.js (Unofficial)\n\n\n## Table of Contents\n\n\u003c!-- MarkdownTOC autolink=\"true\" bracket=\"round\" --\u003e\n\n- [Installation](#installation)\n- [Getting Started](#getting-started)\n- [API Reference](#api-reference)\n  - [fetchAuth\\(options\\)](#fetchauthoptions)\n  - [getDeviceName\\(target\\)](#getdevicenametarget)\n  - [status\\(target\\[, options\\]\\)](#statustarget-options)\n  - [run\\(target\\[, options\\]\\)](#runtarget-options)\n  - [stop\\(target\\[, options\\]\\)](#stoptarget-options)\n  - [upload\\(target\\[, options\\]\\)](#uploadtarget-options)\n  - [TSRemote](#tsremote)\n- [License](#license)\n\n\u003c!-- /MarkdownTOC --\u003e\n\n\n\u003ca name=\"installation\"\u003e\u003c/a\u003e\n## Installation\n\n```bash\nnpm install touch-sprite-remote\n```\n\n\n\u003ca name=\"getting-started\"\u003e\u003c/a\u003e\n## Getting Started\n\n```js\nimport { fetchAuth, run, status } from 'touch-sprite-remote';\n\n(async function () {\n  const { auth } = await fetchAuth({\n    key: '\u003cmy_key\u003e',\n    devices: ['\u003cmy_device_id\u003e'],\n  });\n  const runResult = await run('192.168.1.23', { auth });\n  console.log('run:', runResult); /* \"ok\" or \"fail\" */\n\n  const statusResult = await status('192.168.1.23', { auth });\n  console.log('status:', statusResult); /* \"f00\", \"f01\" or \"f02\" */\n}());\n```\n\n\n\u003ca name=\"api-reference\"\u003e\u003c/a\u003e\n## API Reference\n\n\u003ca name=\"fetchauthoptions\"\u003e\u003c/a\u003e\n### fetchAuth(options)\n\nFetch auth / access token.\n\n###### Options\n\n- `key` (String): Developer access key\n- `devices`: ([String]): Devices IDs\n- `expiresIn` (Number): Expires in seconds. Defaults to 3600\n\n###### Returns\n\n```js\n{\n  status: 200,\n  message: 'error message if status is not 200',\n  time: 1422930265, // current unix timestamp\n  auth: 'auth / access token',\n  expiresIn: 3600, // expires in second\n  remainderToken: 4, // remainder token\n}\n```\n\n---\n\n\n\u003ca name=\"getdevicenametarget\"\u003e\u003c/a\u003e\n### getDeviceName(target)\n\nGet device name.\n\n###### Arguments\n\n- `target` (String): Device host target. eg: '192.168.1.23'\n\n###### Returns\n\n(String): Device name.\n\n---\n\n\n\u003ca name=\"statustarget-options\"\u003e\u003c/a\u003e\n### status(target[, options])\n\nGet status.\n\n###### Arguments\n\n- `target` (String): Device host target. eg: '192.168.1.23'\n- `options` (Object): Defines `options.auth` for access token (required)\n\n###### Returns\n\n(String): Returns one of these string:\n\n- `f00`: Free\n- `f01`: In running scripts\n- `f02`: In recording screen\n\n---\n\n\n\u003ca name=\"runtarget-options\"\u003e\u003c/a\u003e\n### run(target[, options])\n\nRun script.\n\n###### Arguments\n\n- `target` (String): Device host target. eg: '192.168.1.23'\n- `options` (Object): Defines `options.auth` for access token (required)\n\n###### Returns\n\n(String): `ok` or `fail`\n\n---\n\n\n\u003ca name=\"stoptarget-options\"\u003e\u003c/a\u003e\n### stop(target[, options])\n\nStop script.\n\n###### Arguments\n\n- `target` (String): Device host target. eg: '192.168.1.23'\n- `options` (Object): Defines `options.auth` for access token (required)\n\n###### Returns\n\n(String): `ok` or `fail`\n\n---\n\n\n\u003ca name=\"uploadtarget-options\"\u003e\u003c/a\u003e\n### upload(target[, options])\n\nUpload file.\n\n###### Arguments\n\n- `target` (String): Device host target. eg: '192.168.1.23'\n- `options` (Object):\n  + `auth` (String): Access token (required)\n  + `file` (String): Local file path\n  + `remoteFile` (String): Remote file path\n  + `type` (String): Defining root type. One of `lua`, `res`, `log` or `plugin` is supported. By default, if `file` ext is `.lua`, `.luac` or `.txt`, it would be `lua`, otherwise, it would be `res`\n\n###### Returns\n\n(String): `ok` or `fail`\n\n---\n\n\n\u003ca name=\"tsremote\"\u003e\u003c/a\u003e\n### TSRemote\n\nTSRemote class. A TSRemote instance by calling `new TSRemote(options)` provides all methods above, but could only get and set auth once.\n\nThe `options` is almost the same with `fetchAuth(options)`, but also provides these two auth cache getter and setter functions:\n\n- `async getAuth()`: Will call when calling any api needs `auth`. It's useful to get `auth` from your cache system\n- `async setAuth(authObject)`: Will call when `getAuth()` doesn't return `auth`. The `authObject` is the same with the result of `fetchAuth()`. It's useful to save the `auth` to your cache system\n\n###### Example\n\n```js\nimport TSRemote from 'touch-sprite-remote';\n\nlet cache;\n\n(async function () {\n  const tsr = new TSRemote({\n    key: '\u003cmy_key\u003e',\n    devices: ['\u003cmy_device_id\u003e'],\n\n    /* add `getAuth()` and `setAuth()` functions */\n    getAuth: async () =\u003e cache,\n    setAuth: async ({ auth, expiresIn }) =\u003e (cache = auth),\n  });\n\n  /* no need `auth` option */\n  const runResult = await tsr.run('192.168.1.23');\n  const statusResult = await tsr.status('192.168.1.23');\n}());\n```\n\n###### Additional instance methods\n\n- `refreshToken()`: Force refresh token\n- `addDevices(device[, ...devices])`: Add devices. Will refresh token\n- `removeDevices(device[, ...devices])`: Remove devices. Will refresh token\n\n\n\u003ca name=\"license\"\u003e\u003c/a\u003e\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcap32%2Fnode-touch-sprite-remote","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcap32%2Fnode-touch-sprite-remote","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcap32%2Fnode-touch-sprite-remote/lists"}