pyrogram/docs/source/intro/quickstart.rst

57 lines
1.5 KiB
ReStructuredText
Raw Normal View History

2019-05-10 14:14:10 +00:00
Quick Start
===========
2022-01-07 09:18:51 +00:00
The next few steps serve as a quick start to see Pyrogram in action as fast as possible.
2019-05-10 14:14:10 +00:00
Get Pyrogram Real Fast
----------------------
2022-01-07 09:18:51 +00:00
.. admonition :: Cloud Credits
:class: tip
If you need a cloud server to host your applications, try Hetzner Cloud. You can sign up with
`this link <https://hetzner.cloud/?ref=9CyT92gZEINU>`_ to get €20 in cloud credits.
2019-05-10 14:14:10 +00:00
1. Install Pyrogram with ``pip3 install -U pyrogram``.
2. Get your own Telegram API key from https://my.telegram.org/apps.
2022-01-07 09:18:51 +00:00
3. Open the text editor of your choice and paste the following:
2019-05-10 14:14:10 +00:00
.. code-block:: python
2022-01-07 09:18:51 +00:00
import asyncio
2019-05-10 14:14:10 +00:00
from pyrogram import Client
api_id = 12345
api_hash = "0123456789abcdef0123456789abcdef"
2022-01-07 09:18:51 +00:00
async def main():
async with Client("my_account", api_id, api_hash) as app:
await app.send_message("me", "Greetings from **Pyrogram**!")
2022-01-07 09:18:51 +00:00
asyncio.run(main())
2019-05-10 14:14:10 +00:00
4. Replace *api_id* and *api_hash* values with your own.
2022-01-07 09:18:51 +00:00
5. Save the file as ``hello.py``.
2019-05-10 14:14:10 +00:00
2022-01-07 09:18:51 +00:00
6. Run the script with ``python3 hello.py``
2019-05-10 14:14:10 +00:00
7. Follow the instructions on your terminal to login.
8. Watch Pyrogram send a message to yourself.
Enjoy the API
-------------
2022-01-07 09:18:51 +00:00
That was just a quick overview. In the next few pages of the introduction, we'll take a much more in-depth look of what
we have just done above.
2019-05-10 14:14:10 +00:00
2022-04-24 09:56:07 +00:00
If you are feeling eager to continue you can take a shortcut to :doc:`../start/invoking` and come back
2022-01-07 09:18:51 +00:00
later to learn some more details.
2019-05-12 17:26:55 +00:00
2019-06-22 23:30:50 +00:00
.. _community: https://t.me/Pyrogram