0% found this document useful (0 votes)
2 views2 pages

API Basics

An API (Application Programming Interface) enables communication between software applications by defining methods and data formats for information exchange. It can be implemented using SOAP, which is heavier and uses XML, or REST, which is lightweight and commonly uses JSON. API clients like Postman and cURL are tools used to interact with APIs, and HTTP status codes provide feedback on the results of API requests.

Uploaded by

iihtiics
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

API Basics

An API (Application Programming Interface) enables communication between software applications by defining methods and data formats for information exchange. It can be implemented using SOAP, which is heavier and uses XML, or REST, which is lightweight and commonly uses JSON. API clients like Postman and cURL are tools used to interact with APIs, and HTTP status codes provide feedback on the results of API requests.

Uploaded by

iihtiics
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

What is an API?

An API (Application Programming Interface) is a set of rules that allows different


software applications to communicate with each other. It defines methods and data
formats that applications can use to request and exchange information.

Example of API Usage:


A weather app uses a weather API to fetch real-time temperature and forecast data
from a weather service provider.

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.

Common API Clients:


Postman – Popular for testing REST APIs.
cURL – Command-line tool to make API requests.
Swagger UI – Provides an interactive API documentation interface.
Insomnia – Lightweight API testing tool.
Example Using Postman:
Choose GET method.
Enter https://api.example.com/users in the request URL.
Click Send to see the response.
Status Codes
HTTP status codes indicate the result of an API request.

Status Code Meaning Example


200 OK Request was successful Fetching user data
201 Created Resource was successfully created Creating a new user
400 Bad Request The request was invalid Missing required parameters
401 Unauthorized Authentication failed Invalid API key
403 Forbidden Access denied User lacks permission
404 Not Found The requested resource was not found Invalid endpoint
500 Internal Server Error Server encountered an error API service failure
Example API Response for 200 OK
json
Copy
Edit
{
"status": 200,
"message": "Success",
"data": {
"id": 101,
"name": "John Doe",
"email": "johndoe@example.com"
}
}
Example API Response for 404 Not Found
json
Copy
Edit
{
"status": 404,
"message": "User not found"
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy