Exsssspanding Possibilities with Python 🐍

Python server code for your production Firebase apps.

Calling all Python enthusiasts! The day you’ve been waiting for has finally arrived.

Python support in Cloud Functions for Firebase has officially graduated from public preview to general availability 🎉🐍

Since the introduction of Python support at Google I/O earlier this year, we’ve been working hard on Python support to ensure it matches the capabilities and reliability of Node.js support so that you can confidently use it in your production apps.

Unlocking the Power of Python’s Ecosystem

Previously, Cloud Functions for Firebase only supported Node.js, a popular JavaScript runtime environment. While Node.js has its strengths, we know not everyone loves to write their backend code in JavaScript or TypeScript. If you’re more comfortable with Python, write in Python!

Plus, Python’s extensive collection of libraries, particularly in the domains of machine learning and data processing, is now readily available within Cloud Functions. This means you can integrate these powerful libraries into your backend solutions, making it easier than ever to build intelligent services and handle large datasets.

Numpy logo
Numpy
TensorFlow logo
TensorFlow
Pandas logo
Pandas
Flask logo
Flask
Google Cloud Vertex AI logo
Vertex AI
LangChain logo
LangChain
SciPy logo
SciPy

AI at Your Fingertips with Vertex, PaLM, and TensorFlow

Run models locally with TensorFlow, or use the convenient Python SDKs for Cloud Vertex or PaLM to integrate powerful machine learning models into your app in a way that scales. In this demo, Product Manager Chris Gill demonstrates chaining together Imagen and PaLM with Vertex AI to create an app that will generate a poem for any image:

Check out the source code for the demo on GitHub to try it yourself.

The Integration you Expect from Cloud Functions for Firebase

Just like with Node, you can trigger your functions directly via an HTTP request or callable function, or based off of background events in Firebase, like a write to Cloud Firestore, or a new upload to Cloud Storage. You can use our provided logging library to easily log structured data to Cloud Logging. Check out the use cases documentation to see what’s possible!

main.py
from firebase_functions import firestore_fn, logger

@firestore_fn.on_document_created(document="messages/{pushId}")
def makeuppercase(event):
    # Get the value of "original" from the new Firestore document.
    original = event.data.get("original")
    logger.info(f"Uppercasing {original}", doc_id=event.params["pushId"])

    # Uppercase the text and write it back to Firestore.
    upper = original.upper()
    event.data.reference.update({"uppercase": upper})
Copied!

Try it out

For all you Pythonistas out there, we hope that this update helps you supercharge your app development with Firebase.

$firebase init functions
Copied!

If you’d like to give Python a try, take a look at the getting started guide to learn how to write your own Python functions. Or, start with a prebuilt sample in the functions-samples GitHub repository.

Let us know what you think

Cloud Functions for Firebase LogoCloud Functions for Firebase Logo
Cloud Functions for Firebase

Write code that responds to events and invokes functionality exposed by other Firebase features.

https://firebase.google.com/docs/functions