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
Hashes for requests_rest_api-0.2.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 988a12998403ba939638ac9ab1011024fc6ee2a2e051c50845be8234fd705659 |
|
MD5 | f83dbfe374de7a3268db731adf681dbf |
|
BLAKE2b-256 | db717da7706544cf29163ffc419d11bc6ccbb36bf46dc1b00dfefd271ed2b142 |