{"id":32117065,"url":"https://github.com/tgsnake/fileid","last_synced_at":"2026-02-19T02:01:53.908Z","repository":{"id":38441669,"uuid":"494910466","full_name":"tgsnake/fileid","owner":"tgsnake","description":"core framework for tgsnake for generating file id","archived":false,"fork":false,"pushed_at":"2023-04-10T12:29:19.000Z","size":51785,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-27T06:53:36.686Z","etag":null,"topics":["bot-framework","fileid","telegram","telegram-bot-api"],"latest_commit_sha":null,"homepage":"https://deno.land/x/tgsnake_fileid","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/tgsnake.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":["buymeacoffee.com/butthx","saweria.co/butthx","nyawer.co/butthx"]}},"created_at":"2022-05-21T22:45:52.000Z","updated_at":"2023-08-12T11:48:52.000Z","dependencies_parsed_at":"2022-08-19T11:35:15.193Z","dependency_job_id":null,"html_url":"https://github.com/tgsnake/fileid","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/tgsnake/fileid","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgsnake%2Ffileid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgsnake%2Ffileid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgsnake%2Ffileid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgsnake%2Ffileid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tgsnake","download_url":"https://codeload.github.com/tgsnake/fileid/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgsnake%2Ffileid/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29600844,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T00:59:38.239Z","status":"online","status_checked_at":"2026-02-19T02:00:07.702Z","response_time":117,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["bot-framework","fileid","telegram","telegram-bot-api"],"created_at":"2025-10-20T16:26:44.833Z","updated_at":"2026-02-19T02:01:53.902Z","avatar_url":"https://github.com/tgsnake.png","language":"TypeScript","funding_links":["buymeacoffee.com/butthx","saweria.co/butthx","nyawer.co/butthx"],"categories":[],"sub_categories":[],"readme":"# @tgsnake/fileid\r\n\r\nCore framework for creating fileId for tgsnake.\r\n\r\n\u003e _This framework is ported or inspired from **pyrogram**, big thank for that framework._\r\n\r\nAnother framework it should be can using this framework, **not only a tgsnake**.\r\n\r\n## The advantages we offer\r\n\r\n- **Stable**  \r\n  As long as we use this, the framework works fine without any problems. If a problem is found we will fix it as soon as possible.\r\n- **Fast**  \r\n  This framework using simple algorithm to make it fast compared to other frameworks.\r\n- **Zero Dependencies**  \r\n  With zero dependencies it make this framework fast and You don't have to worry about the security of this framework.\r\n- **Typescript Support**  \r\n  This framework is build with typescript, so for typescript user no need to worry about types, because we already have it.\r\n- **Url Safe**  \r\n  We are using `base64url` than `base64` for encoding the file id, which `base64url` more safe when you using for Url. see : https://stackoverflow.com/a/55389212/16600138\r\n- **Work with another framework fileId generator**  \r\n  This framework also supported file id of :\r\n\r\n  - Telethon\r\n  - Pyrogram\r\n  - Bot Api\r\n  - tg-file-id\r\n  - Another framework should be we supported too.\r\n\r\n  \u003e We just tester for decoding file id from that framework, nvm work for re-sending the documents, but you can try. should be work too..\r\n\r\n## Installation\r\n\r\nInstalling this framework with npm\r\n\r\n```bash\r\n  cd my-project\r\n  npm install @tgsnake/fileid\r\n```\r\n\r\nInstalling this framework with yarn\r\n\r\n```bash\r\n  cd my-project\r\n  yarn add @tgsnake/fileid\r\n```\r\n\r\n## Usage/Examples\r\n\r\n```javascript\r\nconst { FileId, FileType, ThumbnailSource, FileTypeUniqueId } = require('@tgsnake/fileid');\r\nconst raw = FileId.decodeFileId(\r\n  'CAACAgUAAxkBAAICjWKI4c8Zg7eo6bSbtAV_bVcFa9DmAAJ3BgACuNvZV0cotKoi35kTHgQ'\r\n);\r\nconsole.log(fileId);\r\n```\r\n\r\n## Documentation\r\n\r\n### Options\r\n\r\nThis options is using for generating unique file id or file id. Pass this options when you create a new class from FileId.\r\n\r\n\u003c!-- prettier-ignore --\u003e\r\n| field | type | required | description |\r\n| :------: | :-----: | :----: | :-----: | \r\n| `version` | number | true | The major version of bot api file id. Usually is `4`. |\r\n| `subVersion` | number | true | The minor version of bot api file id. Usually same with tdlib version or `32`. |\r\n| `dcId` | number | true | The data center id, where that file is stored. |\r\n| `fileType` | enum/number of FileType | true | The enum/number of FileType. recommend to use enum. |\r\n| `id` | bigint | true | The id of file. |\r\n| `accessHash` | bigint | true | The hash to access that file. |\r\n| `fileReference` | Buffer | optional | File reference of that file. |\r\n| `url` | string | optional | If the file has web location, fill this with url of that web location. |\r\n| `volumeId` | bigint | optional | If the file has volume id, fill this with it. or if file doesn't have a volume id, fill this with `BigInt(0)``. This is required when you try to make file id of photo/thumbnail. |\r\n| `localId` | number | optional | If the file has local id, fill this with it. or if file doesn't have a local id, fill this with `0`. This is required when you try to make file id of photo/thumbnail. |\r\n| `secret` | bigint | optional | The secret key from file, if file doesn't have a secret key fill this with `BigInt(0)`. This is required when you try to make `ThumbnailSource.LEGACY` |\r\n| `chatId` | bigint | optional | If you want to make a file id of photo profil, fill this with BigInt of chatId. |\r\n| `chatAccessHash` | bigint | optional | If you want to make a file id of photo profil, fill this with BigInt of accessHash that chat, or `BigInt(0)` it must be work when you doesn't have a accessHash of that chat. |\r\n| `stickerSetId` | bigint | optional | The id of that sticker set. |\r\n| `stickerSetAccessHash` | bigint | optional | The accessHash of that sticker set. `BigInt(0)`` ot must be work when you doesn't have a accessHash of that sticker set. | \r\n| `thumbnailSource` | enum/number of ThumbnailSource | optional | The enum/number of ThumbnailSource. recommended to use enum. |\r\n| `thumbnailFileType` | enum/number of FileType | optional | The enum/number of FileType. recommend to use enum. |\r\n| `thumbnailSize` | string | optional | The size of that thumbnail.\u003cbr/\u003e see : https://core.telegram.org/api/files#image-thumbnail-types |\r\n| `fileTypeUniqueId` | enum/number of FileTypeUniqueId | optional | Only for generating uniqueFileId. \u003cbr/\u003e The enum/number of FileTypeUniqueId. recommended to use enum. |\r\n\r\n### Enums\r\n\r\n#### FileType\r\n\r\n```ts\r\nenum FileType {\r\n  THUMBNAIL = 0,\r\n  CHAT_PHOTO = 1, // ProfilePhoto\r\n  PHOTO = 2,\r\n  VOICE = 3, // VoiceNote\r\n  VIDEO = 4,\r\n  DOCUMENT = 5,\r\n  ENCRYPTED = 6,\r\n  TEMP = 7,\r\n  STICKER = 8,\r\n  AUDIO = 9,\r\n  ANIMATION = 10,\r\n  ENCRYPTED_THUMBNAIL = 11,\r\n  WALLPAPER = 12,\r\n  VIDEO_NOTE = 13,\r\n  SECURE_RAW = 14,\r\n  SECURE = 15,\r\n  BACKGROUND = 16,\r\n  DOCUMENT_AS_FILE = 17,\r\n}\r\n```\r\n\r\nImporting this enum :\r\n\r\n```javascript\r\nconst { FileType } = require('@tgsnake/fileid');\r\n```\r\n\r\n#### ThumbnailSource\r\n\r\n```ts\r\nenum ThumbnailSource {\r\n  LEGACY = 0,\r\n  THUMBNAIL = 1,\r\n  CHAT_PHOTO_SMALL = 2, // DialogPhotoSmall\r\n  CHAT_PHOTO_BIG = 3, // DialogPhotoBig\r\n  STICKER_SET_THUMBNAIL = 4,\r\n}\r\n```\r\n\r\nImporting this enum :\r\n\r\n```javascript\r\nconst { ThumbnailSource } = require('@tgsnake/fileid');\r\n```\r\n\r\n#### FileTypeUniqueId\r\n\r\n```ts\r\nenum FileTypeUniqueId {\r\n  WEB = 0,\r\n  PHOTO = 1,\r\n  DOCUMENT = 2,\r\n  SECURE = 3,\r\n  ENCRYPTED = 4,\r\n  TEMP = 5,\r\n}\r\n```\r\n\r\nImporting this enum :\r\n\r\n```javascript\r\nconst { FileTypeUniqueId } = require('@tgsnake/fileid');\r\n```\r\n\r\n### Generating file id.\r\n\r\nfor generating file id, you can use `.encodeFileId` method. And for decoding using `.decodeFileId`method.\r\n\r\n```javascript\r\nconst { FileId, FileType, ThumbnailSource, FileTypeUniqueId } = require(\"@tgsnake/fileid\")\r\nconst fileId = FileId.encodeFileId({\r\n  version : 4,\r\n  subVersion : 32,\r\n  fileType : FileType.STICKER,\r\n  id : ,// fill this with document id\r\n  accessHash : , // fill this with document accessHash\r\n  fileReference : , // fill this with document fileReference\r\n  dcId : // fill this with document dcId\r\n  // fill with another options.\r\n})\r\nconsole.log(fileId)\r\n```\r\n\r\n### Generating file id and uniqueFileId\r\n\r\nfor generating only unique file id, you can use `.encodeUniqueId` method. And for decoding using `decodeUniqueId` method.\r\n\r\n```javascript\r\nconst { FileId, FileType, ThumbnailSource, FileTypeUniqueId } = require(\"@tgsnake/fileid\")\r\nconst fileId = FileId.encode({\r\n  version : 4,\r\n  subVersion : 32,\r\n  fileType : FileType.STICKER,\r\n  fileTypeUniqueId : FileTypeUniqueId.DOCUMENT,\r\n  id : ,// fill this with document id\r\n  accessHash : , // fill this with document accessHash\r\n  fileReference : , // fill this with document fileReference\r\n  dcId : // fill this with document dcId\r\n  // fill with another options.\r\n})\r\nconsole.log(fileId)\r\n```\r\n\r\n## License\r\n\r\n[MIT](https://choosealicense.com/licenses/mit/)\r\n\r\n---\r\n\r\nBuild With ❤️ by tgsnake dev.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftgsnake%2Ffileid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftgsnake%2Ffileid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftgsnake%2Ffileid/lists"}