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.2.tar.gz (16.1 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.2-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: restpylot-0.1.2.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.11.15 Linux/6.17.0-1015-azure

File hashes

Hashes for restpylot-0.1.2.tar.gz
Algorithm Hash digest
SHA256 107f5085c90a3bb72b97e2409ca8394299a2004a657d29ff69ae1a65b4ba771f
MD5 8fcc71a3b3824cf565b6f5d56667f1aa
BLAKE2b-256 4362e9993fb96776e1f347de6c35f69cd647b844c40073975b7e01b79a16b58e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: restpylot-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 16.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.11.15 Linux/6.17.0-1015-azure

File hashes

Hashes for restpylot-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 610784d2bec8e0c7f56fa2215c7872691a9f09e6a610ab5bed5ebc9de0314cb6
MD5 83966a61a61759e3e4fcfd5f54c854fb
BLAKE2b-256 d718d5ae266a2262c607547cdb2c021b027908aa2433a2167047fd1eb67237c7

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