# Requests (Python)

> A Python tool for calling web APIs. One line gets a page.

**Field:** Software Development  
**Category:** APIs  
**Also known as:** Python Requests, requests library, import requests

## Think of it like

Think of it like a polite messenger. You say where to go and what to ask, and it brings back the answer.

## Definition

Requests is a popular Python library for sending HTTP requests. One line can fetch a page or call an API. It handles headers, cookies and JSON for you. Its motto is HTTP for Humans, because it is simple to read. Scripts, scrapers and back ends all use it.

## Example

Lucy writes a Python script with Requests. Every hour it asks a weather API for the forecast and saves it.

## Example code

```python
import requests

res = requests.get("https://api.example.com/orders/42", timeout=10)
print(res.status_code, res.json()["total"])
```

Fetch an order, with a time limit, and read the JSON.

## Why it matters

It is the usual way Python code talks to the web.

## Common mistake

Leaving out a timeout. Without one, a call to a stuck server can hang forever.

## Three principles

- **One line.** requests.get fetches it.
- **JSON built in.** res.json() reads the body.
- **Set a timeout.** Never wait forever.

## Related terms

- [HTTP Client](https://learn.benibix.com/term/development/http-client)
- [Python](https://learn.benibix.com/term/development/python)
- [Axios](https://learn.benibix.com/term/development/axios)
- [Web Scraping](https://learn.benibix.com/term/development/web-scraping)
- [curl](https://learn.benibix.com/term/development/curl)

![Three ways to send the same GET request to an API. In JavaScript code, Axios. In Python code, Requests. In a terminal, HTTPie with the command http. All three arrows point to one endpoint, which sends back JSON.](https://learn.benibix.com/diagrams/dev3-http-clients.svg)

---

Source: https://learn.benibix.com/term/development/python-requests
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
