Is JSON a good choice for a RESTful API? What are the best practices for designing a REST+JSON API that embraces HATEOAS? Nate will cover a number of common design specs and examine their pros and cons.
- [Instructor] The principles of REST and HATEOAS are format agnostic. In other words, a RESTful API could return XML, HTML, JSON, or something else entirely. JSON has increasingly become a popular response format for APIs on the web. Let's take a closer look at the advantages and disadvantages of JSON, and discuss how to properly craft a RESTful JSON API. One of the biggest reasons why JSON has eclipsed XML in popularity is that it's lightweight and easy for humans to read. It's also easy for machines to read because it doesn't require a heavy XML parsing engine.
That means it's easy to find support for reading and writing JSON on almost any platform across the web, plus desktop and mobile devices. On the other hand, because JSON doesn't have a built in way to enforce or even define a document schema, it's much looser than XML. There's no standard way of defining document metadata or guaranteeing clients a particular document structure. To remove this disadvantage, it's a good practice to adopt a standardized schema for your REST API's JSON responses. This way you can benefit from all the folks before you who have had to grapple with the intricacies of modeling RESTful responses with JSON.
There are a number of schemas and formats that have been created to help make building REST plus JSON APIs easier and more consistent. JSON API is a popular specification with a lot of detail. HAL is specifically designed for hypermedia and HATEOAS using JSON or XML. ION is specifically designed for hypermedia, HATEOAS, and JSON. JSON Schema and Collection+JSON are two other formats that share some similarities with the first approaches, but they're a little more limited in scope and are focused on adding generic metadata to a JSON document.
This list is not exhaustive, and there are other options out there, too. For this course, I'm going to use the ION specification as a starting point because in my opinion, it's the simplest and most intuitive. The REST and HATEOAS concepts, like Links, Resources, and Collections apply to whichever schema or format you feel most comfortable with. Next, we'll take a brief tour of the ION format.
- REST vs. RPC
- Using HTTP methods (aka verbs)
- Returning JSON
- Creating a new API project
- Building a root controller
- Routing to controllers with templates
- Requiring HTTPS for security
- Creating resources and data models
- Returning data and resources from a controller
- Representing links (HREFs)
- Representing collections
- Sorting and searching collections
- Creating forms
- Caching and compression
- Authentication and authorization for RESTful APIs
Skill Level Intermediate
Building Web APIs with ASP.NET Corewith Chris Woodruff1h 7m Intermediate
Deploying ASP.NET Core Applicationswith Nate Barbettini57m 57s Intermediate
1. REST API Concepts
2. Building a Basic API
3. Securing the API
4. Representing Resources
5. Representing Links
6. Representing Collections
7. Sorting Collections
8. Searching Collections
9. Forms and Modifying Data
10. Caching and Compression
11. Authentication and Authorization
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.