This is a topic for discussing what REST APIs for Autonomi are wanted, feedback on what exists and so on.
This is not just for dweb, although that’s what I will be focusing on. Any RESTful API is welcome here and if we can work towards common standards that would be great - but for now I just want to get some useful APIs in place so folk can try out building dynamic web apps for Autonomi.
Here’s my first question, but devs feel free to open discussion on any REST API for Autonomi.
dweb
I’m working on REST APIs for Autonomi functions and have POST/GET for a few types working (archives POST/GET, files multipart-POST/GET, data GET etc).
EDIT: For the moment I’m focused on web clients so expect JSON payloads and responses (although for /data which gets data using a datamap or data address the response is binary so you can load directly into a browser). If you need binary POST/GET let me know. I’ll be doing it anyway at some point but will prioritise based on what folk want.
So, with a JS web app client in mind here’s a simple example I made (literally yesterday):
/chunk POST/GET
I have just implemented Chunk POST/GET but to start with have the client supplying the content with a simple JSON object, which mirrors the following DwebChunk struct in Rust:
pub struct DwebChunk {
content: String,
}
So in JSON the client would create a JSON object to POST to /chunk which looks like this:
{
"content": "hi, I'm a chunk"
}
The response is a PutResult (in Rust) which for the above returns the following JSON to the client:
{
"dweb_type": "Chunk",
"status": 200,
"status_message": "success",
"cost_in_attos": "3",
"file_name": "",
"full_path": "",
"data_address": "a31f27622645bb1a467d0e1d8e9b169de1a907f170291e1cbe28ad3c3fbfdc2c",
"data_map": ""
}
I return similar JSON for other POST and PUT operations with content depending on the type of data being stored, and whether it succeeds.
Feedback
Comments, suggestions and requests on any of this are welcome but for now I’m wondering about the JSON used to POST a Chunk. Using a String is limited, but JSON support for binary also not great so any ideas?
What additional JSON options would be useful for the data and using what encoding? For binary it might be a base64 or IntelHex ecoding for example, both of which are discussed on StackOverflow here.
For now I will publish as is, but will update this depending on feedback. If you have requests or suggestions relating to any Autonomi data types, please reply here too.
Next I’m working on Pointer, Scratchpad and probably Vault but for now from a web JS client perspective. So if you need non-JS stuff shout!
Thanks, and if you want to try the dweb REST APIs, see here.