Recently, while spending my time browsing random things on internet, I came across an interesting project from Axel Fuhrmann.
It is a Rest API of the cartoon Rick and Morty do Adult Swim (which I’m a big fan).
The API brings information about characters, episodes and planets (Locations) related to each other. The form of query is pretty simple and I really liked what I saw.
Digging into API Documentation I was able to see several native clients for various languages (such as Python, Ruby, Elixir, etc …) and figured that there was no Java version for this. At this point, I decided to implement Java native client for it. Behold, the Rick and Morty API Java Client.
this client is very simple and it basically encapsulate calls to the service in an intuitive way for each desired object. For example, let’s say we want to get information from the Rick Sanchez, which in the API is related to ID 1. We would do something like:
1 2 3 4 5 6 |
// Create a new Character with ID 1 Character rickSanchez = character.setId(1); // Refresh its data rickSanchez.refresh(); // Check if its name is right assertEquals("Rick Sanchez", rickSanchez.getName()); |
The same way, each relationship brings a list of Objects containing only the IDS and it must refresh()
the object to fetch its extra data.
Implementing this client was an interesting exercise and I really liked the result. Hope you like it!