Skip to main content

Object Oriented rest client

Project description

# RESTler

Status: [![Travis Status](https://travis-ci.org/jdost/restler.svg?branch=master)](https://travis-ci.org/jdost/restler)

RESTler is a python library I dreamed up that maps Object+method calls to RESTful
URL requests. The idea is that you create a base RESTler object for the root of the
RESTful web application and then use method calls to get sub URLs and then use some
keyword attributes to make various requests to the created route, with built in
response handling. This should make it easy to wrap a nice RESTful API into a
simple python library.

## Example

``` python
>> flickr = Restler('http://flickr.com/api')
>> photos = flickr.photos
>> photos.__url__
'http://flickr.com/api/photos/'
```

## Getting Started

If you have a RESTful API you want to wrap, just use the `Restler` constructor to
create the base entry point of the application. Then use the resulting object to
access the sub-routes of the application. Every attribute maps to a level of the
URL, so `application.users.asdf` would request from `(application base)/users/asdf/`

## Route Object

The `Route` object returned from each attribute of the route has a series of
methods to help in accessing the current route or child routes. The object itself
is calleable which maps to a `GET` request on the object. Any other attributes will
map to sub URLs of the current URL the `Route` maps to.

## Response Object

Any request made via a `Route` will return a `Response` object. This object will
encapsulate the basic request with some helpers built in. The main helper is that
the object's representation will map to the clearest form of the response data. If
this is a JSON string, it will be parsed, if it is an XML document, it will be a
pointer to the XML document, if it is a plaintext string, it will just be a plain
string. The headers for the response will be accessible as well via a reserved
property of the response.

### Example

``` python
workhammer = Restler('http://workhammer.herokuapp.com')
login = workhammer.login("post", username='admin', password='password')
if login.code > 300:
throw "Login failed"

players = workhammer.player()
player = workhammer.player[players[0].id]()
```

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

librestler-0.2.2.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

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

librestler-0.2.2-py2-none-any.whl (12.6 kB view details)

Uploaded Python 2

File details

Details for the file librestler-0.2.2.tar.gz.

File metadata

  • Download URL: librestler-0.2.2.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for librestler-0.2.2.tar.gz
Algorithm Hash digest
SHA256 a70ea93100e4ee87538b2a3b28d299b526c04079be90c80689cb68227873d6e4
MD5 2383d5657d349f88add7b200f1e8ba06
BLAKE2b-256 82832d7a4e963e9dfa4b23e8841cc75c4c7615b668f8b2645544b80d1fb53ec2

See more details on using hashes here.

File details

Details for the file librestler-0.2.2-py2-none-any.whl.

File metadata

File hashes

Hashes for librestler-0.2.2-py2-none-any.whl
Algorithm Hash digest
SHA256 ffc2f56080db2ca82e59c1de22b1bea34bbc77364c9fdaee0f0fabbf9eaf4a8b
MD5 10604151d9123881650dd92f30ed7e35
BLAKE2b-256 dbbf550dd1702d064a0be70f09784a97ffe6b6d9556537c5baf52d72aeb0e6a2

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