Code Monkey home page Code Monkey logo

drest's Introduction

dRest HTTP/REST Client Library for Python

dRest is a configurable HTTP/REST client library for Python. It's goal is to make the creation of API clients dead simple, without lacking features.

Continuous Integration Status

Features include:

  • Light-weight API Client Library, implementing REST by default
  • Native support for the Django TastyPie API Framework
  • Only one external dependency on httplib2
  • Key pieces of the library are customizable by defined handlers
  • Interface definitions ensure handlers are properly implemented
  • Tested against Python versions 2.6, 2.7, 3.2, 3.3
  • 100% test coverage via Nose

More Information

Usage

import drest

# Create a generic client api object
api = drest.API('http://localhost:8000/api/v1/')

# Make calls openly via any HTTP Method, and any path
# GET http://localhost:8000/api/v1/users/1/
response = api.make_request('GET', '/users/1/')

# Or attach a resource
api.add_resource('users')

# Get available resources
api.resources
>>> ['users', 'projects', 'etc']

# Get all objects of a resource
# GET http://localhost:8000/api/v1/users/
response = api.users.get()

# Get a single resource with primary key '1'
# GET http://localhost:8000/api/v1/users/1/
response = api.users.get(1)

# Create a resource data dictionary
user_data = dict(
    username='john.doe',
    password='oober-secure-password',
    first_name='John',
    last_name='Doe',
    )

# POST http://localhost:8000/api/v1/users/
response = api.users.post(user_data)

# Update a resource with primary key '1'
response = api.users.get(1)
updated_data = data.copy()
updated_data['first_name'] = 'John'
updated_data['last_name'] = 'Doe'
    
# PUT http://localhost:8000/api/v1/users/1/
response = api.users.put(1, updated_data)

# Patch a resource with primary key '1'
# PATCH http://localhost:8000/api/v1/users/1/
response = api.users.patch(1, dict(first_name='Johnny'))

# Delete a resource with primary key '1'
# DELETE http://localhost:8000/api/v1/users/1/
response = api.users.delete(1)

License

The dRest library is Open Source and is distributed under the BSD License (three clause). Please see the LICENSE file included with this software.

drest's People

Contributors

airtonix avatar derks avatar oliverdrake avatar rdgreis avatar spookylukey avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.