Payswarm - Web API

Unofficial Draft 23 March 2010

Editor:
Manu Sporny, Digital Bazaar, Inc.

Abstract

This document defines a set of REST Web APIs to enable the legal transfer of commercialized digital content. These APIs enable new Web-based business models by specifying methods of interaction between user agents and web servers to exchange digital goods and ensure the subequent distribution of monetary compensation to the content distributors and rights holders.

Status of This Document

This document is merely a public working draft of a potential specification. It has no official standing of any kind and does not represent the support or consensus of any standards organisation.

Table of Contents

1. Introduction

2. Network Participants

3. Content Transaction Overview

PaySwarm purchase process diagram #1
PaySwarm purchase process diagram #2
PaySwarm purchase process diagram #3

4. Base Technologies

4.1 REST

4.2 Javascript Object Notation

4.3 AES Cryptography Suite

4.4 RDFa

5. Discovery

5.1 API Discovery

5.2 Content Discovery

6. The Purchase Process

This section describes the media discovery, license acquisition, contract drafting, negotiating, data transfer, payment and file assembly process in detail.

6.1 Media Discovery

6.2 License Selection

6.3 Asserting Purchase Preferences

6.4 Creating a Ware Bundle

6.5 Brokering a Non-Swarming Contract

6.6 Brokering a Swarming Contract

6.7 Negotiating with a Seller

6.8 Downloading a FilePiece

6.9 Purchasing the License

6.10 Purchasing the Data

6.11 Assembling the Data

7. Security Concerns

7.1 Identity Management

7.2 Digital Signatures

7.3 Encryption and Decryption

7.4 Identifying and Removing Troublemakers

7.5 Halting Content Distribution

8. API Reference

This section contains all of the developer documentation for interacting with a PaySwarm network via a standard set of REST-based API calls. Programs written in Javascript Python, Ruby, C, C++, C#, Perl, and many other programming languages can be written to interact with a PaySwarm network via the following Web Services.

bfp

catalog

contract

financial

media

POST /payees/resolve

Resolves a set of given payees to the final dollar amount.
Authentication: Optional
Returns: The return value is currently not documented.

Input Validator

(
   
   (
   
      (
         licenseAmount: string
      )
      or
   
      (
         licensePayees: array
      )
   )
   and
   
   (
      licenseAmount: optional precisemoney
      piecePayees: optional 
      (
         array
         and
         each item matches
         (
            mediaId: optional integer range(0 - 4294967296)
            description: optional string
            min: optional string
            amount: optional precisemoney
            amountResolved: optional boolean
            amountType: string
            percentage: optional string
            id: integer range(1 - 4294967296)
            taxExempt: optional boolean
         )
      )
      filePieceCount: optional integer range(1 - 4294967296)
      licensePayees: optional 
      (
         array
         and
         each item matches
         (
            mediaId: optional integer range(0 - 4294967296)
            description: optional string
            min: optional string
            amount: optional precisemoney
            amountResolved: optional boolean
            amountType: string
            percentage: optional string
            id: integer range(1 - 4294967296)
            taxExempt: optional boolean
         )
      )
      dataPayees: optional 
      (
         array
         and
         each item matches
         (
            mediaId: optional integer range(0 - 0)
            description: optional string
            min: optional string
            amount: optional precisemoney
            amountResolved: optional equals false
            amountType: 
            (
            equals PAYEE_AMOUNT_TYPE_FLATFEE
               or
            equals PAYEE_AMOUNT_TYPE_PLICENSE
               or
            equals PAYEE_AMOUNT_TYPE_PCUMULATIVE
               or
            equals PAYEE_AMOUNT_TYPE_PTOTAL
            )
            percentage: optional string
            id: integer range(1 - 4294967296)
            taxExempt: optional boolean
         )
      )
   )
)

GET /catalog/server?nodeuser=A

Gets a user's server information, including their server ID, server token, and server url.
Authentication: Required
Returns: an HTTP 200 code if successful, an exception if not.

Query Parameters

Query Validator

(
   nodeuser: integer range(1 - 4294967296)
)

GET /catalog/sellerpools?fileId=A&mediaIds=B

Gets all media IDs associated with the given file ID in the set of all seller pools. Typically, there will be only one.
Authentication: Required
Returns: The return value is currently not documented.

Query Parameters

Query Validator

(
   mediaIds: equals true
   fileId: fileid
)

GET /catalog/sellerpools/<mediaId>

Gets all seller pools for the given media ID in the given range.
Authentication: Required
Returns: The return value is currently not documented.

Path Parameters

GET /catalog/sellerpools/<mediaId>/<fileId>

Gets the seller pool for the given media ID and file ID.
Authentication: Required
Returns: The return value is currently not documented.

Path Parameters

GET /catalog/payees/schemes?nodeuser=A

Gets a set of payee schemes from a user's custom catalog given a set of filters.
Authentication: Required
Returns: an HTTP 200 code if successful, an exception if not.

Query Parameters

GET /catalog/payees/schemes/<schemeId>?nodeuser=A

Gets an existing payee scheme from a user's custom catalog.
Authentication: Required
Returns: an HTTP 200 code if successful, an exception if not.

Path Parameters

Query Parameters

Query Validator

(
   nodeuser: integer range(1 - 4294967296)
)

POST /catalog/payees/schemes?nodeuser=A

Creates a new payee scheme in a user's custom catalog. The message body must contain a PayeeScheme object.
Authentication: Required
Returns: an HTTP 200 code if successful, an exception if not.

Query Parameters

Query Validator

(
   nodeuser: integer range(1 - 4294967296)
)

Input Validator

(
   payees: datapayees
   description: 
   (
      string
      and
      more than 1 character
   )
)

POST /catalog/payees/schemes/<schemeId>?nodeuser=A

Updates an existing payee scheme in a user's custom catalog. The message body must contain an array of Payee objects.
Authentication: Required
Returns: an HTTP 200 code if successful, an exception if not.

Path Parameters

Query Parameters

Query Validator

(
   nodeuser: integer range(1 - 4294967296)
)

Input Validator

(
   payees: datapayees
   description: 
   (
      string
      and
      more than 1 character
   )
)

DELETE /catalog/payees/schemes/<schemeId>?nodeuser=A

Deletes an existing payee scheme from a user's custom catalog.
Authentication: Required
Returns: an HTTP 201 code if successful, an exception if not. // DELETE .../payees/schemes/

Path Parameters

Query Parameters

Query Validator

(
   nodeuser: integer range(1 - 4294967296)
)

GET /sva/contracts/sections/<contractId>/<sellerId>

Gets the contract sections for a particular seller, according to that seller's user ID and the related contract ID.
Authentication: Required
Returns: The return value is currently not documented.

Path Parameters

POST /catalog/netaccess/test?nodeuser=A

Responds to a token sent to this server to determine if another entity can access it over the net. If the token matches the unique token used by this catalog, this method will return with success.
Authentication: Required
Returns: an HTTP 201 code if successful, an exception if not.

Query Parameters

Query Validator

(
   nodeuser: integer range(1 - 4294967296)
)

Input Validator

(
   ip: string
   token: 
   (
      string
      and
      less than 50 characters
   )
)
Retrieves a ResourceSet of Media that are related to the specified media ID in an optionally provided way.
Authentication: Optional
Returns: HTTP 200 and a ResourceSet if successful, an exception otherwise.

Path Parameters

Query Parameters

Query Validator

(
   start: optional integer range(0 - 4294967296)
   num: optional integer range(0 - 4294967296)
   relationship: optional regex("^(similar)$")
)

GET /media?genre=A&list=B&num=C&owner=D&query=E&start=F

Retrieves a set of media resources an a ResourceSet. The contents of the media resources are modified by the content filters passed as query parameters.
Authentication: Optional
Returns: HTTP 200 code and a ResourceSet containing all of the media items if successful, an exception otherwise.

Query Parameters

Query Validator

(
   index: optional regex("^(contributors|media)$")
   list: optional integer range(1 - 4294967296)
   owner: optional integer range(1 - 4294967296)
   start: optional integer range(0 - 4294967296)
   num: optional integer range(1 - 50)
   genre: optional integer range(1 - 4294967296)
   query: optional 
   (
      string
      and
      more than 2 characters
      and
      less than 320 characters
   )
   type: optional string
)

GET /media/<mediaId>

Retrieves a single media resource by id. The contents of the media resource are modified by the content filters passed as query parameters.
Authentication: Optional
Returns: HTTP 200 and a Media object if successful, an exception otherwise.

Path Parameters

POST /media

Adds or updates a single Media resource.
Authentication: Required
Returns: HTTP 200 if successful, an exception otherwise.

Query Validator

(
   id: integer range(0 - 4294967296)
)

POST /media/<mediaId>

Updates a single Media resource.
Authentication: Required
Returns: HTTP 200 if successful, an exception otherwise.

Path Parameters

Query Validator

(
)

DELETE /media/<mediaId>

Deletes a single Media resource.
Authentication: Required
Returns: HTTP 200 if successful, an exception otherwise.

Path Parameters

GET /catalog/wares/<wareId>

Populates a ware according to its ID.
Authentication: Optional
Returns: The return value is currently not documented.

Path Parameters

POST /catalog/wares?nodeuser=A

Creates or updates an existing Ware in a user's catalog with the given ware.
Authentication: Required
Returns: HTTP 200 OK if the add was successful, an exception otherwise.

Query Parameters

Query Validator

(
   nodeuser: integer range(1 - 4294967296)
)

Input Validator

(
   
   (
      mediaId: integer range(1 - 4294967296)
      id: 
      (
         string
         and
         more than 1 character
      )
      description: optional string
   )
   and
   
   (
   
      (
         fileInfo: 
         (
            id: fileid
         )
      )
      or
   
      (
         fileInfos: 
         (
            array
            and
            more than 1 character
            and
            less than 1 characters
            and
            each item matches
            (
               id: fileid
            )
         )
      )
   )
   and
   
   (
   
      (
         payeeSchemeId: integer range(1 - 4294967296)
      )
      or
   
      (
         payees: datapayees
      )
   )
)

GET /catalog/wares?nodeuser=A

Populates Wares that is contained in a user's catalog based on ware IDs or file IDs.
Authentication: Optional
Returns: HTTP 200 OK and a Ware if the ware exists, an exception otherwise.

Query Parameters

GET /catalog/wares/<wareId>?nodeuser=A

Populates a Ware that is contained in a user's catalog.
Authentication: Optional
Returns: HTTP 200 OK and a Ware if the ware exists, an exception otherwise.

Path Parameters

Query Parameters

Query Validator

(
   nodeuser: integer range(1 - 4294967296)
)

DELETE /catalog/wares/<wareId>?nodeuser=A

Deletes a Ware that is contained in a user's catalog.
Authentication: Required
Returns: HTTP 200 OK if the ware was deleted successfully, or an exception otherwise.

Path Parameters

Query Parameters

Query Validator

(
   nodeuser: integer range(1 - 4294967296)
)

POST /sva/contracts/media/<mediaId>

Gets a signed media license for a particular buyer.
Authentication: Required
Returns: The return value is currently not documented.

Path Parameters

Input Validator

(
null
   or
dynamiclicensepayees
)

GET /sva/contracts/<contractId>

Gets a contract by its ID.
Authentication: Required
Returns: The return value is currently not documented.

Path Parameters

POST /sales/contract/filepiece

Retrieves a filepiece from the seller.
Authentication: Required
Returns: the encrypted data for the filepiece followed by trailers with signatures and encrypted key(s).

Query Validator

(
   nodeuser: integer range(1 - 4294967296)
)

Input Validator

(
   index: integer range(0 - 4294967296)
   peerbuyKey: 
   (
      string
      and
      more than 1 character
   )
   mediaId: integer range(1 - 4294967296)
   sellerProfileId: integer range(1 - 4294967296)
   bfpId: integer range(1 - 4294967296)
   csHash: 
   (
      string
      and
      more than 1 character
   )
   fileId: 
   (
      string
      and
      more than 1 character
   )
   size: integer range(0 - 4294967296)
)

GET /catalog/sellers/<userId>

Gets a set of sellers for the given user ID.
Authentication: Required
Returns: The return value is currently not documented.

Path Parameters

GET /catalog/sellers/<userId>/<serverId>

Gets a particular seller, given the seller's user ID and server ID.
Authentication: Required
Returns: The return value is currently not documented.

Path Parameters

POST /catalog/sellers/<userId>

Adds a new seller for the given user ID. The new server ID and token will be returned on success.
Authentication: Required
Returns: The return value is currently not documented.

Path Parameters

Input Validator

(
   url: 
   (
      string
      and
      more than 1 character
   )
   listingUpdateId: string
)

POST /catalog/sellers/<userId>/<serverId>

Updates an existing seller's URL.
Authentication: Required
Returns: The return value is currently not documented.

Path Parameters

Input Validator

(
   url: 
   (
      string
      and
      more than 1 character
   )
)

POST /sales/contract/negotiate

Negotiates a contract section with a seller. The buyer provides a contract section with their desired terms, the seller responds with a signed contract section containing their acceptable terms.
Authentication: Required
Returns: the seller's signed contract section, which the buyer may elect to accept.

Query Validator

(
   nodeuser: integer range(1 - 4294967296)
)

Input Validator

(
   media: 
   (
      licenseAmount: precisemoney
      piecePayees: piecepayees
      publicDomain: boolean
      title: string
      ccLicenses: string
      payees: licensepayees
      signature: string
      releaseDate: regex("^[0-9]{4}-")
      buyerId: integer range(1 - 4294967296)
      signer: 
      (
         userId: integer range(1 - 4294967296)
         profileId: integer range(1 - 4294967296)
      )
      ownerId: integer range(1 - 4294967296)
      distribution: string
      payeeRules: 
      (
         array
         and
         each item matches
         (
            mediaId: integer range(0 - 4294967296)
            value: string
            type: string
         )
      )
      type: string
      id: integer range(1 - 4294967296)
   )
   version: equals "3.0"
   buyer: 
   (
      username: optional string
      userId: integer range(1 - 4294967296)
      delegateId: optional integer range(1 - 4294967296)
      profileId: integer range(1 - 4294967296)
   )
   sections: 
   (
      map
      and
      each item matcheseach item matches
      (
         negotiationTerms: optional map
         seller: 
         (
            username: optional string
            userId: integer range(1 - 4294967296)
            serverId: integer range(1 - 4294967296)
            url: string
         )
         webbuy: optional boolean
         buyer: 
         (
            username: optional string
            userId: integer range(1 - 4294967296)
            delegateId: optional integer range(1 - 4294967296)
            profileId: integer range(1 - 4294967296)
         )
         ware: 
         (
            id: 
            (
               string
               and
               more than 1 character
            )
         )
         contractId: optional integer range(0 - 4294967296)
      )
   )
   id: integer range(0 - 4294967296)
)

POST /sva/contracts/purchase/data

Purchases data associated with a given contract section.
Authentication: Required
Returns: The return value is currently not documented.

Input Validator

(
   date: regex("^[2-9][0-9]{3}-")
   section: 
   (
      
      (
         sellerSignature: string
         seller: 
         (
            username: optional string
            url: string
            userId: integer range(1 - 4294967296)
            profileId: integer range(1 - 4294967296)
            serverId: integer range(1 - 4294967296)
         )
         buyerSignature: string
         buyer: 
         (
            username: optional string
            userId: integer range(1 - 4294967296)
            delegateId: optional integer range(1 - 4294967296)
            profileId: integer range(1 - 4294967296)
            accountId: integer range(1 - 4294967296)
         )
         ware: 
         (
            mediaId: integer range(1 - 4294967296)
            payees: warepayees
            id: 
            (
               string
               and
               more than 1 character
            )
            description: optional string
         )
         contractId: integer range(1 - 4294967296)
      )
      and
      
      (
      
         (
            webbuy: equals true
            ware: 
            (
               fileInfos: 
               (
                  array
                  and
                  each item matches
                  (
                     contentType: string
                     extension: string
                     pieces: optional 
                     (
                        map
                        and
                        less than 0 characters
                     )
                     mediaId: integer range(1 - 4294967296)
                     size: integer range(1 - 4294967296)
                     id: string
                     contentSize: integer range(1 - 4294967296)
                  )
               )
            )
         )
         or
      
         (
            webbuy: optional equals false
            ware: 
            (
               fileInfos: 
               (
                  array
                  and
                  each item matches
                  (
                     contentType: string
                     extension: string
                     pieces: optional 
                     (
                        array
                        and
                        each item matches
                        (
                           index: integer range(0 - 4294967296)
                           ciphered: boolean
                           encrypted: boolean
                           sellerSignature: string
                           bfpSignature: string
                           pieceKey: optional 
                           (
                              data: string
                              length: integer range(1 - 4294967296)
                              algorithm: string
                           )
                           openKey: optional 
                           (
                              data: string
                              length: integer range(1 - 4294967296)
                              algorithm: string
                           )
                           sellerProfileId: integer range(1 - 4294967296)
                           bfpId: integer range(1 - 4294967296)
                           size: integer range(0 - 4294967296)
                        )
                     )
                     mediaId: integer range(1 - 4294967296)
                     size: integer range(1 - 4294967296)
                     id: string
                     contentSize: integer range(1 - 4294967296)
                  )
               )
            )
         )
      )
   )
)

GET /media/genres/<mediaType>

Retrieves the entire tree of genres for a given MediaType.
Authentication: Optional
Returns: HTTP 200 if successful and a nested map of genres, or an exception otherwise.

Path Parameters

GET /media/genres/<mediaType>

Retrieves a genre object for a given MediaType and genre ID.
Authentication: Optional
Returns: HTTP 200 and a genre object if successful, or an exception otherwise.

Path Parameters

POST /catalog/bundles

Creates a ware bundle according to the given media ID(s) and data preferences.
Authentication: Optional
Returns: The return value is currently not documented.

Input Validator

(
   mediaId: integer range(1 - 4294967296)
   preferences: 
   (
      array
      and
      each item matches
      (
         mediaIds: optional 
         (
            array
            and
            each item matchesinteger range(1 - 4294967296)
         )
         preferences: 
         (
            array
            and
            each item matches
            (
            
               (
                  contentType: regex("^audio/.+$")
                  minBitrate: integer range(1 - 4294967296)
               )
               or
            
               (
                  contentType: regex("^video/.+$")
                  videoCodec: string
               )
            )
         )
      )
   )
)

POST /sva/contracts/purchase/license

Purchases a license for the given media for a particular buyer.
Authentication: Required
Returns: The return value is currently not documented.

Input Validator

(
   
   (
      media: 
      (
         licenseAmount: precisemoney
         piecePayees: piecepayees
         publicDomain: boolean
         title: string
         ccLicenses: string
         payees: licensepayees
         signature: string
         releaseDate: regex("^[0-9]{4}-")
         buyerId: integer range(1 - 4294967296)
         signer: 
         (
            userId: integer range(1 - 4294967296)
            profileId: integer range(1 - 4294967296)
         )
         ownerId: integer range(1 - 4294967296)
         distribution: string
         payeeRules: 
         (
            array
            and
            each item matches
            (
               mediaId: integer range(0 - 4294967296)
               value: string
               type: string
            )
         )
         type: string
         id: integer range(1 - 4294967296)
      )
      version: equals "3.0"
      buyer: 
      (
         username: optional string
         userId: integer range(1 - 4294967296)
         delegateId: optional integer range(1 - 4294967296)
         profileId: integer range(1 - 4294967296)
         accountId: integer range(1 - 4294967296)
      )
      sections: optional 
      (
         map
         and
         less than 0 characters
      )
      id: integer range(0 - 0)
   )
   and

)

POST /catalog/netaccess/rtest

Performs a reverse network access test to ensure an in-the-wild sales server's catalog can be accessed via the internet. The message body must contain the sales server host, port, and URL path to post to and the token to post. If the given host is blank, the IP address of the caller will be used.
Authentication: Required
Returns: an HTTP 201 code if successful, an exception if not.

Input Validator

(
   token: 
   (
      string
      and
      less than 50 characters
   )
   host: string
   timeout: integer range(15 - 30)
   path: string
   sellerId: integer range(1 - 4294967296)
   port: integer range(1 - 65535)
)

GET /sva/bfp

Gets the BFP module for the given bfp ID, API version, operating system, and cpu type.
Authentication: Optional
Returns: The return value is currently not documented.

Query Validator

(
   os: string
   id: integer range(1 - 4294967296)
   apiVersion: string
   cpuType: string
)

A. References

A.1 Normative references

No normative references.

A.2 Informative references

No informative references.