An open API service indexing awesome lists of open source software.

https://github.com/kd3n1z/go-telegram-parser

Telegram Web App initData parsing & validation
https://github.com/kd3n1z/go-telegram-parser

go golang parser telegram telegram-mini-app telegram-web-app telegram-web-app-data telegram-web-app-data-parser validation

Last synced: 13 days ago
JSON representation

Telegram Web App initData parsing & validation

Awesome Lists containing this project

README

          

# go-telegram-parser

A lightweight parser for validating and extracting data from Telegram Web App's initialization data. This library ensures data validation using HMAC-SHA256 hashing.

## Usage

```go
package main

import (
"fmt"
telegramparser "github.com/kd3n1z/go-telegram-parser"
)

func main() {
botToken := "your-bot-token-here"

parser := telegramparser.CreateParser(botToken)

initData, err := parser.Parse("query_id=123&auth_date=1234567890&hash=abcdef...")

if err == nil {
fmt.Println("Validated data:")
fmt.Println("QueryId:", initData.QueryId)
fmt.Println("Hash:", initData.Hash)
fmt.Println("User.FirstName:", initData.User.FirstName)
// ...
} else {
fmt.Println("Validation failed.")
}
}
```

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.