Learn what REST is (and what it isn't), and what "resources" are in the context of REST.
- The internet is full of code and opinions on REST and building RESTful APIs. REST stands for Representational State Transfer but what exactly does that mean and what does it mean for an API to be "RESTful"? Let's first clear up some misconceptions and look at what REST is not. Contrary to popular belief, simply using HTTP methods like GET and POST doesn't make your API RESTful. That just means that you're using HTTP. And just because an API returns JSON, doesn't make it RESTful either. There are plenty of non-REST APIs that return JSON.
Finally just because your API supports CRUD operations, like creating and deleting, doesn't make it RESTful. RESTful APIs do use HTTP methods and can return JSON and can model CRUD operations but that's not specifically what makes an API RESTful. What REST is is all about modeling your API around resources and allowing clients to perform operations on those resources. In the context of REST, a resource is any object in your API's design domain. Things like documents, users, orders, reservations, and tasks.
In many cases a resource will correlate exactly with a row in a table or an object in the database but that's not always the case. So instead of having API endpoints that are verbs or represent actions you can take in the system, the endpoints in a RESTful API represent resources or collections of those resources. In addition, relationships between data are represented by relationships between the resources in your API. For example, in the API we'll design for Landon Hotels, a user could have a one-to-many relationship with reservations at the hotel.
Each reservation resource would then have a link to the corresponding user resource. RESTful APIs also need to allow the client to act on a resource, to change some state in the system, like creating a new reservation or updating a user's details. After the state has been updated on the server, some representation of that new or updated state needs to be returned to the client. That's where the name representational state transfer comes from. You might be thinking that this all sounds vaguely familiar and it is. It's almost identical to the way a web browser works with HTML.
In fact, web browsers are a great way to get a feel for how REST APIs and REST clients work. We'll explore more of this similarity later in the course. To sum it up, REST is all about modeling your API around resources, links between those resources, and ways to change or act upon those resources. Next we'll dig deeper into what this means and compare REST with another popular style of APIs called RPC.
Author
Released
9/21/2018- What is RESTful design?
- Building a new API with ASP.NET Core
- Using HTTP methods
- Returning JSON
- Creating RESTful routing with templates
- Versioning
- Securing RESTful APIs with HTTPS
- Representing resources
- Representing links
- Representing collections
- Sorting and searching collections
- Building forms
- Adding caching to an ASP.NET Core API
- Configuring user authentication and authorization
Skill Level Intermediate
Duration
Views
Related Courses
-
Designing RESTful APIs
with Keith Casey1h 24m Intermediate -
API Testing and Validation
with Keith Casey1h 13m Intermediate -
Deploying ASP.NET Core Applications
with Nate Barbettini1h 1m Intermediate
-
Introduction
-
1. REST API Concepts
-
What is REST?2m 37s
-
REST vs. RPC3m 24s
-
HTTP methods5m 4s
-
Full and partial updates1m 47s
-
Returning JSON2m 4s
-
The Ion hypermedia type1m 25s
-
-
2. Build a Basic API
-
Create a new project1m 20s
-
Configure MVC1m 45s
-
Create a root controller2m 46s
-
Test with Postman1m 13s
-
Introduction to OpenAPI1m 17s
-
Add NSwag to the project2m 28s
-
-
3. Versioning and Errors
-
Approaches to API versioning1m 52s
-
Add versioning support2m 45s
-
Serialize exceptions as JSON4m 11s
-
-
4. Secure the API
-
Require HTTPS3m 11s
-
How CORS works3m 1s
-
Add CORS middleware1m 33s
-
5. Represent Resources
-
Create a resource class2m 19s
-
Load data from configuration1m 35s
-
Set up an in-memory database2m 22s
-
Create data model classes1m 44s
-
Map models automatically3m 47s
-
-
6. Represent Links
-
Create a Link class4m 48s
-
Rewrite Links with a filter9m 47s
-
Rewrite resource HREFs4m 4s
-
-
7. Represent Collections
-
Add pagination7m 37s
-
8. Sorting Collections
-
Add sort attributes4m 28s
-
Validate sort parameters6m 58s
-
Add a default sort term3m 18s
-
9. Searching Collections
-
Add search attributes3m 35s
-
Validate search parameters7m 42s
-
Extend search to other types5m 21s
-
Add comparison operators3m 30s
-
10. Forms and Modifying Data
-
Forms in Ion1m 32s
-
Create a POST action13m 32s
-
Delete a resource3m 25s
-
Serialize the form metadata3m 54s
-
-
11. Caching and Compression
-
Compress responses1m 36s
-
How HTTP caching works4m 20s
-
Support the ETag header5m 7s
-
Add server-side caching3m 48s
-
-
12. Authentication and Authorization
-
Authentication for REST APIs3m 21s
-
Add Identity4m 51s
-
Add a test user3m 21s
-
Create a users collection5m 45s
-
Add OpenIddict4m 12s
-
Add a token endpoint2m 6s
-
Create a UserInfo route5m 28s
-
More about OpenID Connect2m 59s
-
Authorization using policies5m 19s
-
Conclusion
-
Next steps59s
-
- 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.
CancelTake 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.
Share this video
Embed this video
Video: What is REST?