Introducing REST API
Representational State Transfer (REST) is an architectural style that defines a set of constraints to be used for creating web services. REST API is a way of accessing web services in a simple and flexible way without having any processing.
In HTTP there are four methods that are commonly used in a REST-based Architecture i.e., POST, GET, PUT, and DELETE. These correspond to create, read, update, and delete (or CRUD) operations respectively.
GET: This method allows for the server to find the data you requested and sends it back to you.
PUT: If you perform the ‘PUT’ request, then the server will update an entry in the database.
POST: This method permits the server to create a new entry in the database.
DELETE: This method allows the server to delete an entry in the database.
In this tutorial, we will practice these methods (CRUD) and use the following components:
- Postman: Postman is a standalone software testing API (Application Programming Interface) platform to build, test, design, modify, and document APIs. We will use this tool to make HTTP GET, POST, PUT, DELETE requests.
- Curl: Curl is a command-line tool for transferring data from a client or to a server, designed to work without user interaction. With Curl, you can upload or download data using one of the supported protocols, including HTTP, HTTPS, SCP, SFTP, and FTP. Like using Postman, e will use this tool to make HTTP GET, POST, PUT, DELETE requests. Windows 10 already contains Curl, but for Windows 7 and 8, you still need to download and install Curl from the official website.
- CRUD a post via REST API from the web site https://istqblearning.com/.
- Using API Basic Authentication. There are many other types such as JWT Authentication, API Key Authentication, OAUTH 2.0 Authentication… Basic authentication is a simple authentication protocol used to authenticate users when accessing a web application or a web server. It involves sending a username and password to the server in plaintext, encoded using Base64 encoding, as part of an HTTP request.