Thuta Learning
AdvancedProgrammingbeginner

Requests Library

Relax. We'll talk through this in plain words — no textbook voice.

Requests Library Visual Guide
requests.get() နဲ့ API data ယူပြီး JSON response ပြန်ဖတ်ပုံကို diagram နဲ့ရှင်းပြထားပါတယ်။

Requests Library is the easiest library for making HTTP requests in Python. It's used to interact with APIs.

⚡ Installation: pip install requests

🎯 Common Methods:

requests.get()

requests.post()

requests.put()

requests.delete()

python
# Requests library example (simulated)
# Note: This is demo code showing the structure

import json

# Simulating a GET request
class MockResponse:
    def __init__(self):
        self.status_code = 200
        self.text = '{"userId": 1, "id": 1, "title": "Sample Post"}'
    
    def json(self):
        return json.loads(self.text)

# Simulate API call
response = MockResponse()

print(f"Status Code: {response.status_code}")
print(f"Response JSON: {response.json()}")

# POST request example structure
post_data = {
    "title": "New Post",
    "body": "This is the content",
    "userId": 1
}
print(f"\nPOST Data: {post_data}")
You should see
Status Code: 200 Response JSON: {'userId': 1, 'id': 1, 'title': 'Sample Post'} POST Data: {'title': 'New Post', 'body': 'This is the content', 'userId': 1}
Requests Library | Thuta Learning