Settings

Theme

Show HN: HyperMap – a new REST API standard that supports client-side JavaScript

github.com

4 points by feichtinger 2 years ago · 0 comments · 2 min read

Reader

Hi HN! HyperMap is a new standard for REST APIs that supports client-side code execution. That means the server can send JavaScript or WebAssembly to the client to run locally. This is the same execution model as the Web, and given that it's pretty clear that client-side JavaScript has been instrumental to the Web's success I think we should be taking advantage of this capability for our APIs.

This project was the result of many years of banging my head against a wall designing and integrating REST APIs. Over that time it feels like we want our APIs to do more and more, and the result is ever more documentation, specifications, and client wrappers/SDKs. It's a ton of work to build, maintain, and integrate. Is that the best we can do?

Two approaches looked promising to me: hypermedia and GraphQL, but having spent time with both I don't think they were the silver bullet I was looking for. Hypermedia's focus on navigation didn't seem to solve problems I saw in most APIs, and GraphQL's initial hype seems to have died somewhat as people realise it's best in quite a narrow domain.

It occurred to me a little while ago that the REST architecture was abstracted from the Web, and includes "code on demand" as an optional constraint — basically, sending JavaScript to run in the client. Could that be useful for APIs? After some experimentation with different hypermedia formats, I ended up designing a new, minimalist format that was very easy for existing JSON-based REST APIs to adopt, along with a mini-DOM like interface for scripts to interact with the representation.

It's early but the results seem exciting! Using HyperMap you can do things like get rid of Webhooks, incorporate live, streaming data into your regular REST responses, and even move processing/analytics to the client for privacy or latency reasons. Because you have the full power of JavaScript and all the modern Web APIs to hand I expect a people to discover a whole load of interesting use cases I haven't even thought of!

I'd love feedback on the direction and the design. The project's very early so there's still a substantial amount of design and development still do — contributions of any kind are more than welcome!

No comments yet.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection