{"activeVersionTag":"latest","latestAvailableVersionTag":"latest","collection":{"info":{"_postman_id":"84b93d68-2073-4f51-bde3-68f19de57c62","name":"Wasm-Joey API documentation","description":"# SecondState's Wasm execution environment; Wasm-Joey\n\n[SecondState](https://www.secondstate.io/) has developed a high performance [WebAssembly(Wasm) Virtual Machine called SSVM](https://github.com/second-state/SSVM). \n\nThis product, called [Wasm-Joey](https://github.com/second-state/wasm-joey) allows you to:\n- upload/store your WebAssembly executables (.wasm files) for later use\n- run a function of your Wasm executable in the SSVM environment (via HTTP request/response)\n- store data\n- remote fetch data\n- secure your Wasm \n- share your Wasm and much more ...\n\nBelow is an explanation of the list of features, followed by actual endpoint documentation.\n\nFirstly, callbacks!\n\n## Callbacks\n- Allows user to specify a callback object as part of a request. \n- Callback objects can be placed in the request header i.e. `--header SSVM_Callback: {hostname ... port ... etc.}`\n- Callback objects can be placed in the request body i.e.\n```\n{\n\t\"SSVM_Callback\": {\n\t\t\"hostname\": \"dev.rpc.ssvm.secondstate.io\",\n\t\t\"path\": \"/api/run/1/say\",\n\t\t\"method\": \"POST\",\n\t\t\"port\": 8081,\n\t\t\"headers\": {\n\t\t\t\"Content-Type\": \"text/plain\",\n\t\t\t\"SSVM_Usage_Key\": \"83f02dd3-6440-482f-983f-78127ed6f943\"\n\t\t}\n\t},\n\t  \"Function_Parameters\": [1, 2, 3, 4]\n}\n```\n- Callback objects can be stored permanently in Joey's DB via a RESTful API endpoint.\n- A Callback in the header overrides a Callback in the body and a Callback in the DB.\n- A Callback in the body overrides a Callback in the DB.\n- If no other Callback objects are provided in the request and there is a Callback object in the DB, that DB Callback will execute regardless.\n- A blank Callback object in the header or the body can negate the Callback that is stored in the DB. \n\n## Remote fetching of data\nThis allows the caller to deal with large files without having to upload/download them. The GET and POST activities take place on the server side. The client stays light.\n\n### SSVM_Fetch in the request body (passes the response from the request and ignores any peripheral data in the body)\n```\ncurl --location --request POST 'https://rpc.ssvm.secondstate.io:8081/api/run/1/say' \\\n--header 'SSVM_Usage_Key: 83f02dd3-6440-482f-983f-78127ed6f943' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{\n\t\"SSVM_Fetch\": {\n\t\t\"body\": \"body\",\n\t\t\"hostname\": \"rpc.ssvm.secondstate.io\",\n\t\t\"path\": \"/api/run/1/say\",\n\t\t\"method\": \"POST\",\n\t\t\"port\": 8081,\n\t\t\"headers\": {\n\t\t\t\"Content-Type\": \"text/plain\",\n\t\t\t\"SSVM_Usage_Key\": \"83f02dd3-6440-482f-983f-78127ed6f943\"\n\t\t}\n\t},\n\t\"function_params\": [1, 2]\n}'\n```\nReturns\n```\nhello hello \"body\"\n```\n\n### SSVM_Fetch in the request head (overrides body and any peripheral data)\n```\ncurl --location --request POST 'https://rpc.ssvm.secondstate.io:8081/api/run/1/say' \\\n--header 'SSVM_Usage_Key: 83f02dd3-6440-482f-983f-78127ed6f943' \\\n--header 'SSVM_Fetch: {\"body\": \"header\",\"hostname\": \"rpc.ssvm.secondstate.io\",\"path\": \"/api/run/1/say\",\"method\": \"POST\",\"port\": 8081,\"headers\": {\"Content-Type\": \"text/plain\",\"SSVM_Usage_Key\": \"83f02dd3-6440-482f-983f-78127ed6f943\"}}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{\n\t\"SSVM_Fetch\": {\n\t\t\"body\": \"body\",\n\t\t\"hostname\": \"rpc.ssvm.secondstate.io\",\n\t\t\"path\": \"/api/run/1/say\",\n\t\t\"method\": \"POST\",\n\t\t\"port\": 8081,\n\t\t\"headers\": {\n\t\t\t\"Content-Type\": \"text/plain\",\n\t\t\t\"SSVM_Usage_Key\": \"83f02dd3-6440-482f-983f-78127ed6f943\"\n\t\t}\n\t},\n\t\"function_params\": [1, 2]\n}'\n```\nReturns\n```\nhello hello \"header\"\n```\n\n### SSVM_Fetch in the request body; providing only a URL\n```\ncurl --location --request POST 'https://rpc.ssvm.secondstate.io:8081/api/run/1/say' \\\n--header 'SSVM_Usage_Key: 83f02dd3-6440-482f-983f-78127ed6f943' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{\n\t\"SSVM_Fetch\": \"https://raw.githubusercontent.com/tpmccallum/test_endpoint2/master/tim.txt\",\n\t\"function_params\": [1, 2]\n}'\n```\nReturns\n```\nhello Tim\n```\n\n### SSVM_Fetch in the request header; providing only a URL\n```\ncurl --location --request POST 'https://rpc.ssvm.secondstate.io:8081/api/run/1/say' \\\n--header 'SSVM_Usage_Key: 83f02dd3-6440-482f-983f-78127ed6f943' \\\n--header 'SSVM_Fetch: https://raw.githubusercontent.com/tpmccallum/test_endpoint2/master/tim2.txt' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{\n\t\"SSVM_Fetch\": \"https://raw.githubusercontent.com/tpmccallum/test_endpoint2/master/tim.txt\"\n}'\n```\nReturns\n```\nhello Tim2\n```\n## Authenticated calling\n### Private \nIf a Wasm executable is for private use, the caller can make Joey generate a couple of keys (at the time when the Wasm executable is uploaded). For example, if the following header (`SSVM_Create_Usage_Key`) key is set to true in the request, the keys will be generated.\n```\ncurl --location --request POST 'https://rpc.ssvm.secondstate.io:8081/api/executables' \\\n--header 'Content-Type: application/octet-stream' \\\n--header 'SSVM_Description: Private Wasm File' \\\n--header 'SSVM_Create_Usage_Key: true' \\\n--data-binary '@/Users/tpmccallum/hello_bg.wasm'\n```\nThe above code will return the following response\n```\n{\n\t\"wasm_id\": 16,\n\t\"wasm_sha256\": \"0xfb413547a8aba56d0349603a7989e269f3846245e51804932b3e02bc0be4b665\",\n\t\"usage_key\": \"a038c28b-0e47-42e3-8686-be4c4d7f729b\",\n\t\"admin_key\": \"87d6edf0-52de-48fa-a4b2-0d035e5dc70a\"\n}\n```\nNote the `usage_key` and `admin_key`.\n### Public\nOn the contrary, Wasm executables that are set into the system with no mention of `SSVM_Create_Usage_Key` are set to public by default. For example, the following request returns the generic zeroed out usage key.\n```\ncurl --location --request POST 'https://rpc.ssvm.secondstate.io:8081/api/executables' \\\n--header 'Content-Type: application/octet-stream' \\\n--header 'SSVM_Description: Private Wasm File' \\\n--data-binary '@/Users/tpmccallum/hello_bg.wasm'\n```\n```\n{\n\t\"wasm_id\": 17,\n\t\"wasm_sha256\": \"0xfb413547a8aba56d0349603a7989e269f3846245e51804932b3e02bc0be4b665\",\n\t\"usage_key\": \"00000000-0000-0000-0000-000000000000\",\n\t\"admin_key\": \"8741ec91-79d4-4718-bce9-d073438ea582\"\n}\n```\n### Switching between private and public\nTo make a public Wasm executable private, simply perform the following RESTful (`PUT`) request\n```\ncurl --location --request PUT 'https://rpc.ssvm.secondstate.io:8081/api/keys/17/usage_key' \\\n--header 'SSVM_Admin_Key: 8741ec91-79d4-4718-bce9-d073438ea582'\n```\nThe above request will return a fresh key as shown below.\n```\n{\n    \"SSVM_Usage_Key\": \"c031f2c8-dada-4eff-9a92-8bd63011c7c1\"\n}\n```\nThis `PUT` request is also a great way to refresh keys i.e. change who can access a Wasm executable, after a hackathon or temporary training exercise etc.\n\nTo make a private Wasm executable public, simply perform the following RESTful `DELETE` request\n```\ncurl --location --request DELETE 'https://rpc.ssvm.secondstate.io:8081/api/keys/17/usage_key' \\\n--header 'SSVM_Admin_Key: 8741ec91-79d4-4718-bce9-d073438ea582'\n```\n\n## Ephemeral storage\n- Allows users to quickly store ephemeral information via a RESTful endpoint (no Wasm or Rust required). This is useful for pooling information from IoT sensors or performing tasks such as quickly gathering information per second which is then placed in a batch which may be processed each 60 seconds etc.\n- Allows users to quickly retrieve ephemeral information via RESTful endpoint.\n- Any ephemeral information is saved for up to 1 hour. If the ephemeral information (at the specific key) is updated then the 1 hour limit is restarted.\n\n### Store data and receive a key for future use\n```\ncurl --location --request POST 'https://rpc.ssvm.secondstate.io:8081/api/ephemeral_storage' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{\"some_json\": \"data_to_store_temporarily\"}'\n```\nReturns\n```\n{\"key\":\"e09da790-b072-46e9-9e6c-c879d07376fd\"}\n```\n\n### Use the key to access the data\n```\ncurl --location --request GET 'https://rpc.ssvm.secondstate.io:8081/api/ephemeral_storage/e09da790-b072-46e9-9e6c-c879d07376fd'\n```\nReturns\n```\n{\"value\":{\"some_json\":\"data_to_store_temporarily\"}}\n```\n\n### Update the data\n```\ncurl --location --request PUT 'https://rpc.ssvm.secondstate.io:8081/api/ephemeral_storage/e09da790-b072-46e9-9e6c-c879d07376fd' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{\"asdf\": \"Update the data\"}'\n```\n\n### Delete the data\n```\ncurl --location --request DELETE 'https://rpc.ssvm.secondstate.io:8081/api/ephemeral_storage/e09da790-b072-46e9-9e6c-c879d07376fd'\n```\n\nNow, as promised, let's look at the individual endpoints. \n\n# Endpoints","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json","isPublicCollection":false,"owner":"4967217","collectionId":"84b93d68-2073-4f51-bde3-68f19de57c62","publishedId":"SztA68nE","public":true,"publicUrl":"https://documenter-api.postman.tech/view/4967217/SztA68nE","privateUrl":"https://go.postman.co/documentation/4967217-84b93d68-2073-4f51-bde3-68f19de57c62","customColor":{"top-bar":"FFFFFF","right-sidebar":"303030","highlight":"EF5B25"},"documentationLayout":"classic-double-column","customisation":null,"version":"8.10.0","publishDate":"2020-05-25T06:12:42.000Z","activeVersionTag":"latest","documentationTheme":"light","metaTags":{},"logos":{}},"statusCode":200},"environments":[],"user":{"authenticated":false,"permissions":{"publish":false}},"run":{"button":{"js":"https://run.pstmn.io/button.js","css":"https://run.pstmn.io/button.css"}},"web":"https://www.getpostman.com/","team":{"logo":"https://res.cloudinary.com/postman/image/upload/t_team_logo_pubdoc/v1/team/768118b36f06c94b0306958b980558e6915839447e859fe16906e29d683976f0","favicon":""},"isEnvFetchError":false,"languages":"[{\"key\":\"csharp\",\"label\":\"C#\",\"variant\":\"HttpClient\"},{\"key\":\"csharp\",\"label\":\"C#\",\"variant\":\"RestSharp\"},{\"key\":\"curl\",\"label\":\"cURL\",\"variant\":\"cURL\"},{\"key\":\"dart\",\"label\":\"Dart\",\"variant\":\"http\"},{\"key\":\"go\",\"label\":\"Go\",\"variant\":\"Native\"},{\"key\":\"http\",\"label\":\"HTTP\",\"variant\":\"HTTP\"},{\"key\":\"java\",\"label\":\"Java\",\"variant\":\"OkHttp\"},{\"key\":\"java\",\"label\":\"Java\",\"variant\":\"Unirest\"},{\"key\":\"javascript\",\"label\":\"JavaScript\",\"variant\":\"Fetch\"},{\"key\":\"javascript\",\"label\":\"JavaScript\",\"variant\":\"jQuery\"},{\"key\":\"javascript\",\"label\":\"JavaScript\",\"variant\":\"XHR\"},{\"key\":\"c\",\"label\":\"C\",\"variant\":\"libcurl\"},{\"key\":\"nodejs\",\"label\":\"NodeJs\",\"variant\":\"Axios\"},{\"key\":\"nodejs\",\"label\":\"NodeJs\",\"variant\":\"Native\"},{\"key\":\"nodejs\",\"label\":\"NodeJs\",\"variant\":\"Request\"},{\"key\":\"nodejs\",\"label\":\"NodeJs\",\"variant\":\"Unirest\"},{\"key\":\"objective-c\",\"label\":\"Objective-C\",\"variant\":\"NSURLSession\"},{\"key\":\"ocaml\",\"label\":\"OCaml\",\"variant\":\"Cohttp\"},{\"key\":\"php\",\"label\":\"PHP\",\"variant\":\"cURL\"},{\"key\":\"php\",\"label\":\"PHP\",\"variant\":\"Guzzle\"},{\"key\":\"php\",\"label\":\"PHP\",\"variant\":\"HTTP_Request2\"},{\"key\":\"php\",\"label\":\"PHP\",\"variant\":\"pecl_http\"},{\"key\":\"powershell\",\"label\":\"PowerShell\",\"variant\":\"RestMethod\"},{\"key\":\"python\",\"label\":\"Python\",\"variant\":\"http.client\"},{\"key\":\"python\",\"label\":\"Python\",\"variant\":\"Requests\"},{\"key\":\"r\",\"label\":\"R\",\"variant\":\"httr\"},{\"key\":\"r\",\"label\":\"R\",\"variant\":\"RCurl\"},{\"key\":\"ruby\",\"label\":\"Ruby\",\"variant\":\"Net::HTTP\"},{\"key\":\"shell\",\"label\":\"Shell\",\"variant\":\"Httpie\"},{\"key\":\"shell\",\"label\":\"Shell\",\"variant\":\"wget\"},{\"key\":\"swift\",\"label\":\"Swift\",\"variant\":\"URLSession\"}]","languageSettings":[{"key":"csharp","label":"C#","variant":"HttpClient"},{"key":"csharp","label":"C#","variant":"RestSharp"},{"key":"curl","label":"cURL","variant":"cURL"},{"key":"dart","label":"Dart","variant":"http"},{"key":"go","label":"Go","variant":"Native"},{"key":"http","label":"HTTP","variant":"HTTP"},{"key":"java","label":"Java","variant":"OkHttp"},{"key":"java","label":"Java","variant":"Unirest"},{"key":"javascript","label":"JavaScript","variant":"Fetch"},{"key":"javascript","label":"JavaScript","variant":"jQuery"},{"key":"javascript","label":"JavaScript","variant":"XHR"},{"key":"c","label":"C","variant":"libcurl"},{"key":"nodejs","label":"NodeJs","variant":"Axios"},{"key":"nodejs","label":"NodeJs","variant":"Native"},{"key":"nodejs","label":"NodeJs","variant":"Request"},{"key":"nodejs","label":"NodeJs","variant":"Unirest"},{"key":"objective-c","label":"Objective-C","variant":"NSURLSession"},{"key":"ocaml","label":"OCaml","variant":"Cohttp"},{"key":"php","label":"PHP","variant":"cURL"},{"key":"php","label":"PHP","variant":"Guzzle"},{"key":"php","label":"PHP","variant":"HTTP_Request2"},{"key":"php","label":"PHP","variant":"pecl_http"},{"key":"powershell","label":"PowerShell","variant":"RestMethod"},{"key":"python","label":"Python","variant":"http.client"},{"key":"python","label":"Python","variant":"Requests"},{"key":"r","label":"R","variant":"httr"},{"key":"r","label":"R","variant":"RCurl"},{"key":"ruby","label":"Ruby","variant":"Net::HTTP"},{"key":"shell","label":"Shell","variant":"Httpie"},{"key":"shell","label":"Shell","variant":"wget"},{"key":"swift","label":"Swift","variant":"URLSession"}],"languageOptions":[{"label":"C# - HttpClient","value":"csharp - HttpClient - C#"},{"label":"C# - RestSharp","value":"csharp - RestSharp - C#"},{"label":"cURL - cURL","value":"curl - cURL - cURL"},{"label":"Dart - http","value":"dart - http - Dart"},{"label":"Go - Native","value":"go - Native - Go"},{"label":"HTTP - HTTP","value":"http - HTTP - HTTP"},{"label":"Java - OkHttp","value":"java - OkHttp - Java"},{"label":"Java - Unirest","value":"java - Unirest - Java"},{"label":"JavaScript - Fetch","value":"javascript - Fetch - JavaScript"},{"label":"JavaScript - jQuery","value":"javascript - jQuery - JavaScript"},{"label":"JavaScript - XHR","value":"javascript - XHR - JavaScript"},{"label":"C - libcurl","value":"c - libcurl - C"},{"label":"NodeJs - Axios","value":"nodejs - Axios - NodeJs"},{"label":"NodeJs - Native","value":"nodejs - Native - NodeJs"},{"label":"NodeJs - Request","value":"nodejs - Request - NodeJs"},{"label":"NodeJs - Unirest","value":"nodejs - Unirest - NodeJs"},{"label":"Objective-C - NSURLSession","value":"objective-c - NSURLSession - Objective-C"},{"label":"OCaml - Cohttp","value":"ocaml - Cohttp - OCaml"},{"label":"PHP - cURL","value":"php - cURL - PHP"},{"label":"PHP - Guzzle","value":"php - Guzzle - PHP"},{"label":"PHP - HTTP_Request2","value":"php - HTTP_Request2 - PHP"},{"label":"PHP - pecl_http","value":"php - pecl_http - PHP"},{"label":"PowerShell - RestMethod","value":"powershell - RestMethod - PowerShell"},{"label":"Python - http.client","value":"python - http.client - Python"},{"label":"Python - Requests","value":"python - Requests - Python"},{"label":"R - httr","value":"r - httr - R"},{"label":"R - RCurl","value":"r - RCurl - R"},{"label":"Ruby - Net::HTTP","value":"ruby - Net::HTTP - Ruby"},{"label":"Shell - Httpie","value":"shell - Httpie - Shell"},{"label":"Shell - wget","value":"shell - wget - Shell"},{"label":"Swift - URLSession","value":"swift - URLSession - Swift"}],"layoutOptions":[{"value":"classic-single-column","label":"Single Column"},{"value":"classic-double-column","label":"Double Column"}],"versionOptions":[],"environmentOptions":[{"value":"0","label":"No Environment"}],"canonicalUrl":"https://documenter.gw.postman.com/view/metadata/SztA68nE"}