{"id":18755112,"url":"https://github.com/dthree/node-piston","last_synced_at":"2025-04-13T01:35:33.073Z","repository":{"id":57324901,"uuid":"379673624","full_name":"dthree/node-piston","owner":"dthree","description":"Node.js client wrapper for the Piston API","archived":false,"fork":false,"pushed_at":"2023-05-15T16:08:12.000Z","size":27,"stargazers_count":26,"open_issues_count":1,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-09-15T21:26:30.768Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/dthree.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-23T16:59:40.000Z","updated_at":"2024-09-02T04:23:37.000Z","dependencies_parsed_at":"2022-09-06T06:41:10.107Z","dependency_job_id":null,"html_url":"https://github.com/dthree/node-piston","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dthree%2Fnode-piston","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dthree%2Fnode-piston/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dthree%2Fnode-piston/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dthree%2Fnode-piston/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dthree","download_url":"https://codeload.github.com/dthree/node-piston/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223558618,"owners_count":17165159,"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":[],"created_at":"2024-11-07T17:31:43.181Z","updated_at":"2024-11-07T17:32:10.697Z","avatar_url":"https://github.com/dthree.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Piston Node Client\n\nA Node.js client wrapper for the [Piston API](https://github.com/engineer-man/piston). \n\nPiston is a high performance general purpose code execution engine. It excels at running untrusted and possibly malicious code without fear from any harmful effects.\n\n\u003cbr\u003e\n\n## Installation\n\n```bash\nnpm install piston-client\n```\n\n### Usage Example\n\n```js\nimport piston from \"piston-client\";\n\n(async () =\u003e {\n\n    const client = piston({ server: \"https://emkc.org\" });\n    \n    const runtimes = await client.runtimes();\n    // [{ language: 'python', version: '3.9.4', aliases: ['py'] }, ...]\n\n    const result = await client.execute('python', 'print(\"Hello World!\")');\n    // { language: 'python', version: '3.9.4', run: {\n    //     stdout: 'Hello World!\\n',\n    //     stderr: '',\n    //     code: 0,\n    //     signal: null,\n    //     output: 'Hello World!\\n'\n    // }}\n\n})();\n```\n\n\u003cbr\u003e\n\n## Documentation\n\n### `piston(options)`\n\n```js\nimport piston from \"piston-client\";\nconst client = piston({});\n```\n\nCreates a new client. Accepts an `options` object as its first argument.\n\n##### Options\n\n- `server` - The domain name of the Piston server to be used. Defaults to `https://emkc.org`.\n\n### `client.runtimes()`\n\n```js\nimport piston from \"piston-client\";\n(async () =\u003e {\n    const client = piston();\n    const runtimes = await client.runtimes();\n})();\n```\n\nReturns an array of available runtimes. [See Piston documentation for the runtimes endpoint](https://github.com/engineer-man/piston#runtimes-endpoint).\n\n### `client.execute(language, code, [config])`\n\nExecute arbitrary code for a given language. Additional, optional config can be passed in the third parameter.\n\n```js\nimport piston from \"piston-client\";\n(async () =\u003e {\n    const client = piston();\n    const result = await client.execute('javascript', 'console.log(\"Hello world!\")', { language: '3.9.4 '});\n})();\n```\n\n##### Options\n\n- `language` - Expects a string of the language.\n- `code` - Expects a string of the code to execute.\n- `config` - Expects an object with additional config. See [Piston documentation](https://github.com/engineer-man/piston#execute-endpoint) for the available config options.\n\n### `client.execute(config)`\n\nTo execute Piston with more fine-tuned control, pass in a `config` object as the first and only parameter.\n\n```js\nimport piston from \"piston-client\";\n(async () =\u003e {\n    const client = piston();\n    const result = await client.execute({\n        \"language\": \"js\",\n        \"version\": \"15.10.0\",\n        \"files\": [{\n            \"name\": \"my_cool_code.js\",\n            \"content\": \"console.log(process.argv)\"\n        }],\n        \"stdin\": \"\",\n        \"args\": [\"1\", \"2\", \"3\"],\n        \"compileTimeout\": 10000,\n        \"runTimeout\": 3000,\n        \"compileMemoryLimit\": -1,\n        \"runMemoryLimit\": -1\n    });\n})();\n```\n\n##### Options\n\nSee [Piston documentation](https://github.com/engineer-man/piston#execute-endpoint) for the available options. The only difference is that the option are in camelCase as opposed to snake_case.\n\n### Error handling\n\nAny error will return an object with the following signature:\n\n```js\n{ success: false, error: Error }\n```\n\nNo errors are thrown so wrapping in `try / catch` is unnecessary.\n\n\u003cbr\u003e\n\n## License\n\nMIT © [DC](https://github.com/dthree)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdthree%2Fnode-piston","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdthree%2Fnode-piston","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdthree%2Fnode-piston/lists"}