Skip to main content

The requests-rest-api package contains functions to make REST API calls using the requests package.

Project description

Requests REST API

PyPI - Version PyPI - Python Version


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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

requests_rest_api-0.2.4.tar.gz (17.0 MB view hashes)

Uploaded Source

Built Distribution

requests_rest_api-0.2.4-py3-none-any.whl (6.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page