1. Benoit Chesneau
  2. py-restclient


py-restclient / docs / resource.txt

The default branch has multiple heads

.. _resource_ref:


.. module:: restkit

This module provide a common interface for all HTTP requests. This
module make HTTP requests using `Pycurl`_ by default if installed or


    >>> from restkit import Resource
    >>> res = Resource('http://friendpaste.com')
    >>> res.get('/5rOqE9XTz7lccLgZoQS4IP',headers={'Accept': 'application/json'})
    u'{"snippet": "hi!", "title": "", "id": "5rOqE9XTz7lccLgZoQS4IP", "language": "text", "revision": "386233396230"}'
    >>> res.get('/5rOqE9XTz7lccLgZoQS4IP',headers={'Accept': 'application/json'}).http_code
Data returned are unicode or binaries.

Resource class

.. autoclass:: restkit.rest.Resource


    .. attribute:: uri

        Str, full uri to the server.

    .. attribute:: transport

        Any instance of object based on 
        `restkit.transport.HTTPTransportBase`. By default it will use 
        a client based on `pycurl <http://pycurl.sourceforge.net/>`_ if 
        installed or `restkit.http.HTTPLib2Transport`,a transport based on 
        `Httplib2 <http://code.google.com/p/httplib2/>`_ or make your
        own depending of the option you need to access to the serve
        (authentification, proxy, ....).


    .. automethod:: restkit.rest.Resource.clone

    .. automethod:: restkit.rest.Resource.__call__

    .. automethod:: restkit.rest.Resource.get

    .. automethod:: restkit.rest.Resource.head

    .. automethod:: restkit.rest.Resource.delete

    .. automethod:: restkit.rest.Resource.post

    .. automethod:: restkit.rest.Resource.put
    .. automethod:: restkit.rest.Resource.request

    .. automethod:: restkit.rest.Resource.update_uri

RestClient class

RestClient represent a simple HTTP client. **New in 1.1** By default all urls are utf8
encoded. But you could change default charset, safe characters and
decide that keys don't need to be encoded.

.. autoclass:: restkit.rest.RestClient



    .. attribute:: transport

        Any http instance of object based on 
        `restkit.httpc.HttpClient`. By default it will use 
        `restkit.httpc.ProxiedHttpClient that support simple proxy auth.

    .. describe:: charset
        By default it's 'utf-8', it define charset of urls.

    .. describe:: encode_keys

        By default True. Encode params keys

    .. describe:: safe

        By default is ":/", define which charaters are safe in url and
        don't need to be encoded.


    .. automethod:: restkit.rest.RestClient.get

    .. automethod:: restkit.rest.RestClient.head

    .. automethod:: restkit.rest.RestClient.delete

    .. automethod:: restkit.rest.RestClient.post

    .. automethod:: restkit.rest.RestClient.put

    .. automethod:: restkit.rest.RestClient.request

.. _Pycurl: http://pycurl.sourceforge.net/
.. _Httplib2: http://code.google.com/p/httplib2/