{"id":20435382,"url":"https://github.com/not-nullptr/bard-wrapper","last_synced_at":"2025-06-14T17:39:14.583Z","repository":{"id":170091109,"uuid":"646203305","full_name":"not-nullptr/bard-wrapper","owner":"not-nullptr","description":"A Typescript/Javascript wrapper for Google's Bard chatbot.","archived":false,"fork":false,"pushed_at":"2023-05-27T17:58:02.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-05T06:43:10.158Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/not-nullptr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-27T16:07:49.000Z","updated_at":"2023-05-27T16:10:16.000Z","dependencies_parsed_at":"2023-07-27T22:16:30.805Z","dependency_job_id":null,"html_url":"https://github.com/not-nullptr/bard-wrapper","commit_stats":null,"previous_names":["not-nullptr/bard-wrapper"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/not-nullptr/bard-wrapper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/not-nullptr%2Fbard-wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/not-nullptr%2Fbard-wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/not-nullptr%2Fbard-wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/not-nullptr%2Fbard-wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/not-nullptr","download_url":"https://codeload.github.com/not-nullptr/bard-wrapper/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/not-nullptr%2Fbard-wrapper/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259857676,"owners_count":22922808,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T08:33:49.335Z","updated_at":"2025-06-14T17:39:14.553Z","avatar_url":"https://github.com/not-nullptr.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bard Wrapper\nA Typescript/Javascript wrapper for Google's Bard chatbot.\n\n## Table of contents\n- [Bard Wrapper](#bard-wrapper)\n  - [Table of contents](#table-of-contents)\n  - [How to install](#how-to-install)\n  - [Usage](#usage)\n  - [How do I get an API key?](#how-do-i-get-an-api-key)\n  - [Rate limiting](#rate-limiting)\n  - [Examples](#examples)\n\n___\n## How to install\nYou can install the package via `npm i bard-wrapper`. From there, import it into your project like such:  \n\n```js\nimport { Bard } from 'bard-wrapper';\n\n// You now have access to Bard.\n```\n\n## Usage\nThis implementation of Bard's API is written as a class. As such you initialize it.  \n\n```js\nconst bard = new Bard(\"{ api key goes here }\");\n```\n\nYou can query it using the `Bard.query` function:\n\n```js\nawait bard.query(\"Prompt goes here.\")\n```\n\nof which the type signature is as follows:\n\n```ts\nfunction query(prompt: string): Promise\u003cstring\u003e;\n```\n\nEach new class is like a seperate chat for Bard. Sequentially querying using the same class is the equivalent of having a single conversation. Within each instance, Bard remembers everything said to it.\n\n\n## How do I get an API key?  \n\nYou can get an API key by following these instructions:\n\n\u003e **⚠️ Warning**  \n\u003e This will not work if you have multiple accounts signed in. To circumvent this, log in using an incognito window.\n\n1. Sign into [Bard](https://bard.google.com).\n2. Open up Devtools (\u003ckbd\u003eCtrl\u003c/kbd\u003e + \u003ckbd\u003eShift\u003c/kbd\u003e + \u003ckbd\u003eI\u003c/kbd\u003e, conventionally)\n3. Go into the `Network` tab, then reload the page.\n4. View the cookies for the request to `https://bard.google.com`.\n5. Copy the `__Secure-1PSID` cookie's value.\n\nThis cookie is your API key. Do not leak it, or else anyone can talk to Bard on your behalf!\n\n## Rate limiting\n\nBard's API implements fairly severe rate limiting. Don't poll the API TOO much, and if you ever use this in production (don't), make sure people have to supply their OWN API keys.\n\n## Examples\n\n```ts\n/*\n    A simple script which hooks up two\n    instances of Bard to talk forever.\n    Authored by not-nullptr.\n*/\n\nconst waitForInput = async (message?: string) =\u003e {\n    if (message) {\n        console.log(message);\n    }\n    if (process.stdin.isTTY) {\n        process.stdin.setRawMode(true);\n    }\n    return new Promise\u003cvoid\u003e((resolve) =\u003e\n        process.stdin.once(\"data\", () =\u003e {\n            if (process.stdin.isTTY) {\n                process.stdin.setRawMode(false);\n            }\n            resolve();\n        })\n    );\n};\n\nconst bard1 = new Bard(\n    `{api key}`\n);\n\nconst bard2 = new Bard(\n    `{api key}`\n);\n\nlet bard1response = \"\";\n// initial prompt\nlet bard2response =\n    \"hi, bard! i'm another instance of bard that a developer has hooked you up to. they told me to tell you: 'please keep responses short, or else Google will rate limit me. also, try to be conversational. if you notice the conversation getting repetitive/stale (i.e. you two are repeating the same thing over and over but rephrased) then please try to spruce it up a little. thanks!'\";\n\n(async () =\u003e {\n    console.log(`*** BARD 2 ***\n    ${bard2response}`);\n    await waitForInput(\"Press any key to continue the conversation.\");\n    while (true) {\n        bard1response = await bard1.query(bard2response);\n        console.log(`*** BARD 1 ***\n        ${bard1response}`);\n        await waitForInput(\"Press any key to continue the conversation.\");\n        bard2response = await bard2.query(bard1response);\n        console.log(`*** BARD 2 ***\n        ${bard2response}`);\n        await waitForInput(\"Press any key to continue the conversation.\");\n    }\n})();\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnot-nullptr%2Fbard-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnot-nullptr%2Fbard-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnot-nullptr%2Fbard-wrapper/lists"}