{"id":24118522,"url":"https://github.com/phearzero/turing-pi-js","last_synced_at":"2026-05-14T19:35:52.859Z","repository":{"id":153750548,"uuid":"630261328","full_name":"PhearZero/turing-pi-js","owner":"PhearZero","description":"Turing Pi API Client","archived":false,"fork":false,"pushed_at":"2023-04-28T14:36:46.000Z","size":18,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-05-02T02:18:01.705Z","etag":null,"topics":["javascript","turing-pi"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/turing-pi-js","language":"TypeScript","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/PhearZero.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-20T02:23:36.000Z","updated_at":"2023-06-24T03:46:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"931c5344-9555-4a8c-a5a0-7fc531b850f9","html_url":"https://github.com/PhearZero/turing-pi-js","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/PhearZero%2Fturing-pi-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PhearZero%2Fturing-pi-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PhearZero%2Fturing-pi-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PhearZero%2Fturing-pi-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PhearZero","download_url":"https://codeload.github.com/PhearZero/turing-pi-js/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241176615,"owners_count":19922732,"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":["javascript","turing-pi"],"created_at":"2025-01-11T08:19:51.658Z","updated_at":"2026-05-14T19:35:52.823Z","avatar_url":"https://github.com/PhearZero.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🤖 turing-pi-js\n\u003e A JavaScript client for Turing Pi web API\n\n## ℹ️ Overview\n\n### 📦 Prerequisites\n- [Node.js](https://nodejs.org/en)\n- [Turing Pi 2](https://turingpi.com/product/turing-pi-2/)\n\nThis project is maintained by @PhearZero and is not associated with @turing-machines.\nThis library is used to control a `Turing Pi 2` from a JavaScript environment.\n\n## ⚙️ Getting started\n\n### Install\n```bash\nnpm -i turing-pi-js --save\n```\n\n### Import\n```javascript\nimport {tpi} from 'turing-pi-js'\nconst BMC_API = '\u003cAdd-URL-to-BMC-API\u003e'\nconst client = tpi(BMC_API)\n```\n\n### Example Usage\n```javascript\n// Get current power state for all Nodes\nclient.get('power').then(r=\u003econsole.log(r))\n// Power On Node 1\nclient.set('power',{node1:1}).then(r=\u003econsole.log(r))\n```\n[Find out more in the detailed usage](#-usage)\n\n## 💾 Firmware\n\nThe current firmware, as of writing ([v1.0.1](https://github.com/wenyi0421/turing-pi), [v0.1.0-ce](https://github.com/daniel-kukiela/turing-pi-2-community-edition-firmware)), \ndoes not support Cross Origin Requests and requires a reverse proxy to connect from another machine. This library will \nwork without a proxy when deployed locally on the [Turing Pi Web Server](https://help.turingpi.com/hc/en-us/articles/8849365259933-BMC-Web-Interface)\n\n#### 🔃 Reverse Proxy\n\nTemporary fix until the firmware api becomes more stable. This template patches the response headers for using the library\nin the browser. The `ENV` variable for the [Turing Pi BMC API](https://help.turingpi.com/hc/en-us/articles/8795098568477-BMC-API) is `BMC_API` in following template:  \n\n```nginx\n#/etc/nginx/templates/default.conf.template\nserver {\n    listen       80;\n    listen  [::]:80;\n    server_name  localhost;\n    \n    location /api/bmc {\n        proxy_pass   ${BMC_API};\n        proxy_hide_header Content-Type;\n        add_header Content-Type application/json;\n        add_header Access-Control-Allow-Origin *;\n    }\n}\n```\n## 📗 Usage\n\n### ✨ Create client\n```javascript\nimport {tpi} from 'turing-pi-js'\nconst BMC_API = '\u003cAdd-URL-to-BMC-API\u003e'\nconst client = tpi(BMC_API)\n```\n\n### 🔧 Fetch Options\n```javascript\nclient.get('nodeinfo', {\n    credentials: true,\n})\n```\n\n### 🔌 Power\n```javascript\n// Valid values are \"0\" or \"1\". \"0\" for OFF, \"1\" for ON.\n\n// Get Power for all Nodes\nclient.get('power').then(r=\u003econsole.log(r))\n\n// Set Power for any number of Nodes\nclient.set('power', {node1: 1, node2: 0, /* node3:0, node4:0 */}).then(r=\u003econsole.log(r))\n```\n\n### ⌨️ USB\n```javascript\n// mode: Valid values are \"0\" or \"1\". \"0\" for Host, \"1\" for Device\n// node: Valid values are \"0\", \"1\", \"2\", \"3\". Relating to slots Node1-4\n\n// Get USB state from BMC\nclient.get('usb').then(r=\u003econsole.log(r))\n\n// Set Power for any number of Nodes\nclient.set('usb', {mode: 0, node: 0}).then(r=\u003econsole.log(r))\n```\n\n### ℹ️ Node Info\n```javascript\n// Get Node Info\nclient.get('nodeinfo').then(r=\u003econsole.log(r))\n```\n### ℹ️ BMC Info\n```javascript\n// Get BMC Info\nclient.get('other').then(r=\u003econsole.log(r))\n```\n\n### 📂 SD Card Info\n```javascript\n// Get SD card info\nclient.get('sdcard').then(r=\u003econsole.log(r))\n```\n\n### 🔃 Reset Network\n```javascript\n// Reset network\nclient.set('network', {cmd: \"reset\"}).then(r=\u003econsole.log(r))\n```\n\n### 💾 Update Firmware\n```javascript\n// Get the file contents\nvar input = document.querySelector('input[type=\"file\"]')\n// Upload firmware\nclient.set('firmware', {file: input.files[0]}).then(r=\u003econsole.log(r))\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphearzero%2Fturing-pi-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphearzero%2Fturing-pi-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphearzero%2Fturing-pi-js/lists"}