Storing Data in the Cloud and APIs
Storing data in the cloud and/or using an API can be a possible way to help your app solve your particular problem. Learning about storing data in the cloud and using APIs can also help earn points in the Demo Video section of the judging rubric.
In this lesson, you will…
- Learn about cloud storage and APIs
- Create a login page
Web Databases and APIs
In the last coding lesson, you learned how to store information on a device, or how to use local storage. You also built a to-do list app that allowed users to save their to-do lists in between when they opened and closed the app. In this lesson, you’ll learn about cloud storage, or how to store information on the web so that any device connected to the internet can access it. Web Database is another term often used to describe cloud storage.
Let’s say you have two phones running an app, Phone A and Phone B. If Phone A stores data in local storage, Phone B can’t access it. If Phone A stores data in cloud storage or a web database, then Phone B can access the data.
Uses for Cloud Storage
Cloud Storage is useful for apps with information that frequently changes. Here’s an example. Let’s say you are building an app to show the 10 most popular restaurants in your city each month. You put a list of restaurants into your app and upload your app to the app store. The following month, you update the list of restaurants and update your app in the app store. Users who are already using your app will need to update or re-download your app to see the new top restaurants.
Now let’s say you stored the top 10 restaurants in cloud storage. When you update the restaurants, all of the phones using your app will check for updates to this cloud storage automatically. Users will see the changes right away, and won’t need to re-download anything.
Have you ever shared a picture on Facebook or Instagram? Apps like these use cloud storage. When your friend uploads and shares a picture, your phone checks the web database for new photos, and then you see it in your feed.
So when would you use cloud storage? Here are some common uses:
- Requiring login and passwords for users
- Sharing data from a game, like a high score list
- Allowing users to share images with each other through a feed
- Displaying a feed that all users see
- Remembering things about a user such as their transactions, financial records or medical records
It is important to know that when using cloud storage, phones need to have an internet connection to get information. If the phone has a slow internet connection, this could slow down your app or make it impossible for your app to update.
App Inventor has one main option for storing data in the cloud, CloudDB. FirebaseDB still remains as an option under the Experimental tab, and works the same as CloudDB. Thunkable has three options for storing cloud data - cloud variables, Airtable and Google Sheets. Thunkable also has a special Sign In component that uses Firebase to store emails and passwords for users of your app. You will need to set up accounts to use Airtable and Sign In. Google Sheets is accessible if you have a Gmail account.
API stands for application programming interface. An API is a way you can get information from another website or another website’s database. APIs give you access to information external to your app, whereas cloud storage gives you access to information gathered within your app.
Let’s say you are building an app to help people decide what to wear based on the weather. You could spend lots of time uploading data about the weather into a database, but there are already websites that show the weather. A better solution would be just to grab data from that website and show it to your users through your app. An API is what would allow you to do this.
Activity: Create a Login Screen Using Cloud Storage
This app allows users to create an account and log in. It uses CloudDB in App Inventor and Sign In in Thunkable. Here’s how it works:
When a new user signs up, it saves their username and password in the cloud
When a user logs in, it calls the cloud database to get their username and password
If the user successfully logs in, the app takes them to their profile page
However, this app has a major security bug! It never checks to see if the user’s password matches the one in the cloud storage before logging in. This means that any user can log in to any account. You need to fix this bug and alert the user if they have an incorrect username or password.
You need to make sure that the value returned from the cloud storage matches the password the user entered into the textbox! Ready to get started? Download the source code below.
Talk to your teammates and mentor about how you might use cloud databases or Web APIs in your app. If you want to share any information between different users of your app, you will need to use cloud databases.
If you want users to access information from different websites, then Web APIs are the way to go.
- Technovation alumna Allison John has created a two-part series on how to read and write data to a Google Spreadsheet
- Create a login app with CloudDB
- Create a chat app with CloudDB
- Follow these docs to learn how to use FirebaseDB in Thunkable: https://docs.thunkable.com/realtime-db
- Make a Login and Posting App that uses Firebase and Sign-In, Google Sheets, and Cloudinary to save and share images in the cloud.
- Make a Video Posting app where users can post and share videos.
- Build an App from a Spreadsheet
- Add the Numbers in a Spreadsheet