SAFE Network API Documentation

EDIT: SAFE Launcher was reimplemented via the Launcher as a local Rest Server RFC. The SAFE Launcher API documentation is currently hosted at maidsafe.readme.io.


Hey everyone!

I’ve been looking closely at the Launcher as a Service RFC in the last few days and I am super excited to start building my first SAFE app!

It’s currently possible to study the endpoints of the SAFE Launcher API by looking at the Launcher Service Documentation RFC.

The document is very good but I wanted to make it more readable and to add example requests and responses for each of the endpoints. And so I decided to use a service called ReadMe.io to build a good-looking documentation for the SAFE Launcher API.

Here is the website: safe-api.readme.io (this site has been deleted because it was outdated and also because it has been replaced by maidsafe.readme.io).

I’m very open to any suggestions so just let me know if you have any ideas, questions or feedback.

I also added a link to the SAFE Launcher API documentation on https://safenetwork.org/documentation/.

Cheers!

33 Likes

Brilliant work and really easy to read and understand. Many thanks from me as a community member, this is great and will help me as well as I do not get close to that API much. Fantastic, big beer owed.

10 Likes

Brilliant. Absolutely brilliant. Many thanks @frabrunelle!

5 Likes

everything looks amazing!

What is that new site? www.Safenetwork.org I haven’t seen it before. Is it yours? I thought it was the new www.maidsafe.net website for a second!

3 Likes

Yes, I made it a few weeks ago :smiley:

I was planning to announce it on the forum but I haven’t done it yet. So I imagine for many people it will be the first time seeing it :smile:

The source code is on GitHub and anyone is free to submit improvements, additions, fixes, etc.

One of the reasons I made it is that I wanted a place that contains all the important links. Previously I used to send a long email containing many links when I introduced someone to SAFE Network. Now I can just send them a link to safenetwork.org!

1 Like

Thanks @frabrunelle, that’s useful!

As for the API itself, I’m a bit sad that I can’t see how one would create it’s own StructuredData type?

2 Likes

Your site is awesome! Literally everything one needs and all right there looking amazing, great job!

3 Likes

eagerly waiting the StructuredData section :wink:

2 Likes

Yup, StructuredData is where the real fun is!

3 Likes

I have been waiting for this for so long, this is amazing work…

As a beginner and to be a pain in the ass to put a file the code would be simply look like this.???
{
“endpoint”: “safe-api/v1.0/nfs/put-file”,
“data”: {
“is_path_shared”: false,
“file_path”: “/hello_world.txt”,
“offset”: 0,
“length”: 0,
“include_metadata”: true
}
}

or would we simply create a file is the same as sending a file.

3 Likes

Thinking out loud here, but (in python at least) I am probably going to try to create a function that would create that JSON entry for me (with the input that I provide it).

Now, where I’m stuck, is that once I have that JSON entry built up, what do I do with it?!?!

Have a look at the nfs cli example in safe_examples. That does what you’re after. It’s a rust CLI app, pretty much same process should be possible from python as well. We just havent put a python example together. If you do manage to put one together, we can certainly bring that into the safe_examples repo.

3 Likes

There is no endpoint such as "safe-api/v1.0/nfs/put-file".

To put a file, you’ll currently need to use create-file and then modify-file to update its content.

2 Likes

Speaking as one with rather limited code experience I’m finding this documentation to be rather confusing. So some small example applications or code snippets to go with the json to show how the examples would fit into an app would be good as well as annotations to explain in English what it all meant.

You want some SAFE API tutorials! I vote for this :smile: It is a tricky thing though because obviously MaidSafe don’t have the time yet, and the API is still in flux - and even to those who do have technical nous, not well understood.

So I don’t think we’ll see much of this until someone with the time and ability learns to use the API and starts writing a coding tutorial as they go. It is needed, and something I’d like to do if I had the time, but the API is still not stable or clear enough to set things out like this IMO. It is getting there though, and providing a decoupled JSON API is a big step towards this because it reduces the likelihood for API changes considerably, even when something underneath changes.

I’m sure MaidSafe will also have plans to do this if others don’t, but obviously they are busy making it work for now.

5 Likes

Excellent . This will further encourage people to realise their ideas :+1:

2 Likes

Tutorial please anybody somebody… @frabrunelle @bluebird maybe :wink:

I’d be happy to throw some money in a pot for a thorough tut.
Community engagement program perhaps what can be more engaging than educating the community?

4 Likes

I’m trying to use the SAFE api and I’m having issues getting my app authorized. Now I assume its because it isn’t registered as an authorized app in launcher. Which is fine.

Like with DemoApp it has to be authorized. How can I go about doing that with my custom app?

1 Like

You App needs to ask the Launcher for authorisation and the Launcher will then ask the user to confirm. See the /auth documentation. Any of the example applications will be doing this so if you can’t get it working find one that works with the latest v0.5 API and take a look at the source code. I don’t know which community Apps have been updated, but you’ll find the MaidSafe one’s in safe_examples work of course. Don’t follow an App that was written for the earlier (encripted) API though because that won’t work with the Alpha release.

2 Likes

That’s what I’m attempting to do. Unfortunately I continue to get errors. The URLs for API access are documented differently in different places, but I think I’ve resolved that. An issue I’m having is when accessing by GET attempting to auth the response is 400:Unauthorized, which is fine, the app hasn’t been authorized, but when I try with POST (which is what it should be I assume) I get 404:Endpoint Not Found

Not sure what I’m doing wrong exactly. I recall seeing some other sample apps but they’ve disappeared somewhere.