Building Hypermedia APIs with HTML5 and Node
With this concise book, you’ll learn the art of building hypermedia APIs that don’t simply run on the Web, but that actually exist in the Web. You’ll start with the general principles and technologies behind this architectural approach, and then dive hands-on into three fully-functional API examples.
Too many APIs rely on concepts rooted in desktop and local area network patterns that don’t scale well—costly solutions that are difficult to maintain over time. This book shows system architects and web developers how to design and implement human- and machine-readable web services that remain stable and flexible as they scale.
- Learn the H-Factors for representing application metadata across all media types and formats
- Understand the four basic design elements for authoring hypermedia types
- Convert a simple read-only XML-based media type into a successful API design
- Examine the challenges and advantages of designing a hypermedia type with JSON
- Use HTML5’s rich set of hypermedia controls in the API design process
- Learn the details of documenting, publishing, and registering media type designs and link-relation types
104 110 110 110 111 Design Document The Server Code Authenticating Users Registering a New User Message Responses User Responses The Client Code The POSH Example The Ajax QuoteBot Example Summary 111 113 113 114 116 119 122 122 125 134 5. Documenting Hypermedia . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 Requirements, Compliance, and RFC 2119 The RFC 2119 Keywords Sample Documentation Using RFC 2119 Keywords Defining Compliance Documenting
Media Type | 37 By settling these design questions early, the remaining process will go more smoothly. For this project, the base format selected will be XML. XML is a widely supported format on almost any platform and programming environment. That means we can expect a wide range of client applications to be able to parse and process our Maze Game design. In truth, almost any format will work. For example, there are libraries for the JSON format in a wide range of programming languages, too.
(redirection to a new URI) or simply a 204 - No Content response. The Client Code With the server implementation completed, it’s time to move on to building clients that understand the Collection+JSON hypermedia type. For this chapter, two clients will be implemented. The first will be a browser-based Single Page Interface or SPI client. It relies on a small set of HTML and a script that is capable of parsing, rendering, and processing Collection+JSON messages. In other words, it is a
etc.), the specific hypermedia controls, and the method of expressing state transitions are already decided. This means designers do not need to worry about how to define and document much of the hypermedia type. However, with so many details already decided, there is less room for expressing the problem domain in ways clients can easily understand. This duality of well-defined hypermedia controls and a limit on the options for expressing the problem domain is the key challenge behind working
unique data element/block within the representation name Used to identify a state transition element (i.e. input) within the representation class Used to identify a non-unique data element/block within the representation rel Used to identify a non-unique process flow element within the representation The id attribute can be applied to any element in the document, is a single string value (no spaces allowed), and must be unique in a document: ... The name