API's
Types of API's
REST API - Representational State Transfer is a commonly used API category that isn’t dependent on a specific protocol. It’s considered a relatively user-friendly API to work with and many developers are experienced in this technology. It’s an architecture style of communicating interfaces.
SOAP API - Simple Object Access Protocol is an API that connects different platforms together through HTTP and XML. Its relatively older than other API implementations, but it provides more security as it follows strict protocols. It’s a protocol for communication between applications.
ASP.NET API - Specific form of REST API developed around .NET technology.
REST vs SOAP
Both have some similarities for instance they both support SSL/TLS for secure and encrypted communications, also they both use HTTP to exchange information. When deciding which API to use you must take in many factors into consideration like, security, ACID compliance, and overall application design. For instance, REST is a better choice if you’re trying to build a public API as they have lower security requirements and are much more flexible.
SOAP | REST | |
Design | Exposes the operation | Exposes the data |
Transport protocol | Independent and can work with any transport protocol | Only works with HTTPS |
Data format | Only supports XML data exchange | Supports XML, JSON, HTML, and plain text |
Performance | Larger messages, which makes communications slower | Has a faster performance due to smaller messages and catching support |
Scalability | Difficult to scale as the server maintains state by storing all previous messages exchanged with a client | Easy to scale due to it being stateless so every message is processes independently of previous messages |
Security | Supports encryption with additional overheads | Supports encryption without effecting the overall performance |
Use case | Useful in legacy applications and private API’s | Useful in modern applications and public API’s |
An average rest-based architecture uses mainly 4 HTTP methods.
HTTP method | CRUD method | Description |
POST | CREATE/INSERT | Adds a new resource |
GET | READ/SELECT | Reads the resource |
PUT | UPDATE | Edits an existing resource |
DELETE | DELETE | Deletes a resource |
HTTP status codes
- 1XX - informational
- 2XX - success
- 3XX - redirection
- 4XX - client error
- 5XX - server error
The most common HTTP status codes are:
· 200 – ok
· 301 – moved permanently
· 303 – see other
· 400 – bad request
· 403 – forbidden
· 404 – not found
· 500 – internal server error
Comments
Post a Comment