Skip to main content

Python client for a DjangoRestFramework based web site

Project description

# Strato Python API Package

A python library for interacting with any Django web server base on django-rest-framework

Package is based on, but enhanced to support tokens and other features.

## Features

* Support for tokens. Both
* django-rest-framework's own tokens: `rest_framework.authentication.TokenAuthentication`
* JWT tokens: `rest_framework_jwt.authentication.JSONWebTokenAuthentication`

* Support for arguments (e.g. `?name1=val1&name2=val2`)

* Support for custom methods (e.g. ``/ap1/v1/object/custom/`)

## Requirements

restframeworkclient requires the following modules.

* Python 2.7+ or 3.4+
* requests

## Installation

pip install drf_client

## Usage Guide


options = {
'DOMAIN': '',
'API_PREFIX': 'api/v1',
'TOKEN_TYPE': 'jwt',
'TOKEN_FORMAT': 'JWT {token}',
'LOGIN': 'auth/login/',
'LOGOUT': 'auth/logout/',

c = RestApi(options)

ok = c.login(email=email, password=password)
if ok:

# GET some data
my_object = c.myresourcename.get()
for obj in my_object['results']:

payload = {
'data1': 'val1',
'data2': 'val2',

resp =


## Django Setup

Client assumes by default that all urls should end with a slash (tested with the default
router: `routers.DefaultRouter()`)

Apart from the regular Django and Rest Framework setup, this package currently relies on the following custom
login and logout API functions:

class AccountSerializer(serializers.ModelSerializer):
class Meta:
model = User
fields = ('id', 'email', 'username')

class APILogoutViewSet(APIView):
permission_classes = (permissions.IsAuthenticated,)

def post(self, request, format=None):
return Response({}, status=status.HTTP_204_NO_CONTENT)

urlpatterns = [
url(r'^auth/logout/$', APILogoutViewSet.as_view(), name='api-logout'),


## Development

To test, run python test or to run coverage analysis:

coverage run --source=iotile_cloud test
coverage report -m

You can also use py.test:


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
django-rest-framework-client-0.1.1.tar.gz (5.9 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page