The censhare server offers an API through HTTP calls, commonly called REST-API. Note that this API deliberately doesn’t always follow the “pure RESTful” representational state approach that is based on stateless web resources.
The API allows to access:
- Assets and their metadata
- by ID
- by query expressed as URL matrix parameters, XML or JSON
- Asset files
- Previews, thumbnails, master files
- Resources
- Icons
- Temporary files
- XSLT Transformations
Notes:
- Our XPath- and XSLT-Engine has many extensions that allow to create, update and transform assets, for example cropping a JPEG file. Transformations are usually used to implement this functionally.
- In addition, the REST-API is extensible through Java scriptlet modules.
Restriction:
The censhare Server is designed as production system for interactive users or data hub through interfaces to various other system. The censhare-server is not designed and suitable to support a huge amount of requests through REST, for example as backend for a web site to deliver hundreds or thousands of pages per second. For this purpose, consider an Online channel web server or a Headless CMS (HCMS) to deliver your web content. Online channel and HCMS be scaled to handle huge amounts of content.
URLs and general access
Through the embedded web server of the censhare server, the REST-API can be called through standard HTTP:
|
Authentication is used and the results are limited to the access rights of the supplied user. https may be used as protocol for secured communication as well.
Note that from within the Java based desktop client, the existing client-server connection is used by specifying “censhare” as protocol instead of “http”.
|
In the client, the placeholder ${asset-id}
for the currently selected asset can be used:
Accessing assets
|
Accessing resources
|
Examples
Accessing asset metadata
Syntax: assets/ + asset parameter part
Examples:
- assets/asset/id/123 returns XML of asset ID „123“
- assets/asset/id/123/version/1 returns XML of version 1 of asset ID 123
- assets/asset/id/123/currversion/-2 returns XML of checked out version of asset ID 123
- assets/asset;censhare:asset.id=123;censhare:asset.currversion=-2 returns XML of checked out version of asset ID 123
- assets/asset;censhare:resource-key=transform:product returns XML of current version of first asset with resource key “transform:product”
Accessing files
Syntax: assets/ + storage parameter part + / file
Examples:
- assets/asset/id/123/storage/master/file returns master file of asset ID 123 „
- assets/asset/id/123/storage/preview/file returns preview file of asset ID „123“
- assets/asset/id/123/element/actual/page/1/storage/preview/file returns preview of first page of asset ID 123
- assets/asset/id/123/element/actual/0/storage/preview/file returns preview of element index 0 of asset ID 123
- assets/asset;censhare:resource-key=transform:product/storage/master/file returns master file of first asset with resource key “transform:product”
Get asset icon metadata
Syntax: assets/ + icon parameter part
Examples:
- assets/asset/id/123/icon returns asset icon of asset ID 123
- assets/asset/id/123/version/1/icon returns asset icon of version 1 of asset ID 123
- assets/asset/id/123/currversion/-2/icon returns asset icon of checked-out version of asset ID 123
- assets/asset/id/123/icon/iconset/default returns asset icon of default iconset of asset ID 123
- assets/asset/id/123/icon/iconset/default/background/dark returns asset icon of default iconset for dark background look&feel of asset ID 123
Get asset icon files
Syntax: assets/ + icon parameter part + /file
Examples:
- assets/asset/id/123/icon/file returns asset icon of asset ID 123
- assets/asset/id/123/version/1/icon/file returns asset icon of version 1 of asset ID 123
- assets/asset/id/123/currversion/-2/icon/file returns asset icon of checked-out version of asset ID 123
- assets/asset/id/123/icon/iconset/default/file returns asset icon of default iconset of asset ID 123
- assets/asset/id/123/icon/iconset/default/background/dark/file returns asset icon of default iconset for dark background look&feel of asset ID 123
Transformations
Syntax: assets/ + ; + transformation parameter
Examples:
- assets/asset/id/123/transform;key=test;format=xml returns result of transformation with key “test” and additional parameter “format” with value “xml”
- assets/asset/id/123/transform;key=test;format=xml;param1=a;param2=b returns result of transformation with key „test“ and additional parameter. The result of the XML is returned. Following parameters are available in XSLT:
|
- If you use an HTTP-post request, the payload is expected to be an XML text and then is available from the XSLT through:
|
- To avoid specifying a “dummy” asset by ID for a transformation that actually doesn’t work on a specific asset, the transformation may be called on itself:
|
Zip files
Syntax: REST URL to ZIP file + ;container=zip
Examples:
- assets/asset/id/123/storage/master/file;container=zip returns the list of files contained in the zip:
|
- assets/asset/id/123/storage/master/file;container=zip/docProps/thumbnail.jpeg returns file “thumbnail.jpeg” of folder “docProps” of master ZIP file of asset ID 123
Icons (not suitable for censhare 5 web client)
Syntax: resources/icon/ + icon parameter part + /file
Examples:
- resources/icon/add/file returns icon with key “add”
- resources/icon/add/iconset/default/file returns icon of default iconset with key “add”
- resources/icon/add/iconset/default/background/dark/file returns icon of default iconset for dark look&feel with key “add”
Asset queries
Syntax: assets/all; + search parameter part Returns XML of any assets that matches with given search criteria. Default limit is 1000 assets.
Examples:
- assets/all;censhare:asset.type=picture. returns every asset XML whose type is “picture”
- assets/all;censhare:asset.type=picture.;censhare:text.meta=ipod returns every asset XML whose type is “picture” and meta data contains “ipod”
- assets/all;censhare:asset.type=picture.;censhare:asset.name=ipod/transform;key=test returns a transformation with key „test“ of every asset XML whose type is “picture” and name contains “ipod”
For complex asset queries, HTTP post requests are used with a query expressed in XML as payload.
|
Examples:
Query for assets with „my tasks“ and (asset type is picture or asset type is video)
|
Accessing File systems
Note that for security reasons, external access is limited to the temporary file system.
Syntax: filesystem“ + URL to file
Examples:
- filesystem/temp/1234456/10000.pdf returns file “10000.pdf” in folder “1234456” of temporary file system “temp”
- filesystem/assets/13/89/138931.jpg returns file “138931.jpg” of the “assets” file system
Server statistics
Syntax:
|
Examples:
- censhare:///service/server-statistics returns list of available keys
- censhare:///service/server-statistics/key/operating-system returns system load history
- censhare:///service/server-statistics/key/JVM/latest returns current JVM heap measurement
|