Fork 0
Go library for working with the Lenpaste API.
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Leonid Maslakov 4a879ea09c Update to Lenpaste API v1.2 12 months ago
LICENSE first commit 1 year ago
README.md Update to Lenpaste API v1.2 12 months ago
client.go Update to Lenpaste API v1.2 12 months ago
client_get.go Add go doc 1 year ago
client_new.go Update to Lenpaste API v1.2 12 months ago
client_server.go Add go doc 1 year ago
go.mod first commit 1 year ago


pasteapi is a Go library for working with the Lenpaste API.


Add to go.mod file:

require git.lcomrade.su/root/pasteapi.go v1


package main

import (

func main() {
	pasteSrv := pasteapi.NewServer("https://paste.lcomrade.su/")
	//pasteSrv.Auth("user", "pass")

	// Getting server information
	srvInfo, err := pasteSrv.GetServerInfo()
	if err != nil {
	fmt.Println("## Server Info ##")
	fmt.Println("URL:", pasteSrv.Server)
	fmt.Println("Version:", srvInfo.Version)
	fmt.Println("Maximum paste title length:", srvInfo.TitleMaxLen)
	fmt.Println("Maximum paste body length:", srvInfo.BodyMaxLen)
	fmt.Println("Maximum paste lifetime:", srvInfo.MaxLifeTime)
	fmt.Println("About this server:", srvInfo.ServerAbout)
	fmt.Println("Server rules:", srvInfo.ServerRules)
	fmt.Println("Server Term of Use:", srvInfo.ServerTermsOfUse)
	fmt.Println("Administrator name:", srvInfo.AdminName)
	fmt.Println("Administrator mail:", srvInfo.AdminMail)
	fmt.Println("Syntaxes:", srvInfo.Syntaxes)
	fmt.Println("UI default paste lifetime:", srvInfo.UiDefaultLifeTime)
	fmt.Println("Need auth to create pastes:", srvInfo.AuthRequired)

	// Creating a paste
	fmt.Println("\n## TEST ##")
	fmt.Println("Creating a new paste...")

	pasteID, _, _, err := pasteSrv.New(pasteapi.NewPaste{
		Title: "Test paste",
		Body: `package main

func main() {
	println("Hello world!")
		LineEnd:    pasteapi.LineEndUnix, // LF (\n) line end
		Syntax:     "Go",
		OneUse:     false,
		Expiration: 60 * 10, // 10 minutes
		Author: "Anon",
		AuthorEmail: "me@example.org",
		AuthorURL: "example.org",
	if err != nil {
	fmt.Println("A new paste is created:", pasteSrv.Server+"/"+pasteID)

	// Getting the paste
	fmt.Println("Obtaining the newly created paste...")
	pasteGet, err := pasteSrv.Get(pasteID, false)
	if err != nil {
	fmt.Println("ID:", pasteGet.ID)
	fmt.Println("Title:", pasteGet.Title)
	fmt.Println("Body:", pasteGet.Body)
	fmt.Println("Create time:", pasteGet.CreateTime)
	fmt.Println("Delete time:", pasteGet.DeleteTime)
	fmt.Println("One use:", pasteGet.OneUse)
	fmt.Println("Syntax:", pasteGet.Syntax)
	fmt.Println("Author:", pasteGet.Author)
	fmt.Println("Author email:", pasteGet.AuthorEmail)
	fmt.Println("Author URL:", pasteGet.AuthorURL)


Read documentation online on pkg.go.dev. Or use go doc -all git.lcomrade.su/root/pasteapi.go to read offline.


This library is distributed under the MIT license.