{"id":19740349,"url":"https://github.com/distributive-network/dcp-rest","last_synced_at":"2025-06-29T18:02:40.324Z","repository":{"id":222674843,"uuid":"728858642","full_name":"Distributive-Network/dcp-rest","owner":"Distributive-Network","description":"A Restful HTTP server wrapper for common dcp-client operations","archived":false,"fork":false,"pushed_at":"2024-04-26T13:54:52.000Z","size":363,"stargazers_count":6,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-29T18:02:00.928Z","etag":null,"topics":["api","dcp","dcp-client","http","rest"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Distributive-Network.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-12-07T21:13:57.000Z","updated_at":"2025-03-05T21:26:48.000Z","dependencies_parsed_at":"2024-02-15T16:29:57.989Z","dependency_job_id":"f5b2d419-6afb-4859-b711-2517b30d0750","html_url":"https://github.com/Distributive-Network/dcp-rest","commit_stats":null,"previous_names":["distributive-network/dcp-rest"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Distributive-Network/dcp-rest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Distributive-Network%2Fdcp-rest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Distributive-Network%2Fdcp-rest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Distributive-Network%2Fdcp-rest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Distributive-Network%2Fdcp-rest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Distributive-Network","download_url":"https://codeload.github.com/Distributive-Network/dcp-rest/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Distributive-Network%2Fdcp-rest/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262642933,"owners_count":23341815,"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","dcp","dcp-client","http","rest"],"created_at":"2024-11-12T01:20:40.971Z","updated_at":"2025-06-29T18:02:39.448Z","avatar_url":"https://github.com/Distributive-Network.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Restful DCP (`dcp-rest`)\nA Restful HTTP API wrapper for common [dcp-client](https://www.npmjs.com/package/dcp-client) operations.\n\nThis is a flexible api that will allow you to manage jobs deployed from bifrost or dcp-client as well as provide a rich experience for deploying jobs itself.\n\n## Endpoints\n### Deploying a Job to dcp\nDeploy jobs to DCP. Full language support with libraries for Python and R is coming soon.\nPath: `/job`\nMethod: `POST`\n\nExample request body:\n```json\n{\n\t\"slices\": [1,2,3,4,5,6,7,8,9,10],\n\t\"work\": {\n\t\t\"language\": \"js\",\n\t\t\"function\": \"(datum) =\u003e { return datum * 2; }\"\n\t},\n\t\"account\": {\n\t\t\"address\": \"94E619279C5780fF20ECe07fAA719e3D66111A88\"\n\t}\n}\n```\n\n### Upload data for your Job to work on\nIn `dcp-rest`, every job is an \"open job\", which means you can add slices to be computed anytime after deploying - in fact, you can even omit the `slices` property of the request body in the example above and opt to add them later or in batches if you prefer.\n\nPath: `/job/{jobId}/slices`\nMethod: `POST`\n\n### Getting results\nDownload your currently computed results.\nPath: `/job/[id]/result`\nMethod: `GET`\n\nExample request:\n```\n/api/v0/job/$JOBID/result?range=1-10\u0026range=33-35\n```\n*^ Will return the results for slices 1 to 10 and 33 to 35*\n\nExample Postman request:\n![image](https://github.com/Distributive-Network/dcp-rest/assets/18359452/3c785421-6d90-4b88-9951-d639dd5899e0)\n\n\n### Job Status\nPath: `/job/[id]/status`\nMethod: `GET`\n\n### Forcefully kill a running Job\nStop a job from completing mid execution. \nPath: `/job/{jobId}`\nMethod: `DELETE`\n\n### List your bank keystores on DCP\nList the bank accounts associated with your identity.\nPath: `/accounts`\nMethod: `GET`\n\n## Auth\n`dcp-rest` uses two types of authorization and authentication:\n1. Bearer token API keys (not yet implemented)\n2. Basic tokens comprising of an id keystore and id keystore password\n\n### Basic Auth\nNote: in order to get the best experience with `dcp-rest`, please use an identity keystore which is a proxy to your DCP portal account. This is not required for most of the endpoints, but is used for deploying jobs and listing user bank accounts. \u003cTODO: make a website that generates them and link it here\u003e \n\nHere is an example of generating a token in JavaScript:\n```js\nconst idKeystore = wallet.getId();\nconst idKeystoreJSON = `${JSON.stringify(idKeystore.toJSON())}`;\nconst idKeystorePass = 'myepicpassw0rd'\n\nconst token = `Basic ${btoa(idKeystoreJSON + ':' + idKeystorePass)}`;\n```\n**Important Note**: DCP does not have a solid \"identity\"/\"auth\" underlying implementation yet (but will sometime soon). This means you must use the exact same id keystore to manage a job as you did to deploy it.\n\n## Try it out!\n```\ndocker build -t dcp-rest .\ndocker run -p 1234:1234 dcp-rest\n```\n\n## Roadmap\nPrimary items on the roadmap\n- add better examples\n- create an oauth app for api key generation\n- add better error handling and error responses\n- add support for Python and R in work functions (Python will be easy / might work already)\n- ci \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdistributive-network%2Fdcp-rest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdistributive-network%2Fdcp-rest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdistributive-network%2Fdcp-rest/lists"}