Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve http api #2803

Open
ligi opened this issue Jun 3, 2016 · 7 comments
Open

improve http api #2803

ligi opened this issue Jun 3, 2016 · 7 comments
Labels
kind/enhancement A net-new feature or improvement to an existing feature status/deferred Conscious decision to pause or backlog topic/api Topic api topic/rpc-api Issues related to Kubo RPC API at /api/v0

Comments

@ligi
Copy link

ligi commented Jun 3, 2016

the http api is weird - already had a short conversation about this in the chat - but I think it is better to put this in an issue.

ping currently returns:

⋊> ~ curl http://127.0.0.1:5001/api/v0/ping/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ                                     20:11:57
{"Success":false,"Time":0,"Text":"PING QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ."}
{"Success":true,"Time":745266337,"Text":""}
{"Success":true,"Time":1375473326,"Text":""}
{"Success":true,"Time":230373161,"Text":""}
{"Success":true,"Time":337280582,"Text":""}
{"Success":true,"Time":220376323,"Text":""}
{"Success":true,"Time":928059102,"Text":""}
{"Success":true,"Time":2793408162,"Text":""}
{"Success":true,"Time":1162895192,"Text":""}
{"Success":true,"Time":403357018,"Text":""}
{"Success":true,"Time":1845389336,"Text":""}
{"Success":false,"Time":0,"Text":"Average latency: 1004.19ms"}

would be great if it returns just one json-object

swarm/peers currently returns

⋊> ~ curl http://127.0.0.1:5001/api/v0/swarm/peers                                                                             20:12:13
{"Strings":["/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ","/ip4/104.155.108.198/tcp/4001/ipfs/QmPTv1iPJVRmN4rpBfExHcFKCrGH3W36kbstidWsxhCqL9","/ip4/104.168.165.201/tcp/4001/ipfs/Qmabn7SBBfdNQ1oz6GMhaqpu3iA2Z8ymtnbz8iRTxwz4yf","/ip4/104.236.151.122/tcp/4001/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx","/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z","/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM","/ip4/104.236.32.22/tcp/4001/ipfs/QmepsDPxWtLDuKvEoafkpJxGij4kMax11uTH7WnKqD25Dq"]}

better replace Strings withPeers or just the array without the container

⋊> ~ curl "http://127.0.0.1:5001/api/v0/refs/local"                                                                            20:44:30
QmNza5PEZ6oxqHNqyrNaCr3ExYU3DWsAqwhewNZ1ieuNGe
QmPFDyWdL6yjz92jdc6bzWXHKVvydAhgTzhefSmmkDXzSZ
QmPLJFteJYPXvF7g4dANY6gSgH6Cag1affR3YxuoKTvh91
QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB
QmRgiVzNguvAYcNeDJSymMKUdfW8J3HRKHzM9hPhMFqoVw
QmS7wsF77dKWdStTBv8uqwyEUbzAzANArvsAkJ7bPzzVus
QmSEbwQ8nE1ERTJnV2zydcefcPJsNNWD83uj2euWcwzoZz
QmTumTjvcYCAvRRwQ8sDRxh8ezmrcr88YFU7iYNroGGTBZ
QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn
QmUzLxaXnM8RYCPEqLDX5foToi5aNZHqfYr285w2BKhkft
QmVUr1TPALJz5W7HwFi8yLwSJxTVjdwD95WcdkwZP4MMSh
QmVtU7ths96fMgZ8YSZAbKghyieq7AjxNdcqyVzxTt3qVe
QmY5heUM5qgRubMDD1og9fhCPA6QdkMp3QCwd4s7gJsyE7
QmYTFEAfxC5hQxJ8PivTmcNokRmm3UNsDoDja6CPAqp1Tt
QmYYohSgQ4CAZnPeVxBetkbPNJ9k1rRLJpugsMHQ9j61Pm
QmYhpiVpT2oZTecuTtaFfj5fdbZKHXwjHJ9QLPrGWD9seX
QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG

this could use some json wrapping



⋊> ~ curl "http://127.0.0.1:5001/api/v0/repo/gc"                                                                               21:13:49
{"Key":"QmPLJFteJYPXvF7g4dANY6gSgH6Cag1affR3YxuoKTvh91"}
{"Key":"QmRgiVzNguvAYcNeDJSymMKUdfW8J3HRKHzM9hPhMFqoVw"}
{"Key":"QmS7wsF77dKWdStTBv8uqwyEUbzAzANArvsAkJ7bPzzVus"}
{"Key":"QmSEbwQ8nE1ERTJnV2zydcefcPJsNNWD83uj2euWcwzoZz"}
{"Key":"QmUzLxaXnM8RYCPEqLDX5foToi5aNZHqfYr285w2BKhkft"}
{"Key":"QmVUr1TPALJz5W7HwFi8yLwSJxTVjdwD95WcdkwZP4MMSh"}

could be just a string array


⋊> ~ curl "http://127.0.0.1:5001/api/v0/pin/ls"
{"Keys":{"foo":{"Type":"recursive"} ..

the Keys is a bit weird - I think Pins would be better

@dignifiedquire
Copy link
Member

As far as I know there was a conscious decision to use ndjson for all streaming type output. The ping is streaming the answers it gets and so if you do the request it streams in parts of ndjson, so it is consistent with other things as far as I understand.

@Kubuxu
Copy link
Member

Kubuxu commented Jun 3, 2016

Same thing with repo gc and refs local.

Also I think that stand alone array isn't valid JSON object, as for the specs.

@ligi
Copy link
Author

ligi commented Jun 3, 2016

@Kubuxu it is: http://www.ietf.org/rfc/rfc4627.txt ( http://stackoverflow.com/a/18202619 )

@dignifiedquire ok with the ndjson - but I still think the API is very inconsitent - and /refs/local is really wrong

@Kubuxu
Copy link
Member

Kubuxu commented Jun 3, 2016

Yup, refs local is really wrong.

@whyrusleeping
Copy link
Member

yeah... refs local appears to in all cases directly write b58 marshalled keys to the output. thats... wrong

@Kubuxu
Copy link
Member

Kubuxu commented Jun 3, 2016

I will fix it.

@Kubuxu Kubuxu self-assigned this Jun 3, 2016
@Kubuxu Kubuxu added kind/enhancement A net-new feature or improvement to an existing feature topic/api Topic api labels Jun 3, 2016
@Kubuxu
Copy link
Member

Kubuxu commented Jun 6, 2016

The refs local was PRed in #2812, if you have any more notes about API state, please post them here.

@Kubuxu Kubuxu removed their assignment Jun 21, 2016
@whyrusleeping whyrusleeping added the status/deferred Conscious decision to pause or backlog label Sep 14, 2016
@daviddias daviddias added the topic/rpc-api Issues related to Kubo RPC API at /api/v0 label Oct 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement A net-new feature or improvement to an existing feature status/deferred Conscious decision to pause or backlog topic/api Topic api topic/rpc-api Issues related to Kubo RPC API at /api/v0
Projects
None yet
Development

No branches or pull requests

5 participants