The CloudPublish API is a REST-style interface to the CloudPublish platform, outputing data in JSON format. The purpose of the API is to allow a publisher to create a front-end to the CloudPublish system. The front-end can be as simple as a catalogue listing or as complex as an ecommerce book-store.
A typical process-flow when using the API is as follows:
- User on your website requests a page (e.g. list of their subscribed eBooks)
- Your website receives the request
- Your website makes a call using the CloudPublish API to the server at http://api.cloudpublish.co.uk requesting the list of subscribed eBooks for this user (this request consists of a HTTP GET or POST to a structured URL that contains a reference to the user)
- The CloudPublish server performs the necessary lookups in the CloudPublish database and returns JSON data
- Your website parses this JSON and creates HTML to return to the user for display
Sometimes the CloudPublish server will return an error instead of data (for example, if your request was badly structured or did not make sense to the server). These error messages are returned in the same JSON structure but are clearly marked as errors, for which you should check before attempting to present data to the user. The error messages are aimed at the developer, and we do not advise simply forwarding them on to the user.
Demonstration and example code
A simple example site, for a fictitious publisher, is available here: http://www.cloudpublishdemo.co.uk. The code (PHP) used to create this site includes a CloudPublishConnector class that is intended to make integration more straightforward.The demonstration code is available to download from within the CloudPublish administration tool, under "API Examples".
It is important to note a few things that the CloudPublish API does not provide a customer/user database. It is expected that you will maintain your own customer-facing systems / website, and then supply a unique customer identifier to the API when referring to a specific customer (e.g., retrieving subscription data for a customer). This identifier would typically be the same ID or unique customer number as used in your own customer account database, thereby enabling you to link records effectively.
The CloudPublish API is fully documented here (http://www.cloudpublish.co.uk/api/).