{"id":13904290,"url":"https://github.com/gram-js/gramjs","last_synced_at":"2025-05-12T13:18:41.023Z","repository":{"id":37445041,"uuid":"201809645","full_name":"gram-js/gramjs","owner":"gram-js","description":"NodeJS/Browser MTProto API Telegram client library,","archived":false,"fork":false,"pushed_at":"2024-12-26T18:00:21.000Z","size":3863,"stargazers_count":1482,"open_issues_count":294,"forks_count":191,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-05-12T13:18:15.701Z","etag":null,"topics":["api-client","browser","hacktoberfest","javascript","mtproto","nodejs","telegram","telegram-client"],"latest_commit_sha":null,"homepage":"","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/gram-js.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":"2019-08-11T20:02:45.000Z","updated_at":"2025-05-11T22:32:34.000Z","dependencies_parsed_at":"2023-10-02T12:09:25.181Z","dependency_job_id":"24a69753-bc0f-4f4f-bb89-aa947cd27ea8","html_url":"https://github.com/gram-js/gramjs","commit_stats":{"total_commits":509,"total_committers":58,"mean_commits":8.775862068965518,"dds":0.4636542239685658,"last_synced_commit":"c6eca75735135d2dd9c8ce7f91a14dae088b66b2"},"previous_names":[],"tags_count":151,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gram-js%2Fgramjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gram-js%2Fgramjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gram-js%2Fgramjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gram-js%2Fgramjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gram-js","download_url":"https://codeload.github.com/gram-js/gramjs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253745196,"owners_count":21957319,"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-client","browser","hacktoberfest","javascript","mtproto","nodejs","telegram","telegram-client"],"created_at":"2024-08-06T23:00:52.457Z","updated_at":"2025-05-12T13:18:40.948Z","avatar_url":"https://github.com/gram-js.png","language":"TypeScript","readme":"# GramJS\n\nA Telegram client written in JavaScript for Node.js and browsers, with its core being based on\n[Telethon](https://github.com/LonamiWebs/Telethon).\n\n## How to get started\n\nHere you'll learn how to obtain necessary information to create telegram application, authorize into your account and send yourself a message.\n\n\u003e **Note** that if you want to use a GramJS inside of a browser, refer to [this instructions](https://gram.js.org/introduction/advanced-installation).\n\nInstall GramJS:\n\n```bash\n$ npm i telegram\n```\n\nAfter installation, you'll need to obtain an API ID and hash:\n\n1. Login into your [telegram account](https://my.telegram.org/)\n2. Then click \"API development tools\" and fill your application details (only app title and short name required)\n3. Finally, click \"Create application\"\n\n\u003e **Never** share any API/authorization details, that will compromise your application and account.\n\nWhen you've successfully created the application, change `apiId` and `apiHash` on what you got from telegram.\n\nThen run this code to send a message to yourself.\n\n```javascript\nimport { TelegramClient } from \"telegram\";\nimport { StringSession } from \"telegram/sessions\";\nimport readline from \"readline\";\n\nconst apiId = 123456;\nconst apiHash = \"123456abcdfg\";\nconst stringSession = new StringSession(\"\"); // fill this later with the value from session.save()\n\nconst rl = readline.createInterface({\n  input: process.stdin,\n  output: process.stdout,\n});\n\n(async () =\u003e {\n  console.log(\"Loading interactive example...\");\n  const client = new TelegramClient(stringSession, apiId, apiHash, {\n    connectionRetries: 5,\n  });\n  await client.start({\n    phoneNumber: async () =\u003e\n      new Promise((resolve) =\u003e\n        rl.question(\"Please enter your number: \", resolve)\n      ),\n    password: async () =\u003e\n      new Promise((resolve) =\u003e\n        rl.question(\"Please enter your password: \", resolve)\n      ),\n    phoneCode: async () =\u003e\n      new Promise((resolve) =\u003e\n        rl.question(\"Please enter the code you received: \", resolve)\n      ),\n    onError: (err) =\u003e console.log(err),\n  });\n  console.log(\"You should now be connected.\");\n  console.log(client.session.save()); // Save this string to avoid logging in again\n  await client.sendMessage(\"me\", { message: \"Hello!\" });\n})();\n```\n\n\u003e **Note** that you can also save auth key to a folder instead of a string, change `stringSession` into this:\n\u003e\n\u003e ```javascript\n\u003e const storeSession = new StoreSession(\"folder_name\");\n\u003e ```\n\nBe sure to save output of `client.session.save()` into `stringSession` or `storeSession` variable to avoid logging in again.\n\n## Running GramJS inside browsers\n\nGramJS works great in combination with frontend libraries such as React, Vue and others.\n\nWhile working within browsers, GramJS is using `localStorage` to cache the layers.\n\nTo get a browser bundle of GramJS, use the following command:\n\n```bash\nNODE_ENV=production npx webpack\n```\n\nYou can also use the helpful script `generate_webpack.js`\n\n```bash\nnode generate_webpack.js\n```\n\n## Calling the raw API\n\nTo use raw telegram API methods use [invoke function](https://gram.js.org/beta/classes/TelegramClient.html#invoke).\n\n```javascript\nawait client.invoke(new RequestClass(args));\n```\n\n## Documentation\n\nGeneral documentation, use cases, quick start, refer to [gram.js.org](https://gram.js.org), or [older version of documentation](https://painor.gitbook.io/gramjs) (will be removed in the future).\n\nFor more advanced documentation refer to [gram.js.org/beta](https://gram.js.org/beta) (work in progress).\n\nIf your ISP is blocking Telegram, you can check [My ISP blocks Telegram. How can I still use GramJS?](https://gist.github.com/SecurityAndStuff/7cd04b28216c49b73b30a64d56d630ab)\n\n## Ask a question\n\nIf you have any questions about GramJS, feel free to open an issue or ask directly in our telegram group - [@GramJSChat](https://t.me/gramjschat).\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgram-js%2Fgramjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgram-js%2Fgramjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgram-js%2Fgramjs/lists"}