REQM
is a high-performance HTTP request library written in C++ and exposed to Python. It leverages libcurl
to handle HTTP requests and responses asynchronously and synchronously, with advanced features like cookie handling, proxies, retries, and custom headers. This package provides an easy-to-use Python interface to send GET, POST, PUT, DELETE, and other HTTP methods, making it a robust tool for HTTP operations.
-
Synchronous and Asynchronous HTTP Requests
Perform HTTP requests in a blocking (synchronous) or non-blocking (asynchronous) way with coroutines. -
Supports All HTTP Methods
GET, POST, PUT, DELETE, PATCH, OPTIONS, and HEAD methods are supported. -
Advanced Features
- Full cookie, proxy, and retry handling.
- Custom headers and request bodies.
-
Cross-Platform
Works on Linux, macOS, and Windows using the appropriate shared library (.so
,.dylib
, or.dll
). -
High Performance
Utilizeslibcurl
for high-performance HTTP requests.
To install the REQM
library, use the setup.sh
script. This script will download and install the required files for your platform (Linux, macOS, or Windows). Make sure you have an active internet connection for downloading dependencies.
-
Download or clone the
REQM
repository to your machine. -
Open a terminal and navigate to the project directory.
-
Run the
setup.sh
script:bash setup.sh
-
The script will:
- Check for required dependencies (
git
,curl
,python3
). - Clone the repository if not already cloned.
- Download the required
.so
,.dylib
, or.dll
files andnlohmann-json
header for the project. - Install the library into your Python environment.
The script will automatically download the necessary libraries and install the
REQM
module. You may needsudo
privileges if you're installing it system-wide or if Python is installed for all users. - Check for required dependencies (
Once REQM
is installed, you can use it in your Python projects. The module supports both synchronous and asynchronous HTTP requests. Here are a few examples of how to use it.
import reqm
# Make a synchronous GET request
response = reqm.get("https://httpbin.org/get")
print(response.status_code)
print(response.text)
import reqm
import asyncio
async def fetch_data():
# Make an asynchronous GET request
response = await reqm.async_get("https://httpbin.org/get")
print(response.status_code)
print(response.text)
# Run the asynchronous function
asyncio.run(fetch_data())
import reqm
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer your_token"
}
# Make a synchronous POST request with custom headers and JSON body
response = reqm.post("https://httpbin.org/post", json={"key": "value"}, headers=headers)
print(response.status_code)
print(response.json())
import reqm
# Enable cookie handling
cookies = reqm.cookies()
# Make a GET request and store cookies
response = reqm.get("https://httpbin.org/cookies/set?key=value", cookies=cookies)
print(response.cookies)
import reqm
# Perform a GET request with retries
response = reqm.get("https://httpbin.org/get", retries=3)
print(response.status_code)
import reqm
import asyncio
async def main():
# Asynchronous GET request
response = await reqm.async_get("https://httpbin.org/get")
print(response.status_code)
print(response.json())
# Synchronous POST request
headers = {"Content-Type": "application/json"}
response = reqm.post("https://httpbin.org/post", json={"key": "value"}, headers=headers)
print(response.status_code)
print(response.json())
asyncio.run(main())
This project is licensed under the MIT License - see the LICENSE file for details.