{"id":26655649,"url":"https://github.com/gramiojs/types","last_synced_at":"2026-02-08T15:05:06.979Z","repository":{"id":219925012,"uuid":"739437287","full_name":"gramiojs/types","owner":"gramiojs","description":"Code-generated and Auto-published Telegram Bot API types","archived":false,"fork":false,"pushed_at":"2025-02-13T12:35:56.000Z","size":285,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-30T21:31:06.000Z","etag":null,"topics":["api","auto-published","bot","cicd","code-generated","telegram","telegram-bot-api","types"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@gramio/types","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gramiojs.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":"2024-01-05T15:07:13.000Z","updated_at":"2025-03-30T18:42:55.000Z","dependencies_parsed_at":"2024-03-31T19:22:34.063Z","dependency_job_id":"3553461a-1091-40e9-a3b5-87a0928a4679","html_url":"https://github.com/gramiojs/types","commit_stats":null,"previous_names":["gramiojs/types"],"tags_count":46,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gramiojs%2Ftypes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gramiojs%2Ftypes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gramiojs%2Ftypes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gramiojs%2Ftypes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gramiojs","download_url":"https://codeload.github.com/gramiojs/types/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248368766,"owners_count":21092452,"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":["api","auto-published","bot","cicd","code-generated","telegram","telegram-bot-api","types"],"created_at":"2025-03-25T06:36:50.493Z","updated_at":"2026-02-08T15:05:06.943Z","avatar_url":"https://github.com/gramiojs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Code-generated and Auto-published Telegram Bot API types\n\n\u003cdiv align=\"center\"\u003e\n\n[![Bot API](https://img.shields.io/badge/Bot%20API-8.1+-blue?logo=telegram\u0026style=flat\u0026labelColor=000\u0026color=3b82f6)](https://core.telegram.org/bots/api)\n[![npm](https://img.shields.io/npm/v/@gramio/types?logo=npm\u0026style=flat\u0026labelColor=000\u0026color=3b82f6)](https://www.npmjs.org/package/@gramio/types)\n[![npm downloads](https://img.shields.io/npm/dw/@gramio/types?logo=npm\u0026style=flat\u0026labelColor=000\u0026color=3b82f6)](https://www.npmjs.org/package/@gramio/types)\n[![JSR](https://jsr.io/badges/@gramio/types)](https://jsr.io/@gramio/types)\n[![JSR Score](https://jsr.io/badges/@gramio/types/score)](https://jsr.io/@gramio/types)\n\n\u003c/div\u003e\n\n### Versioning\n\n8.1.x types are for 8.1 Telegram Bot API\n\n## Usage as an [NPM package](https://www.npmjs.com/package/@gramio/types)\n\n```ts\nimport type { APIMethods, APIMethodReturn } from \"@gramio/types\";\n\ntype SendMessageReturn = Awaited\u003cReturnType\u003cAPIMethods[\"sendMessage\"]\u003e\u003e;\n//   ^? type SendMessageReturn = TelegramMessage\n\ntype GetMeReturn = APIMethodReturn\u003c\"getMe\"\u003e;\n//   ^? type GetMeReturn = TelegramUser\n```\n\nPlease see [API Types References](https://tsdocs.dev/docs/@gramio/types)\n\n### Auto-update package\n\nThis library is updated automatically to the latest version of the Telegram Bot API in case of changes thanks to CI CD!\nIf the github action failed, there are no changes in the Bot API\n\n## Imports (after `@gramio/`)\n\n-   `index` - exports everything in the section\n-   `methods` - exports `APIMethods` which describes the api functions\n-   `objects` - exports objects with the `Telegram` prefix (for example [Update](https://core.telegram.org/bots/api/#update))\n-   `params` - exports params that are used in `methods` with `Params` postfix\n\n### Write you own type-safe Telegram Bot API wrapper\n\n```typescript\nimport type {\n    APIMethods,\n    APIMethodParams,\n    TelegramAPIResponse,\n} from \"@gramio/types\";\n\nconst TBA_BASE_URL = \"https://api.telegram.org/bot\";\nconst TOKEN = \"\";\n\nconst api = new Proxy({} as APIMethods, {\n    get:\n        \u003cT extends keyof APIMethods\u003e(_target: APIMethods, method: T) =\u003e\n        async (params: APIMethodParams\u003cT\u003e) =\u003e {\n            const response = await fetch(`${TBA_BASE_URL}${TOKEN}/${method}`, {\n                method: \"POST\",\n                headers: {\n                    \"Content-Type\": \"application/json\",\n                },\n                body: JSON.stringify(params),\n            });\n\n            const data = (await response.json()) as TelegramAPIResponse;\n            if (!data.ok) throw new Error(`Some error occurred in ${method}`);\n\n            return data.result;\n        },\n});\n\napi.sendMessage({\n    chat_id: 1,\n    text: \"message\",\n});\n```\n\n#### Usage with [`@gramio/keyboards`](https://github.com/gramiojs/keyboards)\n\n```typescript\nimport { Keyboard } from \"@gramio/keyboards\";\n\n// the code from the example above\n\napi.sendMessage({\n    chat_id: 1,\n    text: \"message with keyboard\",\n    reply_markup: new Keyboard().text(\"button text\"),\n});\n```\n\n#### With File uploading support\n\n[Documentation](https://gramio.dev/files/usage-without-gramio.html#write-you-own-type-safe-tba-api-wrapper-with-file-uploading-support)\n\n## Generate types manually\n\nPrerequire - [`rust`](https://www.rust-lang.org/)\n\n1. Clone [this repo](https://github.com/gramiojs/types) and open it\n\n```bash\ngit clone https://github.com/gramiojs/types.git\n```\n\n2. Clone [repo](https://github.com/ark0f/tg-bot-api) with Telegram Bot API schema generator\n\n```bash\ngit clone https://github.com/ark0f/tg-bot-api.git\n```\n\n3. Run the JSON schema generator in the `cloned` folder\n\n```bash\ncd tg-bot-api \u0026\u0026 cargo run --package gh-pages-generator --bin gh-pages-generator -- dev \u0026\u0026 cd ..\n```\n\n4. Run types code-generation from the `root` of the project\n\n```bash\nbun generate\n```\n\nor, if you don't use `bun`, use `tsx`\n\n```bash\nnpx tsx src/index.ts\n```\n\n5. Profit! Check out the types of Telegram Bot API in `out` folder!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgramiojs%2Ftypes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgramiojs%2Ftypes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgramiojs%2Ftypes/lists"}