In this post I will be building out an API with  Google’s Firebase. I will be building out the back-end with  Firebase Cloud Functions and  ExpressJS.

Before I begin, I recommend you have the following setup:

  1. A terminal setup on either a Windows, Linux, or Mac (OSX) computer
  2. Node 10.10 installed
  3. NVM installed  with the instructions here
  4. A Google Account
  5. Postman installed
  6. Firebase CLI installed with a run of the terminal command npm install -g firebase-tools

I’m going to be referring to the code available  at this GitHub repo. The GitHub repo also contains a Postman Collection — I recommend importing that collection and using that to test your project. Please note that the app id in the URL paths is specific to my deployed project. You’ll need to change the app id to match a project you’ll be creating in the Firebase Console. If you don’t understand that yet, it’s okay - I’ll be discussing this more after the initial project is setup.

The Basics

To start, I wanted to go over some basic concepts about what APIs are and how the technologies work. This is completely introductory, so feel free to skip this section if you are already familiar.

API stands for Application Programming Interface and refers to the method that computer systems use to communicate with one another. If you Google it, Google defines APIs as:

a set of functions and procedures allowing the creation of applications that access the features or data of an operating system, application, or other service.

Basically, you build out an API so that your system can communicate with whatever you’re building. API’s can include basic REST endpoints for a website, or even the methods that define a software library you’ve built. Which brings up the next important thing, RESTful Services.

RESTful services refer to  Representational State Transfer, and take advantage of the HTTP protocol to pass data (via an API). The HTTP protocol is what we use everyday in websites and internet applications. RESTful services use different HTTP verbs (or methods) to pass data between different systems. Typical HTTP verbs that you will use include the following:

  • GET = retrieving data
  • POST = creating or updating data
  • PUT = updating data
  • DELETE = deleting data

I also mentioned “endpoints” earlier, that is just what I’ll be referring to when I mention a website or service I need to hit. An endpoint is just a fancy way to describe an address that my system will be hitting with an HTTP request.

#firebase #api

How to Build an API with Firebase
3.45 GEEK