TG Push

@TeGePushBot

Микросервис для отправки уведомлений в Telegram.

Регистрируйтесь в боте, создавайте группы и отправляйте уведомления через простой API.

📋 Документация

POST https://tg-push.koyu.tech/send-notification/{api_key}

Request Body

Parameter Type Required Description
sender_id integer Yes Telegram user ID отправителя
text string Yes Текст сообщения для отправки
group string Yes Целевая группа: "all", "myself" или название группы

Response Format

{
  "success": true,
  "sent_to": 5,
  "errors": [
    {
      "user_id": 987654321,
      "error": "Forbidden: bot was blocked by the user"
    }
  ]
}

💻 Примеры кода

curl (Terminal)

$ curl -X POST https://tg-push.koyu.tech/send-notification/abc123xyz \
  -H "Content-Type: application/json" \
  -d '{
    "sender_id": 123456789,
    "text": "Hello, this is a test notification!",
    "group": "myself"
  }'

JavaScript (Fetch API)

const apiKey = 'abc123xyz';
const senderId = 123456789;

fetch(`https://tg-push.koyu.tech/send-notification/${apiKey}`, {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    sender_id: senderId,
    text: 'Hello, this is a test notification!',
    group: 'myself',
  }),
})
  .then(response => response.json())
  .then(data => console.log('Response:', data))
  .catch(error => console.error('Error:', error));

PHP (cURL)

<?php
$apiKey = 'abc123xyz';
$senderId = 123456789;

$url = "https://tg-push.koyu.tech/send-notification/{$apiKey}";

$data = [
    'sender_id' => $senderId,
    'text' => 'Hello, this is a test notification!',
    'group' => 'myself',
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json',
]);

$response = curl_exec($ch);
curl_close($ch);

echo $response;

Python (requests)

import requests
import json

api_key = 'abc123xyz'
sender_id = 123456789

url = f'https://tg-push.koyu.tech/send-notification/{api_key}'

data = {
    'sender_id': sender_id,
    'text': 'Hello, this is a test notification!',
    'group': 'myself'
}

response = requests.post(url, json=data)
print(response.json())

Ruby (Net::HTTP)

require 'net/http'
require 'uri'
require 'json'

api_key = 'abc123xyz'
sender_id = 123456789

uri = URI("https://tg-push.koyu.tech/send-notification/#{api_key}")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Post.new(uri.path)
request['Content-Type'] = 'application/json'
request.body = JSON.dump({
  sender_id: sender_id,
  text: 'Hello, this is a test notification!',
  group: 'myself'
})

response = http.request(request)
puts response.body

Java (HttpClient)

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpClient.Version;
import java.util.concurrent.TimeUnit;

public class ApiExample {
    public static void main(String[] args) throws Exception {
        String apiKey = "abc123xyz";
        int senderId = 123456789;

        String url = "https://tg-push.koyu.tech/send-notification/" + apiKey;
        String json = String.format(
            "{\"sender_id\": %d, \"text\": \"Hello, this is a test notification!\", \"group\": \"myself\"}",
            senderId
        );

        HttpClient client = HttpClient.newBuilder()
            .version(Version.HTTP_2)
            .build();

        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create(url))
            .POST(HttpRequest.BodyPublishers.ofString(json))
            .header("Content-Type", "application/json")
            .build();

        HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.statusCode());
        System.out.println(response.body());
    }
}

Go (net/http)

package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "net/http"
)

func main() {
    apiKey := "abc123xyz"
    senderId := 123456789

    url := fmt.Sprintf("https://tg-push.koyu.tech/send-notification/%s", apiKey)

    data := map[string]interface{}{
        "sender_id": senderId,
        "text":      "Hello, this is a test notification!",
        "group":     "myself",
    }

    jsonData, _ := json.Marshal(data)

    req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    fmt.Println("Status:", resp.Status)
}