This article will be most helpful for students attending Bloc’s Web Development Bootcamp, but can also provide some relevant information to those seeking to learn more about Ruby Gem API clients and JSON Web Tokens.
The introduction to building the Kele API client at Bloc prompted me to look up a lot of things I had kind of been putting off. My cohorts and I are getting to a point in our curriculum where the work is so much more independent and that requires you to need a better understanding of the fundamentals. So, below you’ll find some of the notes I took as I broke down Bloc’s description of the project. A fundamental understanding of what is being said below will better prepare you for building the Kele API client.
Let’s break this down:
Bloc says: “Build Kele, a Ruby Gem API client to access the Bloc API.
- We’ll be using Ruby on Rails to create some kind of project named Kele (name of the lead singer of a band called Bloc Party. Get it? Bloc Party!).
“A Ruby Gem API client”:
- An API client is basically a helper library that includes chunks of code that do the basic things an application needs to do in order to interact with the API. By wrapping this helper library in a Ruby gem, it gives developers an easy way to add it to their projects.
“To access the Bloc API”:
- Bloc’s API sits on top of the underlying complexities of the program and allows us to gain access to certain data. It helps to simplify certain tasks so that we don’t need to know what’s going on under the hood.
In a nutshell:
- We’ll be building a helper library and wrapping it in a Ruby gem so that developers can easily add it to their projects. The Ruby gem will be used to access data from Bloc’s API.
Let’s break this down:
Bloc says: “Bloc’s API provides an external facing JSON Web Token authorized gateway to the Bloc application. You can access it via cURL, but an API client can manage the low-level details of making requests and handling responses. Build the Kele API Client to provide easy access to and use of the student endpoints of Bloc’s API.”
“Bloc’s API provides an external facing JSON Web Token authorized gateway to the Bloc application.”:
- This statement should read like this: “Bloc’s API provides an external-facing (JSON Web Token)-authorized gateway to the Bloc application.”
- It’s saying that Bloc’s API provides a gateway to the Bloc application. As far as we know, it’s the only way in and out. The gateway is authorized by JSON Web Token. If you don’t have the right token, you don’t get to enter the gate and access the application.
- So it’s actually Kele that is passing the credentials to Bloc. If it provides a valid Bloc account in the token, Bloc lets it access the application and retrieve any data it needs, which is returned to the Kele client.
“You can access it via cURL, but an API client can manage the low-level details of making requests and handling responses.”:
- This statement is saying that you could access the data on Bloc’s API with cURL, a command line tool and library used to transfer data, but it’s easier to manage requests and responses with Kele.
- There are many benefits to using a client API over cURL. The client API provides a layer of abstraction — we don’t have to know how it works, only what it does to be able to use it.
- We can also easily drop it into any Ruby project, so we don’t have to figure out how to form cURL commands or any of the specifics, all we have to do is re-use the existing methods for whatever purpose the new project needs them for.
“Build the Kele API Client to provide easy access to and use of the student endpoints of Bloc’s API.”:
- I’ll be building Kele (essentially a helper library) to provide easy access to all of the data on Bloc’s API that is available to students.
There is so much more to be said! If you want to contribute relevant information you find as you direct these statements, please share with us all!