https://github.com/toby3d/telegraph
📚 Official unofficial Golang bindings for Telegraph API
https://github.com/toby3d/telegraph
List: telegraph
api api-client api-documentation api-wrapper awesome-go awesome-list binding bindings go go-client go-library go-packages golang golang-bindings golang-library golang-package library telegraph telegraph-api telegraph-parser
Last synced: 11 days ago
JSON representation
📚 Official unofficial Golang bindings for Telegraph API
- Host: GitHub
- URL: https://github.com/toby3d/telegraph
- Owner: toby3d
- License: mit
- Created: 2016-12-20T14:12:17.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-08-07T23:25:05.000Z (10 months ago)
- Last Synced: 2025-04-28T14:03:46.796Z (25 days ago)
- Topics: api, api-client, api-documentation, api-wrapper, awesome-go, awesome-list, binding, bindings, go, go-client, go-library, go-packages, golang, golang-bindings, golang-library, golang-package, library, telegraph, telegraph-api, telegraph-parser
- Language: Go
- Homepage: https://telegra.ph/api
- Size: 422 KB
- Stars: 67
- Watchers: 3
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.en.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-go - telegraph - Official unofficial Golang bindings for Telegraph API - ★ 48 (Third-party APIs)
README
# telegraph [](https://pkg.go.dev/source.toby3d.me/toby3d/telegraph/v2)
A simple package [with minimum official dependencies](v2/go.mod) to work with [Telegraph API](https://telegra.ph/api).
Download:
```bash
$ go get -u source.toby3d.me/toby3d/telegraph/v2
```Import:
```
import "source.toby3d.me/toby3d/telegraph/v2"
```Fill commands structs and execute it:
```go
package mainimport (
"context"
"fmt"
"log"
"net/http""source.toby3d.me/toby3d/telegraph/v2"
)func Must[T any](v T, err error) T {
if err != nil {
panic(err)
}return v
}func main() {
client := http.DefaultClientaccount, err := telegraph.CreateAccount{
AuthorURL: nil,
AuthorName: Must(telegraph.NewAuthorName("Anonymous")),
ShortName: *Must(telegraph.NewShortName("Sandbox")),
}.Do(context.Background(), client)
if err != nil {
log.Fatalln("cannot create account:", err)
}page, err := telegraph.CreatePage{
AuthorURL: nil,
AccessToken: account.AccessToken,
Title: *Must(telegraph.NewTitle("Sample Page")),
AuthorName: &account.AuthorName,
Content: []telegraph.Node{{
Element: &telegraph.NodeElement{
Tag: telegraph.P,
Children: []telegraph.Node{{Text: "Hello, World!"}},
},
}},
ReturnContent: true,
}.Do(context.Background(), client)
if err != nil {
log.Fatalln("cannot create page:", err)
}fmt.Printf("'%s' by %s\n%s", page.Title, page.AuthorName, page.Content[0])
// 'Sample Page' by Anonymous
//Hello, World!
}
```If you need help, [email me](mailto:[email protected]?subject=Telegraph). If you want to help me, [send a donation](https://toby3d.me/en/pay).