Skip to content

TeaByte/telegram-upload-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Telegram Upload API

Effortlessly upload and fetch files from Telegram 🚀


  1. Clone The Repository

    git clone https://github.com/TeaByte/telegram-upload-api
    cd telegram-upload-api
  2. Edit The config.json File

    In the config.json file, update the following fields with your Telegram credentials and bot information:

    {
    "apiId": 143...,
    "apiHash": "bd4fed...",
    "chatId": -10021442...,
    "botToken": "1234585269:AAGL9o....",
    "serverPort": 8080
    }
    • Replace your_api_id and your_api_hash with your Telegram credentials from https://my.telegram.org/auth.
    • Obtain a bot token from @BotFather and replace your_bot_token.
    • chatId is the ID of a Telegram group where files will be saved ( You can get it from @WhatChatIDBot ).
  3. Start The Server

    deno task start
  4. Test The Server Endpoints

    deno task test

APIs and Usage

The Telegram Upload API provides the following endpoints:

1. Upload Endpoint

  • Endpoint: /upload
  • Method: POST
  • Parameters:
    • file: The file to be uploaded (multipart form data)

Example

curl -X POST -F "file=@/path/to/file.txt" http://localhost:8080/upload

Response

{
  "message": "File uploaded successfully",
  "fileId": "the_file_id",
  "file": {
    "size": 12345,
    "name": "file.txt"
  }
}

2. Fetch Endpoint

  • Endpoint: /fetch
  • Method: GET
  • Parameters:
    • fileId: The unique identifier for the file record
    • mainFileName (Optional): The name to use when downloading the file

Example

curl http://localhost:8080/fetch?fileId=the_file_id

Response

The file content is streamed back as a download.