A couple of colleagues and I decided to join ODTUG’s APEX Gaming Competition. The first challenge was to come up with a great idea for an addictive game. We had some creative people sitting around the table and after some brainstorming we ended up with a simple yet interesting concept: a movie guessing game based on a movie database web API.

Now, when you read “movie database”, the first thing you probably think of is IMDb. It came as a surprise to me that they don’t publish an (official) API. IMDb only distributes plain text data files, and that’s not really what we were looking for. In our search for an alternative, we came across TMDb (https://www.themoviedb.org/). It perfectly fitted our needs: an extensive movie database, well documented and reliable.

The MoviePick game
the MoviePick game

Before starting development, we had one important question to answer: “Do we invoke the TMDb web API from client or server side?”. The easy solution would have been to pick the client side. Calling a couple of web services in JavaScript (or jQuery) and storing their JSON result into a variable is pretty straightforward. However, this would mean that all movie information would just linger around in the browser. You would literally see the movie title passing by when keeping an eye on the incoming TMDd AJAX responses. This idea bothered us too much and made us choose to invoke the TMDb web services from server side. Each hint requested by the end user would then result in a separate AJAX call returning only the requested information.

Invoking the web services from PL/SQL also gave us the opportunity to play around with the new APEX_JSON package, which has been introduced in APEX 5.0. After getting familiar with the package, it was pretty easy to parse the TMDb JSON responses and collect all relevant movie information. Take a look at the MG_TMDB_API_PKG if you want some example code on how to use the APEX_JSON package.

Here are some useful links related to this blog post: