python-boxview
Python client library for Box View API
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
Authentication
Box View API uses token-based authentication. You need create application and generate api token at Box Developes Portal. Then use the token to create instance
from boxview import boxview
api = boxview.BoxView('<your box view api key>')
Alternatively, token can be set by environment variable BOX_VIEW_API_KEY.
Usage
python-boxview supports all methods from Box View API. List of methods and parameters description can be found here
import os
from boxview import boxview
api = boxview.BoxView('<your box view api key>')
# 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)
# create webhook
api.create_webhook('http://example.com/my-webhook')
# create S3 storage profile
api.create_storage_profile('S3', 'super-awesome-bucket', 'AKIAIOSFODNN7EXAMPLE', 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY')
# and delete document
api.delete_document(doc_id)
Dealing with Rate Limiting
import time
from boxview import boxview
api = boxview.BoxView('<your box view api key>')
document_id = '2da6cf9261824fb0a4fe532f94d14625'
retry, max_retry = 0, 3
while True:
try:
api.get_thumbnail_to_file('thumbnail_100x100.png', document_id, 100, 100)
break # ok, thumbnail saved
except boxview.RetryAfter as e:
retry += 1
if retry <= max_retry:
time.sleep(e.seconds) # waiting for next call
else:
raise # failed after `max_retry` attempts, exit with exception
License
The MIT License (MIT)
Contributed by Maxim Kamenkov
Metadata
Release files for python-boxview 1.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| python-boxview-1.2.2.tar.gz | 9.0 kB | Without provenance | Details for python-boxview-1.2.2.tar.gz |
Release files / python-boxview-1.2.2.tar.gz
| Download URL | python-boxview-1.2.2.tar.gz |
|---|---|
| Size | 9.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ce5d6364643769a49d5128f2c0292215dbb1da6a747957a2cde5ca50572f6eb7
|
|
BLAKE2b-256 checksum How to use checksums |
d6bbadfd62f49104b643c2f45e0b944ae7384ceef7286df2441d0d0f437d3919
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for python-boxview 1.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.