The purpose of this video is to present the basic concepts behind CRUD operations and the REST software architecture style.
- [Instructor] Hi and welcome to section two, Implementing Create and Read through a RESTful API. In this section, we will cover what are the basics of REST and CRUD. How can we use SQLAlchemy for data manipulation. How to implement the Create and Read operations using RESTful API. Now we move on to the first video of this section that deals with the CRUD and REST basics. In this video, we are going to take a look at what is CRUD, what does REST stand for and we will check how to add CRUD operations to HTTP verbs.
In the end we will cover a few best practices to keep in mind when we are building RESTful APIs. CRUD is an acronym and stands for create, read, update, and delete. These are the most common operations which we want to have in case of an API, which manipulates data. REST is also an acronym and it's an abbreviation of representational state transfer. Since REST APIs almost always use HTTP as an underlying protocol, the REST API is stateless which means, no data related to the client is stored on the server side and each request contains all the necessary information for the server to fulfill this.
REST API and architecture always involves a client and a server. A system has to be layered in order to extend it and the data has to be cacheable. HTTP verbs or methods can be mapped to CRUD operations. GET method maps to the read operation, POST method maps to the create operation. The DELETE method can be mapped to the delete operation and the PUT method can be mapped to the update operation. There are some guys that say that the PATCH HTTP verb is the actual one which should be used for update but the PUT verb has a more in depth meaning.
If the item, which was updated, exist on the server side, then it will update the data, otherwise, it will try to save the data coming through the request. There are some best practices, which we should be aware of when we are starting to developing a new RESTFUL API. The first rule is we should always have a version for our API and we should use that in all the request you are asked. An HTTP based CRUD RESTful API should always return proper HTTP codes and error codes. Like, HTTP 200 for a successfully handled request or an HTTP 404 in case of a request which does not exist on the server side.
For a secure RESTful API, each request has to be authenticated and validated so we are sure we do not execute data manipulation logic from an anonymous user. Good APIs are built with the possibililty to add caching once this is needed. Starting to use the caching from the beginning can be an overkill because this needs extra maintenance from development and infrastructure point of view. In this video we covered what does CRUD and REST stand for, which HTTP verb should be used for the CRUD operations, and at the end we covered the few but very important best practices to be attentive to when building a new RESTful API.
In the next video we are going to see how to use SQLAlchemy, one of Python's well known algorithms to manipulate the data handled by our API. Thank you for watching and see you in the next video.
Regardless of platform, you will need to build APIs to serve data between different client applications and endpoints. Good APIs are a necessity for web and mobile projects, especially with the modern, mobile-first approach to development. This course delivers the fundamental knowledge required to enable highly connected interactions between applications via RESTful web APIs. Follow along with Gergo Bogdan and learn how to build up and structure an effective web API that can be used by any client application accessing it over HTTP, using Flask, the Python microframework.
Find out how to implement CRUD operations using SQLAlchemy and MySQL as the data store. Get an understanding of how REST works relative to APIs, and learn how to test APIs written in Python with the support of Flask. Explore token-based authentication and find out how to store passwords securely in your database. Along the way, Gergo introduces best practices and design guidelines when building large applications.
- Setting up Flask
- Using Flask templates and routing
- Implementing CRUD operations
- Implementing pagination
- Configuring RESTful authentication
- HTTP caching
- Securing web APIs
- Testing the application