Intessa is a Python library which makes it easy to build dynamic clients to HTTP APIs.
Create your initial API object:
>>> import intessa
>>> api = intessa.API('https://graph.facebook.com/')
>>> api
<intessa.API(u'https://graph.facebook.com/')>
Access sub-URLs using attribute or subscription syntax, returning new API objects:
>>> api[u'19292868552']
<intessa.API(u'https://graph.facebook.com/19292868552')>
>>> api.cocacola
<intessa.API(u'https://graph.facebook.com/cocacola')>
>>> api['btaylor']['picture']
<intessa.API(u'https://graph.facebook.com/btaylor/picture')>
Perform a GET on a URL by calling the API object, returning a Response:
>>> response = api[19292868552]()
>>> response
<intessa.Response[200, text/javascript]>
Your response will already be decoded if possible, with built-in handlers for common content types (see: intessa.conneg):
>>> import pprint
>>> response.type
ContentType('text/javascript; charset=UTF-8')
>>> response.type.media_type
'text/javascript'
>>> response.type.params
odict([('charset', 'UTF-8')])
>>> pprint.pprint(response.value)
{u'category': u'Product/service',
u'company_overview': u'Facebook Platform enables anyone to build social apps on Facebook and the web.',
u'founded': u'May 2007',
u'id': u'19292868552',
u'likes': 2311074,
u'link': u'http://www.facebook.com/platform',
u'mission': u'To make the web more open and social.',
u'name': u'Facebook Platform',
u'picture': u'http://profile.ak.fbcdn.net/hprofile-ak-snc4/211033_19292868552_7506301_s.jpg',
u'username': u'platform',
u'website': u'http://developers.facebook.com'}
Use the back-reference to the API object to access sub-paths:
>>> response.api.picture
<API(u'https://graph.facebook.com/19292868552/picture')>
Obtain a copy from GitHub:
git clone 'https://github.com/zacharyvoase/intessa.git'
cd intessa/
Install nosetests:
pip install nose
Hack.
Run the test suite using nosetests:
python setup.py nosetests
GOTO 3.
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>