Skip to content

Latest commit

 

History

History
85 lines (62 loc) · 2.02 KB

README.md

File metadata and controls

85 lines (62 loc) · 2.02 KB

CloudSight API for Python

Version API Docs Build Status

A simple CloudSight API Client for Python programming language. It has been tested with Python versions 2.7 and 3.5.

Status

This package is currently in beta status. It means the API may still change in backwards incompatible way.

Installation

$ pip install cloudsight

Configuration

You need your API key and secret (if using OAuth1 authentication). They are available on CloudSight site after you sign up and create a project.

Usage

Import the cloudsight package:

import cloudsight

Create an API instance using simple key-based authentication:

auth = cloudsight.SimpleAuth('your-api-key')
api = cloudsight.API(auth)

Or, using OAuth1 authentication:

auth = cloudsight.OAuth('your-api-key', 'your-api-secret')
api = cloudsight.API(auth)

Send the image request using a file:

with open('your-file.jpg', 'rb') as f:
    response = api.image_request(f, 'your-file.jpg', {
        'image_request[locale]': 'en-US',
    })

Or, you can send the image request using a URL:

response = api.remote_image_request('http://www.example.com/image.jpg', {
    'image_request[locale]': 'en-US',
})

Then, update the job status to see if it's already processed:

status = api.image_response(response['token'])
if status['status'] != cloudsight.STATUS_NOT_COMPLETED:
    # Done!
    pass

It usually takes 6-12 seconds to receive a completed response. You may use wait() method to wait until the image is processed:

status = api.wait(response['token'], timeout=30)