Good Morning Everyone!
Today we will be starting a look at integrating another wonderful web API called Firebase! Firebase Website
Signing up with Firebase is completely free and the limitations on your data is actually quite nice of them to allow. So go sign up and make your own Firebase app on the site and take note of your firebase URL it gives you.
Firebase uses a Restful API which means we can communicate to it’s data through URL calls. Unfortunately, with how Insert From URL works we can only REQUEST data from Firebase with that script step since POSTing data requires a JSON body sent with the URL to Firebase. But do not fear, BaseElements is here to save us from frustration at Insert From URL. The wonderful FREE BaseElements plugin allows us to do the specific data sending to Firebase to allow us to also Insert, Update, Delete, etc to the Firebase data!
Link to BaseElements Plugin (Thank you Goya, you rock!)
Before you get started, make sure you visit the Firebase site and sign up for a free account so you can set up your own app and test with your own info as you go along. Also make sure you download the example FileMaker file HERE.
First: You will want to open up the example FileMaker file I linked above. It should contain the BaseElements plugin in the file if you haven’t installed it yet. The first layout should just be a main layout that you can navigate to the different examples and also contains some links to certain web pages that can be helpful to following along.
Second: We have the GET page. It should contain buttons that will request data from one of my Firebase apps called Rumchata. It should contain a few recipes that contain Rumchata. I also included one that just uses Insert From URL and the other will use the BaseElements plugin to request the data. At this point they are almost identical and the plugin really isn’t required. There is also a Custom set of buttons that will allow you to enter your own Firebase app URL to attempt requesting data from your own Firebase.
Third: We have the PUT page. It contains similar options like the GET page but all of these will require using the BaseElements plugin. We first have the buttons that allow you to enter some recipe data and then we send the data to Firebase with a PUT.
Then we also have the custom option where you can enter your Firebase URL and a key/value pair that you will PUT to your own Firebase app.
These both use new script steps that are setting a JSON variable. So to do a PUT request (and POST), we use the base URL to the node you are adding data and the JSON variable you set with the key/value pair you set up.
Fourth: We have the POST page. It contains options much like the PUT page, actually the PUT and POST options are very similar. The main difference is when you use a POST to Firebase, it generates a unique key as the parent of the data you send. So say you use the URL: https://rumchata.firebaseio.com/users_post.json with a key: “username”, and value of “Nick”. In Firebase, the path to that user you added would be something like: https://rumchata.firebaseio.com/users_post/-INOQPH-aV_psbk3ZXEX/username
This is useful for easily adding unique values into Firebase which then you can recall later.
So, look over the scripts, mess with any of it and try and get a feel for sending and receiving data through Firebase! Look through the API documentation a little and find some other functions you can incorporate with Filemaker.
Part 2 of the series will be parsing the data in Filemaker, updating information in Firebase and the start of using a WebViewer so we can create our own Chat client in Filemaker!
Please leave any comments, questions or suggestions on this or anything else you would like to go over! Follow me on twitter (@pudgyplatypus) to get any updates on Filemaker stuff or any of the silly games I make. Also check out MC Services’ website if you are in the market for Filemaker development or Mac consulting!