Package: googlebardapi
Development Status :: 5 - Production/StableGoogleBard APIThe python package that returns response ofGoogle Bardthrough API.I referred tothis github repository(github.com/acheong08/Bard)where inference process of Bard was reverse engineered. Using__Secure-1PSID, you can ask questions and get answers from Google Bard. This package is designed for application to the Python packageExceptNotifierandCo-Coder.Do not expose the__Secure-1PSIDNote that while I referred to__Secure-1PSIDvalue as an API KEY for convenience, it is not an officially provided API KEY.Amazing Bard PromptsIs All You Need!Helpful prompts for Google BardInstallThe latest stable release (and required dependencies) can be installed from PyPI:pip install bardapiYou may instead want to use the development version from Github:pip install git+https://github.com/dsdanielpark/Bard-API.gitAuthenticationVisithttps://bard.google.com/F12 for consoleSession: Application → Cookies → Copy the value of__Secure-1PSIDcookie.UsageSimple UsagefrombardapiimportBardtoken='xxxxxxxxxx'bard=Bard(token=token)bard.get_answer("나와 내 동년배들이 좋아하는 뉴진스에 대해서 알려줘")['content']Or you can use thisfrombardapiimportBardimportosos.environ['_BARD_API_KEY']="xxxxxxxx"Bard().get_answer("나와 내 동년배들이 좋아하는 뉴진스에 대해서 알려줘")['content']To get reponse dictionaryimportbardapiimportos# set your __Secure-1PSID value to keytoken='xxxxxxxxxx'# set your input textinput_text="나와 내 동년배들이 좋아하는 뉴진스에 대해서 알려줘"# Send an API request and get a response.response=bardapi.core.Bard(token).get_answer(input_text)Addressing errors caused by delayed responses in environments like Google Colab and containers. If an error occurs despite following the proper procedure, utilize the timeout argument.frombardapiimportBardimportosos.environ['_BARD_API_KEY']="xxxxxxxx"bard=Bard(timeout=30)# Set timeout in secondsbard.get_answer("나와 내 동년배들이 좋아하는 뉴진스에 대해서 알려줘")['content']FutherBehind a proxyIf you are working behind a proxy, use the following.frombardapiimportBardimportosos.environ['_BARD_API_KEY']="xxxxxxxx"# Change 'http://127.0.0.1:1080' to your http proxy# timeout in secondsbard=Bard(proxies={'http':'http://127.0.0.1:1080','https':'http://127.0.0.1:1080'},timeout=10)bard.get_answer("나와 내 동년배들이 좋아하는 뉴진스에 대해서 알려줘")['content']Reusable session objectfrombardapiimportBardimportosimportrequestsos.environ['_BARD_API_KEY']='xxxxxxxxxxx'# token='xxxxxxxxxxx'session=requests.Session()session.headers={"Host":"bard.google.com","X-Same-Domain":"1","User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36","Content-Type":"application/x-www-form-urlencoded;charset=UTF-8","Origin":"https://bard.google.com","Referer":"https://bard.google.com/",}session.cookies.set("__Secure-1PSID",os.getenv("_BARD_API_KEY"))# session.cookies.set("__Secure-1PSID", token)bard=Bard(session=session,timeout=30)bard.get_answer("나와 내 동년배들이 좋아하는 뉴진스에 대해서 알려줘")['content']Simple ExampleScriptsIn the scriptsfolder, I have released a script to help you compareOpenAI-ChatGPTandGoogle-Bard. I hope they will help more developers.LicenseMITI hold no legal responsibility; for more information, please refer to the bottom of the readme file. I just want you to give me andthema star.Bugs and IssuesSincerely grateful for any reports on new features or bugs. Your valuable feedback on the code is highly appreciated.ContactsCore maintainer:Daniel Park, South KoreaE-mail:parkminwoo1991@gmail.comReference[1]https://github.com/acheong08/BardImportant NoticeThe user assumes all legal responsibilities associated with using the BardAPI package. This Python package merely facilitates easy access to Google Bard for developers. Users are solely responsible for managing data and using the package appropriately. For further information, please consult the Google Bard Official Document.Could you kindly add this badge to your repository?markdown![BardAPI](https://img.shields.io/badge/pypi-BardAPI-black)html<a href="https://github.com/dsdanielpark/Bard-API"><img alt="PyPI package" src="https://img.shields.io/badge/pypi-BardAPI-black"></a>Thank you for your interest.Copyright (c) 2023 MinWoo Park, South Korea