REST API's Flashcards
What is REST & RESTful API?
Representational state transfer
It’s an architectural style for designing networked applications. REST is a set of guidelines for creating API’s
What are the top 5 REST guidelines and the advantages of them?
- Separation of client and server
- Stateless
- Uniform interface
- Cacheable
- Layered system
What are the differences between SOAP API and REST API?
Architecture: REST is an architectural style, SOAP is a protocol (Simple Object Acess Protocol)
Protocol: REST uses HTTP or HTTPS, SOAP can user various protocols (HTTP, SMTP, etc)
Message format: REST uses lightweight formats like JSON or XML, SOAP typically uses XML.
State: REST is stateless, SOAP can be stateful or stateless.
Error handling: REST relies on HTTP status codes, SOAP defines its own fault mechanism.
Performance: REST is generally faster, SOAP slower.
What are HTTP verbs and HTTP methods?
HTTP methods, also known as HTTP verbs, are a set of actions that a client can take on a resource.
Explain the concept of idempotence in RESTful APIs
Same operation will yield the same output.
What are the role of status codes in RESTful APIs?
Used to convey the results of a client’s request.
1XX (info)
100: continue
2XX (success)
200: OK, 201: created, 202: accepted, 204: no content
3XX (redirection)
300: multiple choices
4XX (client error)
400: bad request, 401: unauthorized, 403: forbidden, 404: not found
5XX (server error)
500: internal server error, 501: not implemented, 502: bad gateway, 503: service unavailable
What is CORS?
Cross origin resource sharing
It’s a security feature implemented in web browsers that restricts web pages or scripts from making requests to a different domain than the one that served the web page.
How to remove the CORS restrictions in RESTful API’s in Express.js?
app.use(cors());
What is serialization and deserialization?
Converting an object to json: serialization
Converting json to object: deserialization