Skip to content

cooperhewitt/py-cooperhewitt-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

py-cooperhewitt-api

Python bindings to the Cooper-Hewitt collections API.

Installation

You can install this by either cloning this repository and running

	$ python setup.py

or you can use pip and just do the following

   $ pip install cooperhewitt.api

Example

Plain vanilla

import cooperhewitt.api.client
import pprint

api = cooperhewitt.api.client.OAuth2(ACCESS_TOKEN)

now = int(time.time())
args = {'foo': 'bar', 'timestamp': now}

rsp = api.execute_method('api.test.echo', args)

print pprint.pformat(rsp)

Using a proxy

Just pass a proxy argument to the constructor

import cooperhewitt.api.client
import pprint

api = cooperhewitt.api.client.OAuth2(ACCESS_TOKEN, proxy='http://proxy.example.com:80')

now = int(time.time())
args = {'foo': 'bar', 'timestamp': now}

rsp = api.execute_method('api.test.echo', args)

print pprint.pformat(rsp)

Uploading a file

import cooperhewitt.api.client
import cooperhewitt.api.request

import pprint

api = cooperhewitt.api.client.OAuth2(ACCESS_TOKEN)

fh = open('/path/to/file', 'rb')
args = {'file': fh}

rsp = api.execute_method('api.test.uploadMe', args, cooperhewitt.api.request.encode_multipart_formdata)
print pprint.pformat(rsp)

See also

About

Python bindings for the Cooper-Hewitt collections API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages