API Basics
API Basics
SOAP vs REST
SOAP (Simple Object Access Protocol)
Uses XML for request and response format.
Works over multiple transport protocols (HTTP, SMTP, TCP, etc.).
Strict structure and follows standards like WS-Security.
Heavier and slower compared to REST.
REST (Representational State Transfer)
Uses JSON, XML, or even plain text as response formats.
Works only over HTTP.
Follows standard HTTP methods (GET, POST, PUT, DELETE).
Lightweight, faster, and widely used for web services.
Example SOAP Request (XML Format)
xml
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:web="http://www.example.com/weather">
<soapenv:Header/>
<soapenv:Body>
<web:GetWeather>
<web:City>New York</web:City>
</web:GetWeather>
</soapenv:Body>
</soapenv:Envelope>
Example REST Request (JSON Format)
HTTP GET Request:
http
GET https://api.weather.com/v1/city/NewYork
Response (JSON Format):
json
Copy
Edit
{
"city": "New York",
"temperature": "20°C",
"humidity": "60%"
}
API Clients
API Clients are tools or applications that interact with APIs to send requests and
receive responses.