Skip to main content

This python library is a REST API Call which generates REST URLs using attributes.

Project description

REST API CALL

This python library is a REST API Call which generates REST URLs using attributes.",

As an example:

http://example.org/product/kart/customer?id=3&name=foo'

The URI path:

product/kart/customer?id=3&name=foo

with this python library is the sequence:

product.kart.customer(id='3', name='foo')

get()

You can perform the request (Cf. http://docs.python-requests.org/) with get():

>>> import restapicall
>>> conn = restapicall.ApiCall(endpoint='http://example.org')
>>> r = conn.product.kart.customer(id='3', name='foo').get()
>>> r.url
http://example.org/product/kart/customer?id=3&name=foo
>>> r.status_code
404
>>> r.headers['content-type']
'text/html; charset=UTF-8'

get_url()

the url can be get by get_url():

>>> import restapicall
>>> conn = restapicall.ApiCall(endpoint='http://example.org')
>>> r = conn.product(id='3').kart.customer(name='foo').get_url()
>>> print(r)
http://example.org/product/kart/customer?id=3&name=foo'

You can concatenate the attributes. That's exactly the same:

>>> conn = ApiCall(endpoint='http://example.org')
>>> r = conn.product.kart.customer(id='3', name='foo').get_url()
>>> print(r)
http://example.org/product/kart/customer?id=3&name=foo'

License

ISC

Author information

This code was created in 2019 by Olivier Locard.

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

RestApiCall-1.0.0.tar.gz (3.3 kB view hashes)

Uploaded Source

Built Distribution

RestApiCall-1.0.0-py3-none-any.whl (4.8 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