- What is the difference between restful API and traditional API?
- What are the HTTP Methods in RESTful API and when would you use each of these?
- What does this HTTP Status codes represent?
- 1xx
- 2xx
- 3xx
- 4xx
- 5xx
- What is the difference between the following response functions?
- res.send()
- res.json()
- res.render()
- What are the appropriate status code for the following:
- Status Code OK
- Status Code Bad Request
- Status Code Unauthorized
- Status Code Forbidden
- Status Code Not Found
- Status Code Internal Server Error
-
-
Save Kishimoto96/887437cb456f355f4211b1414a63235b to your computer and use it in GitHub Desktop.
Members: İsmail Dincer - Abdulsalam Hamandoush - Mohamad Aid Bacuk Zanab - Radman Lotfiazar - Ahmad Ramin Soleyman Kheyl
1 - API is a bigger umbrella, and REST API is a unique type of API prevalent among mobile and cloud applications. No API is void of disadvantages, but new developers find REST API difficult because it fails to maintain the state within sessions. As modern APIs have emerged as a product that adheres to specified standards and specific audiences, businesses have improved their user interfaces quickly.
2 - GET -> For reading data by retreiving data from server.
POST -> For creating data and pushing it to server.
PUT -> For updating the data.
DELETE -> For deleting the data.
3- 1xx -> Information responses
2xx -> Successful responses
3xx -> Redirection messages
4xx -> Client error responses
5xx -> Server error responses
4- res.send() -> This prints the message inside on the http address.
re.json() -> With this function we responde as a json file.
res.render() -> This renders ejs, html etc. files.
5- Status Code OK -> 200
Status Code Bad Request -> 400
Status Code Unauthorized -> 401
Status Code Forbidden -> 403
Status Code Not Found -> 404
Status Code Internal Server Error -> 500
Omid Kayhani | Omar Qaqish | Cansu Aysagdic | Sara Nafisa | Joud Khanji
-
RESTful APIs are stateless. They separate the client side from the server side, which enhances speed and scalability. They enable caching, which enhances speed, and they are independent of the programming language and the OS. They are scalable because they are based on HTTP.
-
GET — retrieve a specific resource or a collection of resources
POST — create a new resource
PUT — update a specific resource
DELETE — remove a specific resource -
1xx - informational responses | 2xx - successful responses | 3xx - redirects | 4xx - client errors | 5xx - server errors
-
res.send() function is used to send a response of various types. It automatically sets the Content-Type header based on the type of response being sent.
res.json() function is used to send a JSON response to the client. It sets the Content-Type header to application/json and sends the JSON response as the body of the response.
res.render() function is used to render a view template and send the HTML response to the client. It is used when you want to send dynamic HTML pages based on the data you have.
5.Status Code OK - 200
Status Code Bad Request - 400
Status Code Unauthorized - 401
Status Code Forbidden - 403
Status Code Not Found - 404
Status Code Internal Server Error - 500
- Abdulrahman Albakkar
- Abdullah Karakali
- Atakan Serbes
- Abdullah Amin
Q1.
RESTful APIs typically use HTTP requests to post, read, and delete data, while traditional APIs can use any communication protocol. RESTful APIs differ in architectural style and the way they handle requests and responses.
Q2.
GET: Used to retrieve information from the server.
POST: Used to create new resources on the server.
PUT: Used to update existing resources on the server.
DELETE: Used to remove resources from the server.
PATCH: Used to modify an existing resource on the server.
Q3.
1xx = Informational
2xx = Successful
3xx = Redirection
4xx = Client Error
5xx = Server Error
Q4.
res.send() = Used to send a response of various data types, including strings, HTML, JSON, and more.
res.json() = Used to send JSON data in the response body.
res.render() = Used to render an HTML view using a template engine such as Pug or EJS.
Q5.
Status Code OK = 200
Status Code Bad Request = 400
Status Code Unauthorized = 401
Status Code Forbidden = 403
Status Code Not Found = 404
Status Code Internal Server Error = 500
iroda, @Mustapha909 , @tomiece317 , Saıd Baradaı, Muhammed Mustafa Alaaddaf
1-
Traditional APIs are based on remote procedures or methods, while RESTful APIs follow architectural principles and use HTTP methods to manipulate resources identified by URIs. RESTful APIs are stateless and use standard HTTP response codes. They are considered more flexible, scalable, and simpler to use than traditional APIs.
Client server : client and server are separated from one another, and each of them can grow individually. This is what flexibility is all about.
Scalability : Scalability is a major issue in general APIs. It is not so in REST APIs, and it is because of its layered architecture that works together. They form a hierarchy, and therefore, the modular application is possible which is the key to scalability.
Miscellaneous: REST APIs are the only few APIs that allow code on demand to be transmitted. One of the biggest advantages has to be the fact that the users do not have to know the function names and the parameters in a specific order to execute the REST APIs.
2-
GET: Used to retrieve a resource identified by a URI.
POST: Used to create a new resource or submit data to be processed by a resource.
PUT: Used to update an existing resource identified by a URI, or to create a new resource if it doesn't exist.
DELETE: Used to delete a resource identified by a URI.
PATCH: Used to update a portion of an existing resource identified by a URI.
HEAD: Used to retrieve metadata about a resource without retrieving the resource itself.
OPTIONS: Used to retrieve information about the communication options available for a resource.
3-
1xx (Informational): These codes indicate that the server has received the client's request and is continuing to process it.
2xx (Success): These codes indicate that the server has successfully received, understood, and processed the client's request.
3xx (Redirection): These codes indicate that the client must take additional action to complete the request, such as following a redirect or providing authentication credentials.
4xx (Client Error): These codes indicate that the client's request was invalid or cannot be fulfilled, such as due to a missing parameter or incorrect credentials.
5xx (Server Error): These codes indicate that there was an error on the server side while processing the request, such as a timeout or internal server error.
4-
res.send(): Sends a generic HTTP response with optional data as the body. It can send various types of data, including strings, buffers, and JSON objects.
res.json(): Sends a JSON response with the specified JSON data in the body. It automatically sets the content-type header to application/json and stringifies the JSON data.
res.render(): Renders a view template and sends the HTML generated by the view as the response. It is typically used with template engines such as EJS or Handlebars to generate dynamic HTML content.
5-
Status Code OK: 200 OK
Status Code Bad Request: 400 Bad Request
Status Code Unauthorized: 401 Unauthorized
Status Code Forbidden: 403 Forbidden
Status Code Not Found: 404 Not Found
Status Code Internal Server Error: 500 Internal Server Error
team: @Khaled6120 @nourkrimesh @abdurrahmanabzd
- API uses HTTP protocols to retrieve, update, and delete data. RESTful APIs have a simpler and more flexible approach for web applications, are more scalable, and easier to maintain.
- GET:Used to retrieve data from the server
POST:Used to create new resources on the server.
PUT:Used to update existing resources on the server
DELETE:Used to delete resources from the server.
1xx - Informational
This category indicates that the server has received the request and is continuing to process it. It is usually used for protocols that require extended communication, such as WebSocket or long-polling.
2xx - Success
This category indicates that the request has been successfully received, understood, and accepted by the server.
3xx - Redirection
This category indicates that the client must take additional action to complete the request. It is typically used for redirects or to indicate that a resource has moved.
4xx - Client Errors
This category indicates that the client has made an error in the request, such as a syntax error or requesting a resource that does not exist.
5xx - Server Errors
This category indicates that the server has encountered an error while processing the request. It is usually due to a temporary or permanent server issue.
4. res.send() is used to send a generic response, res.json() is used to send a JSON response, and res.render() is used to render and send an HTML view.
Status Code OK: 200
Status Code Bad Request: 400
Status Code Unauthorized: 401
Status Code Forbidden: 403
Status Code Not Found: 404
Status Code Internal Server Error: 500
Room 10: @badrnasher , @MOHAMMAD-ALMOHAMMAD , @heisenberg550 , @ahmadalashtar01 , @Younesnz
1- Traditional APIs rely on SOAP (Simple Object Access Protocol) and have a more rigid structure, while RESTful APIs use HTTP and have a more flexible structure.
Traditional APIs typically use XML for data exchange, while RESTful APIs support a variety of formats.
RESTful APIs are designed to be stateless, meaning that the server doesn't need to keep track of the client's state between requests, while traditional APIs may require stateful communication.
2- There are 4 basic HTTP verbs we use in requests to interact with resources in a REST system:
- GET: Requests a representation of the specified resource. Requests using GET should only retrieve data.
- HEAD: Asks for a response identical to that of a GET request, but without the response body.
- POST: Used to submit an entity to the specified resource, often causing a change in state or side effects on the server.
- PUT: Replaces all current representations of the target resource with the request payload.
- DELETE: Requests to delete the specified resource.
- CONNECT: Establishes a tunnel to the server identified by the target resource.
- OPTIONS: Used to describe the communication options for the target resource.
- TRACE: Performs a message loop-back test along the path to the target resource.
- PATCH: Used to apply partial modifications to a resource.
3-
- 1XX: INFORMATIONAL
- 2XX: SUCCESS
- 3XX: REDIRECTION
- 4XX: CLIENT ERROR
- 5XX: SERVER ERROR
4-
- res.send(): It can be used to send a response to an HTTP request with various types of data, such as plain text, HTML, Buffers, or JSON. It automatically sets the content-type header based on the type of the data being sent.
- res.json(): This function is used to send a response body in the form of JSON (JavaScript Object Notation)
- res.render(): This function is often used to render a view template with dynamic data.
5-
- Status Code OK: 200
- Status Code Bad Request: 400
- Status Code Unauthorized: 401
- Status Code Forbidden: 403
- Status Code Not Found: 404
- Status Code Internal Server Error: 500
// Team Members: @fatimaali200, @aydinfz, @irzooqi, @AsliSema, @afrakucukaydin, @0Rawan
-
The main difference between a RESTful API and a traditional API lies in their architecture and the way they handle requests and responses. Traditional APIs typically use a Remote Procedure Call (RPC) model and rely on libraries and frameworks, while RESTful APIs are based on the principles of the Representational State Transfer (REST) architecture and use standard HTTP methods to perform operations on resources. RESTful APIs are also stateless, which makes them more scalable and easier to maintain. (Resource-based,Stateless,Cacheable,Uniform Interface.)
-
HTTP methods: put, post, get, delete, head, patch, options.
GET: Requests a representation of the specified resource. Requests using GET should only retrieve data.
HEAD: Asks for a response identical to that of a GET request, but without the response body.
POST: Used to submit an entity to the specified resource, often causing a change in state or side effects on the server.
PUT: Replaces all current representations of the target resource with the request payload.
DELETE: Requests to delete the specified resource.
CONNECT: Establishes a tunnel to the server identified by the target resource.
OPTIONS: Used to describe the communication options for the target resource.
TRACE: Performs a message loop-back test along the path to the target resource.
PATCH: Used to apply partial modifications to a resource.
1xx (Informational)
2xx (Successful)
3xx (Redirection)
4xx (Client Error)
5xx (Server Error)
-
We use res.send(), res.json(), and res.render() to send data to the client. res.send() is a generic function that can be used to send any type of response, while res.json() is used specifically for sending JSON responses, and res.render() is used for rendering views and sending HTML responses.
Status Code OK (200)
Status Code Bad Request (400)
Status Code Unauthorized (401)
Status Code Forbidden (403)
Status Code Not Found (404)
Status Code Internal Server Error (500)
1- Rasam Rabiee @cyberRasam
2- Baraah Masri
3- Talal Bakkour
4- Nour Eddin Hamouda
Answers :
1- A traditional API, also known as a SOAP API, relies on XML as a format for exchanging data and is typically accessed using the Simple Object Access Protocol (SOAP). On the other hand, a RESTful API is a more flexible approach to web services, relying on HTTP and the principles of Representational State Transfer (REST), It uses a lightweight data format, such as JSON or XML, for exchanging data and supports a wider range of HTTP methods (GET, POST, PUT, DELETE, etc.). While REST API and RESTful API are often used interchangeably, they have distinct differences. REST API is an API that follows the principles of the REST architecture, while RESTful API is an API that follows the principles of the REST architecture and meets specific requirements1.
2-
GET: Requests a representation of the specified resource. Requests using GET should only retrieve data.
HEAD: Asks for a response identical to that of a GET request, but without the response body.
POST: Used to submit an entity to the specified resource, often causing a change in state or side effects on the server.
PUT: Replaces all current representations of the target resource with the request payload.
DELETE: Requests to delete the specified resource.
CONNECT: Establishes a tunnel to the server identified by the target resource.
OPTIONS: Used to describe the communication options for the target resource.
TRACE: Performs a message loop-back test along the path to the target resource.
PATCH: Used to apply partial modifications to a resource.
3- HTTP status codes are three-digit numbers that indicate the status of a web server’s response to a client’s request. The first digit of the status code defines the class of response. The last two digits do not have any categorization role. There are five classes of HTTP status codes:
1xx (Informational): These status codes indicate a provisional response. The client should continue with its request.
2xx (Successful): These status codes indicate that the server successfully processed the request and returned the expected response.
3xx (Redirection): These status codes indicate that further action needs to be taken by the user agent in order to fulfill the request.
4xx (Client Error): These status codes indicate that the client has made an error in its request.
5xx (Server Error): These status codes indicate that the server has encountered an error while processing the request.
4- res.send(): This method sends a simple response to the client. It can send a string, buffer, HTML, or JSON data. If you pass a string, it will be sent as plain text. If you pass JSON data, it will be sent as an application/JSON content type. res.send('Hello World!');
res.json(): This method sends a JSON response to the client. It automatically sets the content type to application/JSON. res.json({ message: 'Hello World!' });
res.render(): This method is used to render a view and send the HTML to the client. It is typically used with a templating engine like EJS, Handlebars, or Pug.
res.render('index', { title: 'Homepage' });
5-
Status Code OK: 200
Status Code Bad Request: 400
Status Code Unauthorized: 401
Status Code Forbidden: 403
Status Code Not Found: 404
Status Code Internal Server Error: 500
@Mahmoud-Alshahin @Berra-Mahmut @Harith-Riyadh @Guled-Khadar-Abdi
1- * APIs: uses XML to communicate between different systems, and it uses HTTP POST or GET requests to exchange information between systems.
RESTful APIs: uses a common set of HTTP verbs like GET, POST, PUT, and DELETE to perform operations on resources, and it also uses HTTP requests to perform CRUD (Create, Read, Update, and Delete) operations on resources identified by URIs (Uniform Resource Identifiers)
the main difference between RESTful APIs and traditional APIs is their architectural style and the way they handle data. Traditional APIs use a Remote Procedure Call (RPC) style, while RESTful APIs use a more lightweight and flexible architecture based on the principles of Representational State Transfer (REST). RESTful APIs are generally considered to be more flexible, scalable, and easier to work with than traditional APIs, although they may not always be the best choice for every use case.
2- The primary or most-commonly-used HTTP verbs (or methods, as they are properly called) are POST, GET, PUT, PATCH, and DELETE.
POST for Create ,
GET for read,
Put for update/replace
PATCH for update /modify
DELETE for delete
3-Informational responses(100 – 199)
Successful responses (200 – 299)
Redirection messages (300 – 399)infor
Client error responses (400 – 499)
Server error responses(500 – 599)
4- res.send() to send information to client
res.json() to have json
res.render() to render on client side
5-Status Code OK 200
Status Code Bad Request 400
Status Code Unauthorized 401
Status Code Forbidden 403
Status Code Not Found 404
Status Code Internal Server Error 500
Ozlem Keles, Motaz Ali, Nezir Aydin, Tareq Harh, Jimaa Maya
1- A traditional API, also known as a SOAP (Simple Object Access Protocol) API, relies on XML (eXtensible Markup Language) to structure data and uses HTTP (Hypertext Transfer Protocol) for communication. It usually requires a lot of boilerplate code and is more rigid in terms of what it can do.
On the other hand, a RESTful API (Representational State Transfer) is more flexible and lightweight. It uses HTTP methods (GET, POST, PUT, DELETE) to manipulate data and can return data in various formats, such as JSON (JavaScript Object Notation), XML, or even HTML. RESTful APIs rely on a resource-based architecture, where each resource (such as a customer or an order) is identified by a unique URL, and its state is represented by the HTTP methods and responses.
Stateless Design: RESTful APIs are stateless, meaning that each request from a client to a server must contain all the necessary information to understand and process the request. The server does not store any client context between requests, which allows for scalability and simplicity in the API design.
2- POST = Post is to create new subordinate resources,
GET: get is to retrieve resource representation/information only.
PUT: to update an existing resource (if the resource does not exist, then API may decide to create a new resource or not).
PATCH: to make a partial update.
DELETE: delete a resource.
3-Informational responses (100 – 199)
Successful responses (200 – 299)
Redirection messages (300 – 399)
Client error responses (400 – 499)
Server error responses (500 – 599).
4-res.render() it's used for rendering a HTML or EJS templates.
res.send() is a general-purpose function that can send responses of different types.
res.json() is specifically used to send JSON responses.
5- 200 OK
400 bad requests
401 Code Unauthorized
403 Code Forbidden
404 Code Not Found
500 Code Internal Server Error
@HishamWattar @handedemirbay @MasterOfAlune @muhammedhasann @ilaydanurguzel1
1- an RESTful API tries to model everything in CRUD operations. This is, definitely, a nice way to define it. There are other types of APIs such as AsyncAPI, gRPC or GraphQL.
A traditional API it's merely an interface between two processes or systems. It's a broader concept.
2- GET: to get informations
POST: to post data:
PUT: Update/Replace:
PATCH: Update/Modify
DELETE: Delete
3- 1xx informational response – the request was received, continuing process. 2xx successful – the request was successfully received, understood, and accepted. 3xx redirection – further action needs to be taken in order to complete the request. 4xx client error – the request contains bad syntax or cannot be fulfilled.
4- res.send() to send as string
res.json() to read json
res.render() to render view files
5- Status Code OK: 200
Status Code Bad Request: 400
Status Code Unauthorized: 401
Status Code Forbidden: 403
Status Code Not Found: 404
Status Code Internal Server Error: 500