Skip to main content

А library for a REST API client that works with any API that follows somewhat the REST standard.

Project description

Build Status

Features

This library is a small REST API client with the following features:

  • Url builder - allows you to build a url by natively calling the client’s attributes

  • HTTP requests - a thin wrapper around the requests library that allows full control of the HTTP requests.

Installation

pip install universal-api-client

Usage

Initialising the client

from universal_api_client import Client
swapi_client = Client(base_url='https://swapi.co/api/')

Building a URL

The url builder is part of the request (APIRequest) attribute of the client.

swapi_client.request.people # <universal_api_client.request.APIRequest at 0x1093c3eb8>
swapi_client.request.people.url # 'https://swapi.co/api/people/'
swapi_client.request.people(identifier=1).url # 'https://swapi.co/api/people/1/'
swapi_client.request.people(identifier='1').url # 'https://swapi.co/api/people/1/'

Making a request

The requests are made by the already built APIRequest object. The method call returns the appropriate method call from the requests library.

response = swapi_client.request.people(identifier='1').get() # <Response [200]>
print(response.status_code) # 200

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

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

universal-api-client-0.1.0.tar.gz (11.2 kB view hashes)

Uploaded source

Built Distribution

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