What is API and how to call it using Python وكيفية التعامل معها بالبايثون API ما هي الـ

Опубликовано: 15 Июнь 2026
на канале: 3dss
4,154
167

API stands for Application Programming Interface, API is a connection between computers or between computer programs. It is a type of software interface, offering a service to other pieces of software.

to install requests:
------------------------------
pip install requests

Script used:
-------------------
import requests

resp = requests.get('https://randomuser.me/api/')
resp.text

resp = requests.get('https://api.ipify.org/?format=json')
resp.text

resp = requests.get('https://ipinfo.io/156.196.42.30/geo')
print(resp.text)

url = 'https://reqres.in/api/users'
payload = {"name": "morpheus","job": "leader"}
resp = requests.post(url=url, data=payload)
print(resp.text)

url = 'https://reqres.in/api/login'
payload = {"email": "[email protected]","password": "cityslicka"}
resp = requests.post(url=url, data=payload)
print(resp.text)

url = 'https://reqres.in/api/users/2'
payload = {
"name": "morpheus",
"job": "zion resident"
}
headers=''
resp = requests.post(url=url, data=payload, headers=headers)
print(resp.text)

url = 'https://reqres.in/api/users/2'
resp = requests.delete(url=url)
print(resp)
print(resp.text)