Quick Start
Create a Bot
- Find BotFather in the SafeW app
- Send the
/newbotcommand - Follow the prompts to set the bot name and username
- Obtain your Bot Token
Get Your Token
After successful creation, BotFather will return a Token. Keep this Token safe — it is the sole credential for calling the API.
Security Notice
Never expose your Token publicly or commit it to version control. If the Token is compromised, regenerate it immediately via BotFather.
Send Your First Message
Use the sendMessage method to send a text message:
bash
curl -X POST "https://api.example.com/bot{YOUR_TOKEN}/sendmessage" \
-H "Content-Type: application/json" \
-d '{
"chat_id": 123456789,
"text": "Hello, World!"
}'Success response:
json
{
"ok": true,
"result": {
"message_id": 1,
"chat": {
"id": 123456789,
"type": "private"
},
"text": "Hello, World!"
}
}Receive Messages
There are two ways to receive message updates:
Long Polling (getUpdates)
bash
curl "https://api.example.com/bot{YOUR_TOKEN}/getupdates"Webhook
After setting a Webhook URL, the server will push updates to your specified URL:
bash
curl -X POST "https://api.example.com/bot{YOUR_TOKEN}/setwebhook" \
-H "Content-Type: application/json" \
-d '{
"url": "https://your-server.com/webhook"
}'Next Steps
- Learn the full specification for Making Requests
- Read the detailed Authentication guide
- Browse the complete Bot API method list
