Quantcast

Sales:
(215) 821-7004

Web Service API Reference

The Web Service API allows developers to interact securely with their Vuzit account. You can easily upload, download, remove, and retrieve attributes about documents. All you need is a Vuzit account!

Please note that these are the raw Web Service APIs. For most common functions we have already created client libraries in your language of choice (e.g. .NET, PHP, Python, etc). Please check the developer page for the latest details on these client libraries.


Table of Contents

Introduction

The Web Service APIs conform as much as possible to the design principles of REpresentational State Transfer (REST) using the HTTP 1.1 protocol. Each Method (e.g. create, show, and destroy). uses a corresponding HTTP Verb (e.g. GET, POST, DELETE) that is passed in with the request.

Requests

The URL of the request determines the output format (JSON or XML), and whether or not to use SSL transport layer security. All requests return a 3-character HTTP response code, and optionally return additional attributes in either XML or JSON formats.

Failure Responses

Requests to the API may fail due to an invalid signature, expired timestamp, or a number of other reasons. The format of the error response is the same for all methods, where the Vuzit error code and a description of the error are returned.

Example XML Response

412Access is denied. Invalid signature

Example JSON Response

{"err":{"code":"412","msg":"Access is denied. Invalid signature"}}

Access Control

Every document you upload to Vuzit can be displayed on a web page using your Public Key, but only on the Sites that are authorized to use your Public Key. Documents are stored with either Public or Private access control permissions. Public documents have their content stored in a public storage area that can be accessed and downloaded by anyone on the internet. Private documents can only be accessed by securely authenticating each request with a signature and timestamp [optionally] over an encrypted connection.


Documents API Methods

For all methods, the URL of the request determines the output format (JSON or XML), and whether or not to use SSL transport layer security.

create

This method will upload a new document to your Vuzit account.

Methodcreate
HTTP VerbPOST
Parameter Type Description
upload multipart POST The file being uploaded
secure string Specifies whether the document (via the Vuzit viewer) should be public or private:
0 - Public
1 - Private
download_document string Specifies whether the uploaded document should be available for download:
0 - No
1 - Yes
download_pdf string Specifies whether a PDF should be generated and available for download:
0 - No
1 - Yes
Note: Ignore this option if you are uploading a PDF file, and simply use the download_document parameter instead.
file_type (optional) string The short extension of the file type of the document to be uploaded (e.g. pdf, doc, ppt, etc.) This parameter is required if the file does not have an extension in the filename, and specifying this parameter overrides any existing extension that appears in the filename.
key string Public API Key (see Settings)
signature string Unique Base64-encoded HMAC-SHA1 (see Generating a Signature)
timestamp string Ex: 1233438639 (see Time since the epoch)
Choose a Service Output URL
XML http://vuzit.com/documents.xml
XML with SSL https://ssl.vuzit.com/documents.xml
JSON http://vuzit.com/documents.json
JSON with SSL https://ssl.vuzit.com/documents.json

Response

A successful interaction returns an HTTP response code of 201, and an XML or JSON response with the web_id of the newly created document. The web_id is a unique Vuzit identifier string that is the primary identifier for the document. The web_id is required in order to interact with the document

Example Successful XML Response
oc
Example Successful JSON Response
{"document":{"web_id":"oc"}}

Responses that return errors are covered in the Failure Responses section.

Viewing Your Uploaded Documents

Uploaded documents can be managed in your Dashboard, and are ready to be integrated into web pages using the JavaScript API. The Viewer::fromId() function is used to display the document using the web_id that was returned by the create method. Example JavaScript code is available to illustrate this method to display a public document. For documents that are secure, you must send the signature and timestamp authentication parameters into the Viewer constructer.


index

This method will retrieve or search all documents in your account (i.e. repository search). A query string may be sent with the request, along with desired formatting (minimal or summary). This interface requires the authentication parameters to be specified.

Methodindex
HTTP VerbGET
Parameter Type Description
query string Optional search query.
output string Optional formatting can be specified as minimal or complete. Minimal just returns the web_id of each document that contains the search query, and complete provides additional details that are useful for building search engine results pages (SERPs) in your application.
limit integer Optional. The maximum number of results to return. Can be used in conjunction with the offset parameter to slice the results as needed.
offset integer Optional. Skip the first N results, where N is the supplied offset. Can be used in conjunction with the limit parameter to slice the results as needed.
key string Public API Key (see Settings).
signature string Required. Unique Base64-encoded HMAC-SHA1 (see Generating a Signature).
timestamp string Required. Ex: 1233438639 (see Time since the epoch)
Choose a Service Output URL
XML http://vuzit.com/documents.xml
XML with SSL https://ssl.vuzit.com/documents.xml
JSON http://vuzit.com/documents.json
JSON with SSL https://ssl.vuzit.com/documents.json

Responses

A successful interaction returns an HTTP response code of 200. The XML or JSON response contains a number of attributes about the document. Responses that return errors are covered in the Failure Responses section.

Example XML Request

This returns all documents stored in the account.

Methodshow
HTTP VerbGET
FormatXML
URLhttp://vuzit.com/documents.xml
<?xml version="1.0" encoding="UTF-8"?>

   
    e
  
   
    d
   
    b
  
   
    3
  
 

Example JSON Request with Search

This returns all documents stored in the account that contain the string "Vuzit ROCKS"

Methodshow
HTTP VerbGET
FormatJSON
Search QueryVuzit ROCKS
Outputminimal
URLhttp://vuzit.com/documents.json?q=VUZIT%20ROCKS&output=minimal
{
  "documents": {
    "document": [
      {
        "web_id": "e"
      }, 
      {
        "web_id": "d"
      }
    ], 
    "length": "2", 
    "output": "minimal"
  }
}

show

This method will download a document in your account, or retrieve associated information about that document.

Methodshow
HTTP VerbGET
Parameter Type Description
web_id string A unique Vuzit identifier returned from the create method. This parameter precedes the format in the URL of the request (e.g. http://vuzit.com/documents/oc.xml).
key string Public API Key (see Settings).
watermark string Only for downloading a PDF document, and entirely optional. This will place the specified string directly on each page of the document.
Note: This parameter must also be added to the signature for authentication (see Generating a Signature).
signature string Optional for Public documents unless the watermark parameter is specified. Unique Base64-encoded HMAC-SHA1 (see Generating a Signature).
timestamp string Optional for Public documents. Ex: 1233438639 (see Time since the epoch)
Choose a Service Output URL
XML http://vuzit.com/documents/[web_id].xml
XML with SSL https://ssl.vuzit.com/documents/[web_id].xml
JSON http://vuzit.com/documents/[web_id].json
JSON with SSL https://ssl.vuzit.com/documents/[web_id].json
Download Document (see create for permissions) http://vuzit.com/documents/[web_id].[file_type]
Download Document with SSL (see create for permissions) https://ssl.vuzit.com/documents/[web_id].[file_type]
Download PDF (see create for permissions) http://vuzit.com/documents/[web_id].pdf
Download PDF with SSL (see create for permissions) https://ssl.vuzit.com/documents/[web_id].pdf

Responses

A successful interaction returns an HTTP response code of 200. The XML or JSON response contains a number of attributes about the document, and downloaded documents return a binary stream. Responses that return errors are covered in the Failure Responses section.

Example XML Request

Note that documents where the secure flag is set require the authentication parameters.

Methodshow
HTTP VerbGET
FormatXML
URLhttp://vuzit.com/documents/oc.xml
<?xml version="1.0" encoding="UTF-8" ?>

  http://diglib.org/forums/fall2007/presentations/Payette1.pdf 
  <title>PowerPoint Presentation</title>
  8
  720
  540
  1322267
  
  1194374255
  oc
  jpg
  3

Example JSON Request

Note that documents where the secure flag is set require the authentication parameters.

Methodshow
HTTP VerbGET
FormatJSON
URLhttp://vuzit.com/documents/oc.json
{
  "document": {
    "url":"http://diglib.org/forums/fall2007/presentations/Payette1.pdf",
    "title":"PowerPoint Presentation",
    "page_count":"8",
    "width":"720",
    "height":"540",
    "file_size":"1322267",
    "subject":"",
    "modified_at":"1194374255",
    "web_id":"oc",
    "image_type":"jpg",
    "zoom_count":"3"
}

Example Download Request (Microsoft Word Document)

This is an example where a Microsoft Word document was uploaded via create, and the download_document parameter was specified as a 1 so it is available for download.

Note that documents where the secure flag is set require the authentication parameters.

Methodshow
HTTP VerbGET
FormatBinary: Uploaded Document (any format)
URLhttp://vuzit.com/documents/1iin.doc

Example Download Request (Generated PDF Document)

This is an example where a Microsoft Word document was uploaded via create, and the download_pdf parameter was specified as a 1 so a PDF is generated and available for download. Alternatively this will work if a PDF is uploaded via create and the download_document parameter was specified as a 1.

Note that documents where the secure flag is set require the authentication parameters. If the watermark parameter is specified, then you must specify the authentication parameters regardless of whether or not the secure flag is set.

Methodshow
HTTP VerbGET
FormatBinary: PDF Document
URLhttp://vuzit.com/documents/1iin.pdf

destroy

This method will remove a document from your Vuzit account.

Methoddestroy
HTTP VerbDELETE
Parameter Type Description
web_id string A unique Vuzit identifier returned from the create method. This parameter precedes the format in the URL of the request (e.g. http://vuzit.com/documents/oc.xml).
key string Public API Key (see Settings)
signature string Unique Base64-encoded HMAC-SHA1 (see Generating a Signature)
timestamp string Ex: 1233438639 (see Time since the epoch)
Choose a Service Output URL
XML http://vuzit.com/documents/[web_id].xml
XML with SSL https://ssl.vuzit.com/documents/[web_id].xml
JSON http://vuzit.com/documents/[web_id].json
JSON with SSL https://ssl.vuzit.com/documents/[web_id].json

Responses

A successful interaction returns an HTTP response code of 200. It does not return any XML or JSON. Responses that return errors are covered in the Failure Responses section.


Pages API

The URL of the request determines the output format (JPG, JSON, or XML), and whether or not to use SSL transport layer security. Examples are given below, and more examples can be found in our Javascript code samples. This API does not contain a create or destroy method and can only be performed on the entire document using the Documents API.

index

This method returns the text that is contained on a page, and is ideal for online marketing purposes (SEO and SEM). Note that documents where the secure flag is set require the authentication parameters.

Methodindex
HTTP VerbGET
Parameter Type Description
web_id string A unique Vuzit identifier returned from the create method of the Documents API.
included_pages string The range of pages from which text should be returned. Indexing begins at 0. This can be something as complicated as: "0-1,4-6,81,83,96-103"
key string Public API Key (see Settings).
signature string Unique Base64-encoded HMAC-SHA1 (see Generating a Signature).
timestamp string Optional for Public documents. Ex: 1233438639 (see Time since the epoch)
Choose a Service Output URL
XML http://vuzit.com/documents/[web_id]/pages.xml
XML with SSL https://ssl.vuzit.com/documents/[web_id]/pages.xml
JSON http://vuzit.com/documents/[web_id]/pages.json
JSON with SSL https://ssl.vuzit.com/documents/[web_id]/pages.json

Responses

A successful interaction returns an HTTP response code of 200 with the JPEG file in the body of the message. Errors are returned as an HTTP 403 Forbidden message.

Example

Methodindex
HTTP VerbGET
FormatJSON
URLhttp://vuzit.com/documents/1/pages.json?key=70f18270-f270-185d-a0b5-082befee3502&signature=YwhRK1Gm3u7MiPptvp2cpm3VWBE%3D&timestamp=1266786770&included_pages=0,1

show

We typically refer to the process of downloading an image from the Pages API collectively as the Image API. This method will download a page of a document at a particular zoom level. Currently Vuzit uses the JPEG file format. One of the major benefits of the Image API is that it can be used directly in an HTML <img> tag. Note that documents where the secure flag is set require the authentication parameters.

Methodshow
HTTP VerbGET
Parameter Type Description
web_id string A unique Vuzit identifier returned from the create method of the Documents API.
page string The page number of the document. Indexing begins at 0.
z string Image API only. The zoom level of the document. Most Vuzit accounts have 3 zoom-levels plus a thumbnail image. Indexing begins at 0 (and typically up to z=2). This option cannot be used in conjunction with the t option to request a thumbnail.
t string Image API only. This option specifically requests a thumbnail image (e.g. t=thumb). This option cannot be used in conjuction with the z option to request a specific zoom level.
key string Public API Key (see Settings).
signature string Unique Base64-encoded HMAC-SHA1 (see Generating a Signature).
timestamp string Optional for Public documents. Ex: 1233438639 (see Time since the epoch)
Choose a Service Output URL
JPEG http://vuzit.com/documents/[web_id]/pages/[page].jpg
JPEG with SSL https://ssl.vuzit.com/documents/[web_id]/pages/[page].jpg

Responses

A successful interaction returns an HTTP response code of 200 with the JPEG file in the body of the message. Errors are returned as an HTTP 403 Forbidden message.

Example JPEG Requests

Examples of downloading thumbnail and a particular zoom level are given below. More examples can be found in our Javascript code samples.

Example JPEG Request for Thumbnail

Methodshow
HTTP VerbGET
FormatJPEG
URLhttp://vuzit.com/documents/he8/pages/0.jpg?t=thumb&key=Vuzit

Example JPEG Request for Smallest Zoom Level

Methodshow
HTTP VerbGET
FormatJPEG
URLhttp://vuzit.com/documents/he8/pages/0.jpg?z=0&key=Vuzit

Events API

The URL of the request determines the output format (JSON or XML), and whether or not to use SSL transport layer security. The Events API does not contain a show, create, or destroy method.

index

This method provides a search interface where the search results are returned as either XML or JSON. You can query for each event type that is supported by the viewer, and the custom attributes that may have been applied (e.g. typically used for a username in your application).

Methodindex
HTTP VerbGET
Parameter Type Description
web_id string A unique Vuzit identifier returned from the create method.
event string The Event Type to query.
custom string Optional. If you associated a custom attribute with your viewer instances, then you can query based on this field as well. This is typically used to associate a username in your application to a specific viewer instance.
limit integer Optional. The maximum number of results to return. Can be used in conjunction with the offset parameter to slice the results as needed.
offset integer Optional. Skip the first N results, where N is the supplied offset. Can be used in conjunction with the limit parameter to slice the results as needed.
key string Public API Key (see Settings).
signature string Required. Unique Base64-encoded HMAC-SHA1 (see Generating a Signature).
timestamp string Required. Ex: 1233438639 (see Time since the epoch)
Choose a Service Output URL
XML http://vuzit.com/events.xml
XML with SSL https://ssl.vuzit.com/events.xml
JSON http://vuzit.com/events.json
JSON with SSL https://ssl.vuzit.com/events.json

Event Types

The following events are currently tracked by the standard Vuzit viewer, and have a number of attributes associated with them:

  • document_loaded: returns the IP address, user agent, referer, time requested (since EPOCH), and any custom attributes when the document is opened.
  • document_unload: returns the IP address, user agent, referer, time requested (since EPOCH), and any custom attributes when the document is closed.
  • page_view: returns the IP address, user agent, agent, referer, time requested (since EPOCH), seconds-on-page, and any custom attributes for each page view within a document
  • download_original_click: returns the IP address, user agent, referer, time requested (since EPOCH), and any custom attributes when the Download button is clicked.
  • download_pdf_click: returns the IP address, user agent, referer, time requested (since EPOCH), and any custom attributes when the Print PDF button is clicked.
  • zoom_in: returns the page number, IP address, user agent, referer, time requested (since EPOCH), and any custom attributes when the reader zooms-in on a particular page.
  • zoom_out: returns the page number, IP address, user agent, referer, time requested (since EPOCH), and any custom attributes when the reader zooms-out on a particular page.

Responses

A successful interaction returns an HTTP response code of 200. The XML or JSON response contains all of the attributes described above. Responses that return errors are covered in the Failure Responses section.

Example XML Request (document_loaded)

Note that documents where the secure flag is set require the authentication parameters.

Methodindex
HTTP VerbGET
FormatXML
URLhttps://ssl.vuzit.com/events.xml?web_id=1oto&event=document_loaded


  
    76.124.109.32
    document_loaded
    767814
    1oto
    https://ssl.vuzit.com/user/view/1oto?oid=3
    Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5
    
    1260307295
    
    
  

Example JSON Request (page_view)

Note that documents where the secure flag is set require the authentication parameters.

Methodindex
HTTP VerbGET
FormatJSON
URLhttps://ssl.vuzit.com/events.json?web_id=1oto&event=page_view
{
  "event": {
    "remote_host": "79.252.112.122",
    "event": "page_view",
    "web_id": "1oto",
    "referer": "https://ssl.vuzit.com/user/view/1oto?oid=3",
    "user_agent": "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5",
    "value": "",
    "requested_at": "1260307293",
    "page": 1,
    "duration": 30
  }
}

Authentication

Most requests require authentication which protects you from unauthorized and malicious use of your account. This is achieved by passing in your public key, a specially constructed signature, and a timestamp. You may be able to skim the remainder of this section and jump right to the Example Authentication Code.

The Vuzit REST API uses an HTTP authentication scheme based on a keyed-HMAC (Hashing for Message Authentication) signature for authentication as defined by RFC 2104. This scheme should be familiar to developers of the popular Amazon S3 web service.

Public and Private Keys

  1. Go to the Settings page to retrieve your keys (requires login).
  2. Note your Public and Private Key values.

Generating a TimeStamp

The timestamp is represented as the number of seconds since the epoch in the UTC timezone.

The timestamp is used as part of the authentication process and ensures that a request is only valid for a limited amount of time. The intention of these restrictions is to limit the possibility that intercepted requests could be replayed by an adversary. For even stronger protection against eavesdropping, we offer an encrypted connection using SSL.

Generating a Signature

To authenticate a request, you first concatenate several parameters into a string, and then apply the HMAC-SHA1 algorithm using your Private Key to get the signature. This is informally called signing the request, and we call the output the signature because it simulates the security properties of a real signature.

The algorithm takes as input two byte-strings: a key and a message. The output of HMAC-SHA1 is also a byte string, called the digest. The Signature request parameter is constructed by Base64 encoding this digest. The output of HMAC-SHA1 is also a byte string, called the digest. The Signature request parameter is constructed by Base64 encoding this digest. The show and destroy methods must be URL-encoded (i.e. CGI escaped), but not the create method. The following procedure describes how to create the signature:

  1. Produce the string_to_sign by concatenating the following parameters together into a single string without spaces:
    • Method name (e.g. create, show, destroy)
    • web_id (required for show and destroy)
    • Public Key
    • Timestamp (see above)
    • Watermark (optional: for downloading documents that contain digital watermarks via the show method)
  2. Apply the HMAC algorithm with the SHA-1 digest algorithm (HMAC-SHA1) to the string_to_sign, using your Private Key as the key for the SHA-1 algorithm.
  3. Apply the base64 encoding algorithm to the result of the previous step.
  4. If using the show and destroy methods, then the signature must get URL encoded (ie. CGI escaped).
Example for create method
step 1: methodcreate
step 1: public_keyb2d3af4c-82ba-9950-b272-4dcd5e3f80ea
step 1: timestamp123456789
step 1: string_to_signcreateb2d3af4c-82ba-9950-b272-4dcd5e3f80ea123456789
step 2: private_key86d99a7b-623a-e850-b351-542a0c901dc6
step 3 + 4: signature (escaped)uhuak2GjhZhUTx0WyNW%2BuTNWycA%3D
Example for index method (search query)
step 1: methodindex
step 1: public_keyb2d3af4c-82ba-9950-b272-4dcd5e3f80ea
step 1: timestamp1264996929
step 1: search querysecurity
step 1: string_to_signindexb2d3af4c-82ba-9950-b272-4dcd5e3f80ea1264996929security
step 2: private_key86d99a7b-623a-e850-b351-542a0c901dc6
step 3 + 4: signature (escaped)CcenhuFD2ABNy801YaWizDsPgVE%3D
Example for show method
step 1: methodshow
step 1: web_idoc
step 1: public_keyb2d3af4c-82ba-9950-b272-4dcd5e3f80ea
step 1: timestamp123456789
step 1: string_to_signshowocb2d3af4c-82ba-9950-b272-4dcd5e3f80ea123456789
step 2: private_key86d99a7b-623a-e850-b351-542a0c901dc6
step 3: signatureZQhb4E65/HfB/ZIs9G/FptMzWXs=
step 4: signature (escaped)ZQhb4E65%2FHfB%2FZIs9G%2FFptMzWXs%3D
Example for show method (Download with Digital Watermarks)
step 1: methodshow
step 1: web_idoc
step 1: public_keyb2d3af4c-82ba-9950-b272-4dcd5e3f80ea
step 1: timestamp123456789
step 1: string_to_sign (unescaped spaces)showocb2d3af4c-82ba-9950-b272-4dcd5e3f80ea123456789John Doe: 10/06/09 01:37PM
step 2: private_key86d99a7b-623a-e850-b351-542a0c901dc6
step 3: signaturefRkzwKEnmEheRTKKAdyudmsCSrA=
step 4: signature (escaped)fRkzwKEnmEheRTKKAdyudmsCSrA%3D
Example for destroy method
step 1: methoddestroy
step 1: web_idoc
step 1: public_keyb2d3af4c-82ba-9950-b272-4dcd5e3f80ea
step 1: timestamp123456789
step 1: string_to_signdestroyocb2d3af4c-82ba-9950-b272-4dcd5e3f80ea123456789
step 2: private_key86d99a7b-623a-e850-b351-542a0c901dc6
step 3: signatureMpXqIdMQ6opzTzZygTkOHxvc+qM=
step 4: signature (escaped)MpXqIdMQ6opzTzZygTkOHxvc%2BqM%3D

Example Authentication Code

Web Service APIs, in general, are language-agnostic so we have provided some example code you can use in different server-side systems. These examples will only generate the signature and timestamp for you, and are not complete examples.

Web Services Libraries

Please Contact Us if you would like to contribute code to this section, need samples for other languages, or have any other questions.