Tip
As of now, Grm is not regularly updated. MTKruto is recommended as an alternative for Deno users.
MTProto client for Deno ported from GramJS.
Currently, there is no documentation dedicated to Grm. You can use the GramJS documentation and API reference.
Here you'll learn how to obtain necessary information to initialize the client, authorize your personal account and send yourself a message.
First, you'll need to obtain an API ID and hash:
- Visit my.telegram.org and sign in.
- Click "API development tools" and fill your application details (only the app title and the short name are required).
- Click "Create application".
Don't leak your API credentials. They can't be revoked.
Then use your API credentials with the following example code:
import { StringSession, TelegramClient } from "https://deno.land/x/grm/mod.ts";
const apiId = 123456;
const apiHash = "abcd1234";
// Fill in this later with the value from `client.session.save()`,
// so that you don't have to login every time.
const stringSession = new StringSession("");
console.log("Loading interactive example...");
const client = new TelegramClient(stringSession, apiId, apiHash);
await client.start({
phoneNumber: () => prompt("Phone number:")!,
password: () => prompt("Password:")!,
phoneCode: () => prompt("Verification code:")!,
onError: console.error,
});
console.log("Connected.");
console.log(client.session.save());
// Send yourself a message.
await client.sendMessage("me", { message: "Hello, world!" });
You'll be prompted to enter your phone number (in international format), the code you received from Telegram, and your 2FA password if you have one set.
You can then save output of client.session.save()
and use it in new StringSession("here")
to not login again each time.
After connecting successfully, you should have a text message saying "Hello, world!" in your Saved Messages.
Check out examples/ for more examples.
Here are some awesome projects powered by Grm:
Add yours to this list by opening a pull request.
Feel free to open pull requests related to improvements and fixes to the core library and documentation. We are currently following API changes in the original GramJS repository applying them here.
We'd appreciate if you could help with migrating from Node.js modules such as socks and websocket to Deno APIs.
This port wouldn't exist without these wonderful people. Thanks to
- the original authors and contributors of GramJS,
- authors of the dependencies,
- authors of the already ported dependencies,
- contributors of this repository,
- and everyone else who were a part of this.
This is a direct port of GramJS for Deno. This was just an attempt, which turned out to be a successful one. Most of the commonly used features are working as expected.
It took me like 4 days; a total of 20h6m for this repository alone. Including dependency porting and reading the original code, it is a total of almost 34.8h for the first release. I didn't just copy and paste stuff — I did, but I manually wrote lot of the files. It made me realize how much effort have been put into the development of GramJS. You should definitely give it a star if you're using this library.
I had to port the following Node.js modules to Deno:
- JoshGlazebrook/socks — deno_socks
- indutny/node-ip — deno_ip
- JoshGlazebrook/smart-buffer — deno_smart_buffer
- spalt08/cryptography — deno_cryptography
I know that some of them should not have been ported, but I didn't realized that then.