Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Small Python RESTFul API Wrapper
Python
branch: master
Failed to load latest commit information.
.gitignore Added stuff for using coverage for tests
COPYING Added copyright to pyrest
README.md Added stuff for using coverage for tests
__init__.py Added copyright to pyrest
api.py Added a message about running linters, and actually ran them myself.
requirements.txt Removed distribute, and added coverage
run_tests.sh Added branch coverage to our tests
setup.py Added copyright to pyrest
tests.py

README.md

pyrest

pyrest is a small RESTFul API Wrapper for python. It allows you to rapidly develop your own API Wrapper for your specific application, without worrying about the HTTP Requests on their own.

Code Examples

This would be a basic GET request

from pyrest.api import Api


stack = Api('http://api.stackexchange.com/2.1')  # Notice no trailing / !
stack.update_endpoints(
    {
        'ans': 'answers'
    }
)

print(
    stack.get(
        endpoint = 'ans',
        parameters = (('site', 'stackoverflow'), ('order', 'desc'))
    )
)

Here we show off some of our fancy url modularization:

stack = Api('http://api.stackexchange.com/2.1')  # Notice no trailing / !
stack.update_endpoints(
    {
        'comments': 'posts/%(id)s/comments'
    }
)
print(
    stack.get(
        endpoint = 'comments',
        parameters = (('site', 'stackoverflow'), ('order', 'desc')),
        url_data = {'id': '11867143'}
    )
)

Style/Commiting Guide

  • Commit early, commit often.
  • PEP8
  • At the top of any scope, initialize and define any methods you will use inside it. For objects, use None. For primitives, use the most empty value (False, 0, '', etc.)
    • Two spaces, and then a comment to describe what it does
    • BEWARE, dictionaries (and most likely many others collections!) are objects, and do not get re-instantiated between object instantiation. Make sure in init() you re-set them.
  • Run linters
    • pep8
    • pylint
    • pyflakes
    • pychecker
  • Code Coverage
    • Use coverage to test our code! 100% coverage is a nice rule of thumb.
      • coverage run --omit=tests.py --branch tests.py

Licensing

The code in this repository is underneath the GPLv3 license

Something went wrong with that request. Please try again.