The requests-rest-api package contains functions to make REST API calls using the requests package.
Project description
Requests REST API
Table of Contents
Introduction
The requests-rest-api package contains functions to make REST API calls, it is build on top of the requests library.
Inspiration was found in a similar package by Deric Degagne
Examples
Simple GET:
from requests_rest_api.rest_api import get_request
get_request("https://reqres.in/api/users/2")
NOTE
All the functions simply pass all parameters to requests, so if you can always add more parameters if needed.
For example add the headers parameter like this:
from requests_rest_api.rest_api import get_request
get_request("https://reqres.in/api/users/2", headers={"Token": "123"})
Example with a Session
requests has a Session class that can take care of connection-pooling, authorisation, headers, cookies etc.
It is a good idea to use this if you need to make multiple calls to the same endpoints.
This example would set a token for the session:
from requests import Session
from requests_rest_api.rest_api import get_request
with Session(headers={"Token": "123"}) as session:
result = get_request("https://reqres.in/api/users/2", session=session)
Development
Pytest and Hatch are used to make our lives as developers great.
Installation
pip install requests-rest-api
License
requests-rest-api is distributed under the terms of the MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file requests_rest_api-0.2.4.tar.gz.
File metadata
- Download URL: requests_rest_api-0.2.4.tar.gz
- Upload date:
- Size: 17.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.23.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f204cbe69d6c64b7c6fde80dc7f039e5eee445dd8d074dd5c208d13853bdb888
|
|
| MD5 |
30d62050e240fd888ab4c908bc3ca045
|
|
| BLAKE2b-256 |
56bff6895c3832d2df58eab5cde49f44a606c06ac9d9f3ff9925264bee9a816b
|
File details
Details for the file requests_rest_api-0.2.4-py3-none-any.whl.
File metadata
- Download URL: requests_rest_api-0.2.4-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.23.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
988a12998403ba939638ac9ab1011024fc6ee2a2e051c50845be8234fd705659
|
|
| MD5 |
f83dbfe374de7a3268db731adf681dbf
|
|
| BLAKE2b-256 |
db717da7706544cf29163ffc419d11bc6ccbb36bf46dc1b00dfefd271ed2b142
|