# Create Your Own Web API Service Using Firebase Functions and NodeJS!

**URL:** <https://community.thunkable.com/t/create-your-own-web-api-service-using-firebase-functions-and-nodejs/1040762>\
**Category:** Tutorials and DIY Guides\
**Tags:** firebase, community, webapi, expert, tutorial\
**Created:** [December 22, 2020, 12:39pm UTC](https://community.thunkable.com/t/create-your-own-web-api-service-using-firebase-functions-and-nodejs/1040762 "2020-12-22T12:39:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![drted](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/drted/32/92694_2.png) [@drted](https://community.thunkable.com/u/drted)\
**Post date:** [December 22, 2020, 12:39pm UTC](https://community.thunkable.com/t/create-your-own-web-api-service-using-firebase-functions-and-nodejs/1040762/1 "2020-12-22T12:39:33Z")

</div>

Thunkable does a lot of great things, processing large datasets is not one of them. I was inspired by @eddie.rebehy to try to figure out how to create my own Web API endpoint that I could use to transform large JSON trees (1,000+ nodes) quickly. I thought I would share how you can create a simple Web API using Firebase and NodeJS.

_Disclaimer: This is not a beginner topic and I don’t know the NodeJS language._

**Setup**  
it is important to note that the [Spark (ie 100% free) firebase account, as of March 2021, will no longer support functions](https://cloud.google.com/functions/docs/migrating/nodejs-runtimes). You will need to upgrade to the Blaze pay as you go account. _ **But that doesn’t cost you anything.** _ Here is why, [until you exceed the utilization of the Spark level, you won’t be charged](https://firebase.google.com/pricing?authuser=0), so unless your current utilization is bumping up against the limits, you won’t be charged. But just in case, you can add a charge alert of $1USD that will send you a message when your charges exceed $0.50USD. For me, I am willing to risk $0.50USD to gain server side processing.

You should already have a [Firebase account](https://docs.thunkable.com/realtime-db).

I followed the [Get started: write, test, and deploy your first functions](https://firebase.google.com/docs/functions/get-started) instructions. They were a little vague in places, but they were 95% of what I needed. Follow these instructions and you should be able to get both the server and development (local) environments set up.

A few additional notes on setup on Windows 10:

- I installed Visual Studie Code as my NodeJS integrated development environment (IDE). I’m very please so far.
- Although everything recommends using NVM (or the windows equivalent nvm-windows, I was able to get it set up without nvm-windows.
- The Java Developers Kit (JDK) does nothing to help you set up. After downloading the zip file, extract it somewhere, such as C:\Program Files\Java\JDK. Then go to Environment Setting and change the path to include the JDK bin directory, like C:\Program Files\Java\JDK\jdk-15.0.1\bin. Be sure the path include the “bin” directory. ( we are still paying the price for DOS).
- Installing NodeJS takes a while, get a cup of coffee.

**Calling your service from Thunkable Web API**  
The [Getting Started](https://firebase.google.com/docs/functions/get-started) article include instructions to set up your first service and it works great. That is, it works great until you try to run it in Thunkable as either a preview or Web Live Test. This is because of a Cross-Origin-Resource-Sharing (CORS) issue. @jane wrote a [great article explaining the issue](https://intercom.help/thunkable/en/articles/4515338-what-is-the-cors-policy-affecting-my-web-app). Luckily, NodeJS has a way to enable CORS. I would suggest you [watch this video](https://www.youtube.com/watch?v=qZ1EFnFOGvE&t=1077s) for an explanation. The result is that my NodeJS project looks like this:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/c/6c8223ebd0306b78e786ffb26d3b5b9013ca81c5.png)  
_Note: this function doesn’t do anything but return a message. That is all I wanted for this demonstration_

After deploying the function, you are ready to set up the Thunkable Web API call.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/a/2ac6f7dec33b633a248a10bf6d8044a8bece161e.png)

The results on the web Live Test

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/e/1ee5eec99eafc62526085fd60a4a15998618a7f2.png)

Here is a remix of the sample project

> **[Thunkable](https://x.thunkable.com/copy/33d69be35c866c0c70d7287301da0e77)**

_Testing note: if you are using the web Live Test, you can use the emulated firestore source to test your app’s interactions with the function._  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/b/8b8128288ebbe6d38bab7576602e58de7fbe438f.png)

Happy Thunking!

p.s. Thanks to all of the great Thunkers who have helped me in 2020 to get as far as I have in Thunkable. There are too many to name without my missing someone!

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [December 24, 2020, 1:05am UTC](https://community.thunkable.com/t/create-your-own-web-api-service-using-firebase-functions-and-nodejs/1040762/2 "2020-12-24T01:05:16Z")

</div>

Ted, this is dope. Do you have your api making external data calls yet?!? This is cool.

I just learned to make authenticated Firebase calls using JavaScript today (with bubble so I make a nice webapp to go with my mobile app) and could see this being useful for Firebase data filtering purposes.

---

<div class="post-metadata">

**Author:** ![luv.ak.tech](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/luv.ak.tech/32/104896_2.png) [@luv.ak.tech](https://community.thunkable.com/u/luv.ak.tech)\
**Post date:** [December 24, 2020, 4:05am UTC](https://community.thunkable.com/t/create-your-own-web-api-service-using-firebase-functions-and-nodejs/1040762/3 "2020-12-24T04:05:13Z")

</div>

this is amazing well how did you made the url can you tell me

---

<div class="post-metadata">

**Author:** ![drted](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/drted/32/92694_2.png) [@drted](https://community.thunkable.com/u/drted)\
**Post date:** [December 24, 2020, 10:20am UTC](https://community.thunkable.com/t/create-your-own-web-api-service-using-firebase-functions-and-nodejs/1040762/4 "2020-12-24T10:20:48Z")

</div>

> **[Get started: write, test, and deploy your first functions  |  Firebase](https://firebase.google.com/docs/functions/get-started)**

---

<div class="post-metadata">

**Author:** ![luv.ak.tech](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/luv.ak.tech/32/104896_2.png) [@luv.ak.tech](https://community.thunkable.com/u/luv.ak.tech)\
**Post date:** [April 14, 2021, 5:38am UTC](https://community.thunkable.com/t/create-your-own-web-api-service-using-firebase-functions-and-nodejs/1040762/5 "2021-04-14T05:38:52Z")

</div>

great work i made my own api by watching this tutorial -

[![](https://img.youtube.com/vi/pKd0Rpw7O48/maxresdefault.jpg "How to build a REST API with Node js & Express") ](https://www.youtube.com/watch?v=pKd0Rpw7O48)

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 12:19pm UTC](https://community.thunkable.com/t/create-your-own-web-api-service-using-firebase-functions-and-nodejs/1040762/6 "2024-11-08T12:19:29Z")

</div>


