Skip to main content

A Python library for managing RESTful API interactions with a focus on security and ease of use.

Project description

restpylot Module

This module provides a RestClient class for making HTTP requests with ease. It is built on top of the requests library and provides methods for common HTTP operations such as GET, POST, PUT, DELETE, and PATCH.

Features

  • Supports GET, POST, PUT, DELETE, and PATCH requests.
  • Allows setting custom headers, including Authorization tokens and API keys.
  • Configurable timeout for requests.
  • Debug logging for request and response details.
  • Handles common HTTP errors and exceptions.

Installation

To use the restpylot module:

pip install restpylot

Usage

Initialization

You can initialize the restpylot with a base URL, headers, authorization token, timeout, and debug mode.

from restpylot import RestClient

client = RestClient(
    base_url='https://api.example.com',
    headers={'Custom-Header': 'value'},
    auth_token='your_auth_token',
    timeout=10,
    debug=True
)

Making Requests

The restpylot provides methods for making various types of HTTP requests.

GET Request

response = client.get('/endpoint', params={'key': 'value'})
print(response)

POST Request

response = client.post('/endpoint', json={'key': 'value'})
print(response)

PUT Request

response = client.put('/endpoint', json={'key': 'value'})
print(response)

DELETE Request

response = client.delete('/endpoint')
print(response)

PATCH Request

response = client.patch('/endpoint', json={'key': 'value'})
print(response)

Setting Authorization Token

You can update the authorization token at any time.

client.set_auth_token('new_auth_token')

Setting API Key

You can set an API key with a custom header.

client.set_api_key('your_api_key', header='X-Api-Key')

Closing the Session

It is a good practice to close the session when you are done with the client.

client.close()

Logging

If debug mode is enabled, the restpylot will log detailed information about the requests and responses.

License

This module is provided under the GPL-3.0 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

restpylot-0.1.1.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

restpylot-0.1.1-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

Details for the file restpylot-0.1.1.tar.gz.

File metadata

  • Download URL: restpylot-0.1.1.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.11.12 Linux/6.11.0-1014-azure

File hashes

Hashes for restpylot-0.1.1.tar.gz
Algorithm Hash digest
SHA256 12d023c739f5c238a300bb5be0f3019e50907eea2c50ee6aa0039a8967c3fce0
MD5 96b5f0b5fa59ca3b3fc7c238118dc9e7
BLAKE2b-256 3a4fa96dde47917ad54314e662133930dd71a475d20d20e021a31f3fe22c3fed

See more details on using hashes here.

File details

Details for the file restpylot-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: restpylot-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 16.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.11.12 Linux/6.11.0-1014-azure

File hashes

Hashes for restpylot-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c859850bc2f1ff814e6a1d9087ad2f4cede4f81b3645d94c2f5b11a55f39e419
MD5 59f9fe277093977351ca86bc1f79c6e8
BLAKE2b-256 d91a33b5e107eacac6561cc658ac5e83081a076a7dcdf8b855c6bc40ce48c0bc

See more details on using hashes here.

Supported by

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