feat: add HTTP API for programmatic file downloads#197
Open
feat: add HTTP API for programmatic file downloads#197
Conversation
- Add REST API endpoints for downloading files from Telegram messages
- POST /api/v1/download: submit download tasks
- GET /api/v1/task/{id}: query task status
- GET /health: health check endpoint
- Support token-based authentication
- Add API configuration section to config.toml
- Add comprehensive API documentation
This allows external applications to integrate with SaveAny-Bot
for automated file downloads from Telegram messages.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds an HTTP API for programmatic access to download files from Telegram messages.
Features
Configuration
Add the following section to
config.toml:```toml
[api]
enable = true
host = "0.0.0.0"
port = 8080
token = "your-secret-token" # Optional
```
Usage Example
```bash
Submit a download task
curl -X POST http://localhost:8080/api/v1/download \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-token" \
-d '{
"url": "https://t.me/channel/123\",
"storage": "local"
}'
Check task status
curl http://localhost:8080/api/v1/task/abc123 \
-H "Authorization: Bearer your-token"
```
Implementation Details
pkg/apipackage with HTTP server implementationconfig/api.gocoretask queuetgutilfor message parsingdocs/api.mdRelated Issue
Closes #179