Additional Node HTTP Endpoints
Overview
edited 5/30/19
A high priority TODO is migrating the RPCs to HTTP to allow for more flexibility. This should be fairly straight forward to accomplish since most of the code has already been written and just needs to be adapted to using the HTTP resources instead of the RPC resources.
Proposal
Additional Endpoints to be added:
| RPC | HTTP |
|---|---|
getnameinfo |
GET /name/:name |
getnamebyhash |
GET /name/hash/:hash |
getnameresource |
GET /resource/name/:name |
getnameresourcebyhash |
GET /resource/hash/:hash |
getnameproof |
GET /proof/name/:name |
gtetnameproofbyhash |
GET /proof/hash/:hash |
grindname |
GET /grind?size=int |
sendrawclaim already is implemented as POST /claim
This work has been started here:
- https://github.com/tynes/hsd/blob/node-http/lib/node/http.js
- https://github.com/handshake-org/hsd/pull/168
Previous Issues mentioning this include https://github.com/handshake-org/hsd/issues/12, https://github.com/handshake-org/hsd/issues/126
Quick Question!
This guy: getnamebyhash has route shaped like GET /name/hash/:hash
Top level resource being "name" feels right to me.
However, the other calls have a different shape!
- getnameinfo
GET /info/name/:name- "Info" top level
- getnameresource
GET /resource/name/:name- "Resource" top level
- getnameproof
GET /proof/name/:name- "Proof" top level
Would you be opposed to something more rest-ish? Like:
- getnameinfo
GET /name/info/:name- "Name" top level
- Route param
:nameend of the path.
- getnameresource
GET /name/resource/:name- "Name" top level
- Route param
:nameend of the path.
- getnameproof
GET /name/proof/:name- "Name" top level
- Route param
:nameend of the path.
- grindname
GET /name/grind?size=int- "Name" top level
- getnamebyhash
GET /name/hash/:hash- "Name" top level
- Route param
:hashend of the path. - Hash is hex encoded.
@wi-ski Thanks for your suggestions.
What do you think of the edits made to the original post? The API is being structured this way to keep it similar to the rest of the codebase.
See this endpoint:
https://github.com/handshake-org/hsd/blob/master/lib/node/http.js#L159
// UTXO by address
GET /coin/address/:address
Since a coin is synonymous with a UTXO, the resource being fetched is the top level resource and then how its being fetched is the next level resource. We would like to try to maintain consistency within the codebase.
Yesss - gotcha. Makes sense, ill make those changes to https://github.com/handshake-org/hsd/pull/168
Note: gtetnameproofbyhash => gettnameproofbyhash (spelling)