Giter Site home page Giter Site logo

python-boxview's Introduction

python-boxview

Python client library for Box View API (http://developers.box.com/view/)

Installation

The easiest way to install the latest version is by using pip/easy_install to pull it from PyPI:

pip install python-boxview

You may also use Git to clone the repository from Github and install it manually:

git clone https://github.com/caxap/python-boxview.git
python setup.py install

Usage

import os
import boxview

token = '<your box view api key>'

api = boxview.BoxView(token)

# upload file to create new document
doc = api.create_document(file='python-boxview.pdf', name='python-boxview')

# create new document from public url
doc = api.create_document(url='https://cloud.box.com/shared/static/4qhegqxubg8ox0uj5ys8.pdf')

doc_id = doc['id']

# retrieve existings document
doc1 = api.get_document(doc_id)

# list all uploaded documents for your api key
all_docs = api.get_documents(limit=10)

# update name of existing document
doc1 = api.update_document(doc_id, name='python-boxview')

# check that document ready to view
bool(api.ready_to_view(doc_id))

# start view session for document
session = api.create_session(doc_id, duration=300)

ses_id = session['id']

# get link to box viewer
api.get_session_url(ses_id)

# retrieve original document content to string 
content, mimetype = api.get_document_content_to_string(doc_id)
len(content)

# retrieve pdf version of document to file
api.get_document_content_to_file('python-boxview.pdf', doc_id, extension='.pdf')
os.path.exists('python-boxview.pdf')

# retrieve mimetype of original document content
mimetype = api.get_document_content_mimetype(doc_id)

# And delete document
api.delete_document(doc_id)

License

The MIT License (MIT)

Contributed by Maxim Kamenkov, PandaDoc.com

python-boxview's People

Contributors

caxap avatar

Stargazers

Eylem Ozaslan avatar

Watchers

James Cloos avatar Nick Fishman avatar

Forkers

minervaproject

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.