Published on

Bard-API: Unofficial Python package for Google Bard API


With the current AI hype, we might be a little curious to play/integrate with Google Bard. Unfortunately, they haven't released the public API yet.

However, the community has reverse-engineered the Google Bard web app and built a wrapper for their internal API in Python as a package.

Using which, we can use it in our pet projects :)

As for the authentication part, we'll be using cookie value from the Bard web app.

We'll need to get __Secure-1PSID cookie value from Bard


We need to install bardapi using pip

pip install bardapi

Playing with Google Bard Unofficial API

from bardapi import Bard

token = 'xxxxxxxxxx'
bard = Bard(token=token)
bard.get_answer("Your question here")['content']

Open In Colab

For other advanced use cases, you can refer to their docs

Happy chatting-with Bard!