This site has been archived. To learn more about our current products Ibexa Content, Ibexa Experience, Ibexa Commerce head over to the Ibexa Developer Portal

eZ Community » Blogs » Damien Pobel » REST API Demo application at the eZ...


REST API Demo application at the eZ Unconf #2

Thursday 13 June 2013 2:45:37 pm

  • Currently 5 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

(For french speaking people, a french version of this article is available on my own blog)

One part of the Public API and REST API workshop at the eZ Unconference 2013 was dedicated to a concrete demo of the eZ Publish REST API v2. I chose to build a completely static HTML5/JavaScript application to show that with a very few lines of code, it's possible to build a quite fancy application :-)

The application

The code of this application is now available on Github in the eZunConf2013-REST-API-demo repository and you can install it in any recent enough eZ Publish 5 setup. With a modern browser supporting the getUserMedia/Stream API, it allows to take a photo with your computer webcam and to create the corresponding Image content in eZ Publish! Here's a quick screencast showing it in action:

You can imagine such feature on any site where you want the users to have a proper picture profile for instance a social network, a company intranet, a community website, ...

Some technical details

  • As you can see in the screencast, the browser asks for a login and a password. This is because the Basic authentication method is used (the default method for now), but it's also possible to enable the session authentication method.
  • 6 HTTP requests are needed to create the content and to retrieve its URI. This might sound a lot but that's because our REST API is divided into fine-grained resources. This is a good practice when designing a REST API. You are also not supposed to build any resource URIs on the client side but always retrieve it from a previous REST answer. Fortunately, we will provide some clients API (in PHP and JavaScript) so that you're not forced to work at the HTTP level.
  • The application has to be on the same domain as eZ Publish. This is a limitation imposed by browsers by default. It's possible to workaround this issue, I just did not have time to implement this in this demo.

For others technical details, I let you examine the JavaScript source code. Please be lenient on the code, this example was really build in a hurry and to be as easy as possible to understand. I hope I'll find the time to create a better and a more advanced example soon.

Resources about the eZ Publish REST API v2

Proudly Developed with from