{"id":16513954,"url":"https://github.com/twin/go-pastebin","last_synced_at":"2025-10-03T23:25:57.138Z","repository":{"id":56577317,"uuid":"303219459","full_name":"TwiN/go-pastebin","owner":"TwiN","description":"A Pastebin.com API wrapper in Go.","archived":false,"fork":false,"pushed_at":"2025-03-07T02:07:52.000Z","size":72,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-17T23:04:51.819Z","etag":null,"topics":["api","go","golang","pastebin","pastebin-wrapper"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TwiN.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["TwiN"]}},"created_at":"2020-10-11T21:53:34.000Z","updated_at":"2025-03-07T02:07:54.000Z","dependencies_parsed_at":"2023-12-27T05:24:08.916Z","dependency_job_id":"49c72ec6-9d87-4db4-aa93-57601072cb68","html_url":"https://github.com/TwiN/go-pastebin","commit_stats":null,"previous_names":["twinproduction/go-pastebin"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TwiN%2Fgo-pastebin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TwiN%2Fgo-pastebin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TwiN%2Fgo-pastebin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TwiN%2Fgo-pastebin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TwiN","download_url":"https://codeload.github.com/TwiN/go-pastebin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244765151,"owners_count":20506767,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","go","golang","pastebin","pastebin-wrapper"],"created_at":"2024-10-11T16:10:58.401Z","updated_at":"2025-10-03T23:25:52.097Z","avatar_url":"https://github.com/TwiN.png","language":"Go","funding_links":["https://github.com/sponsors/TwiN"],"categories":[],"sub_categories":[],"readme":"# go-pastebin\n\n![test](https://github.com/TwiN/go-pastebin/actions/workflows/test.yml/badge.svg)\n[![Go Report Card](https://goreportcard.com/badge/github.com/TwiN/go-pastebin)](https://goreportcard.com/report/github.com/TwiN/go-pastebin)\n[![codecov](https://codecov.io/gh/TwiN/go-pastebin/branch/master/graph/badge.svg)](https://codecov.io/gh/TwiN/go-pastebin)\n[![Go version](https://img.shields.io/github/go-mod/go-version/TwiN/go-pastebin.svg)](https://github.com/TwiN/go-pastebin)\n[![Go Reference](https://pkg.go.dev/badge/github.com/TwiN/go-pastebin.svg)](https://pkg.go.dev/github.com/TwiN/go-pastebin)\n\nA [Pastebin.com](https://pastebin.com/) API wrapper in Go.\n\n\n## Table of Contents\n\n- [Usage](#usage)\n  - [Creating a paste](#creating-a-paste)\n  - [Deleting a paste](#deleting-a-paste)\n  - [Retrieving the content of a paste](#retrieving-the-content-of-a-paste)\n    - [GetUserPasteContent](#getuserpastecontent)\n    - [GetPasteContent](#getpastecontent)\n    - [GetPasteContentUsingScrapingAPI](#getpastecontentusingscrapingapi)\n  - [Retrieving paste metadata](#retrieving-paste-metadata)\n    - [GetAllUserPastes](#getalluserpastes)\n    - [GetPasteUsingScrapingAPI](#getpasteusingscrapingapi)\n    - [GetRecentPastesUsingScrapingAPI](#getrecentpastesusingscrapingapi)\n\n\n## Usage\n```\ngo get -u github.com/TwiN/go-pastebin\n```\n\n| Function                        | Client | Description                                                                                                                                                                                                                                                             | PRO  |\n|:--------------------------------|:-------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-----|\n| NewClient                       | n/a    | Creates a new Client                                                                                                                                                                                                                                                    | no   |\n| CreatePaste                     | yes    | Creates a new paste and returns the paste key                                                                                                                                                                                                                           | no   |\n| DeletePaste                     | yes    | Removes a paste that belongs to the authenticated user                                                                                                                                                                                                                  | no   |\n| GetAllUserPastes                | yes    | Retrieves a list of pastes owned by the authenticated user                                                                                                                                                                                                              | no   |\n| GetUserPasteContent             | yes    | Retrieves the content of a paste owned by the authenticated user                                                                                                                                                                                                        | no   |\n| GetPasteContent                 | no     | Retrieves the content of a paste using the raw endpoint. This does not require authentication, but only works with public and unlisted pastes. Using this excessively could lead to your IP being blocked. You may want to use GetPasteContentUsingScrapingAPI instead. | no   |\n| GetPasteContentUsingScrapingAPI | no     | Retrieves the content of a paste using Pastebin's scraping API                                                                                                                                                                                                          | yes* |\n| GetPasteUsingScrapingAPI        | no     | Retrieves the metadata of a paste using Pastebin's scraping API                                                                                                                                                                                                         | yes* |\n| GetRecentPastesUsingScrapingAPI | no     | Retrieves a list of recent pastes using Pastebin's scraping API                                                                                                                                                                                                         | yes* |\n\n\\*To use Pastebin's Scraping API, you must [link your IP to your account](https://pastebin.com/doc_scraping_api)\n\n### Creating a paste\nYou can create a paste by using `pastebin.Client`'s **CreatePaste** function:\n```go\nclient, err := pastebin.NewClient(\"username\", \"password\", \"token\")\nif err != nil {\n\tpanic(err)\n}\npasteKey, err := client.CreatePaste(pastebin.NewCreatePasteRequest(\"title\", \"content\", pastebin.ExpirationTenMinutes, pastebin.VisibilityUnlisted, \"go\"))\nif err != nil {\n\tpanic(err)\n}\nfmt.Println(\"Created paste:\", pasteKey)\n```\nTo view the paste on your browser, you can simply append the returned **pasteKey** to `https://pastebin.com/`.\n\nPassing an empty string as username and as password for the client will result in the creation of a guest paste\nrather than a paste owned by a user. Note that only authenticated users may create private pastes.\n\n\n### Deleting a paste\nYou can delete a paste owned by the user configured in the client by using the **DeletePaste** function:\n```go\nclient, err := pastebin.DeleteClient(\"username\", \"password\", \"token\")\nif err != nil {\n\tpanic(err)\n}\npasteKey, err := client.CreatePaste(pastebin.NewCreatePasteRequest(\"title\", \"content\", pastebin.ExpirationTenMinutes, pastebin.VisibilityUnlisted, \"go\"))\nif err != nil {\n\tpanic(err)\n}\nfmt.Println(\"Created paste:\", pasteKey)\n```\n\n\n### Retrieving the content of a paste\nThere 3 ways to retrieve the content of a paste:\n\n#### GetUserPasteContent\nIf you own the paste, you should use this.\n```go\nclient, err := pastebin.NewClient(\"username\", \"password\", \"token\")\nif err != nil {\n\tpanic(err)\n}\npasteContent, err := client.GetUserPasteContent(\"abcdefgh\")\nif err != nil {\n\tpanic(err)\n}\nprintln(pasteContent)\n```\n\n#### GetPasteContent\nThe paste is public or unlisted, and you don't have a Pastebin PRO account.\n```go\npasteContent, err := pastebin.GetPasteContent(\"abcdefgh\")\nif err != nil {\n\tpanic(err)\n}\nprintln(pasteContent)\n```\n**WARNING:** Using this excessively could lead to your IP being blocked. You may want to use [GetPasteContentUsingScrapingAPI](#getpastecontentusingscrapingapi) instead.\n\n#### GetPasteContentUsingScrapingAPI\nThe paste is public or unlisted and you have a Pastebin PRO account with your [IP linked](https://pastebin.com/doc_scraping_api).\n```go\npasteContent, err := pastebin.GetPasteContentUsingScrapingAPI(\"abcdefgh\")\nif err != nil {\n\tpanic(err)\n}\nprintln(pasteContent)\n```\n\n\n### Retrieving paste metadata\nJust like [retrieving paste content](#retrieving-the-content-of-a-paste), there are many ways to retrieve paste metadata.\n\n\u003cdetails\u003e\n    \u003csummary\u003eList of fields available in paste metadata\u003c/summary\u003e\n\n- key\n- title\n- user\n- url\n- hits\n- size\n- date\n- expiration date\n- visibility (public, unlisted, private)\n- syntax\n\u003c/details\u003e\n\n#### GetAllUserPastes\nThis will return a list of pastes owned by the user.\n```go\nclient, err := pastebin.NewClient(\"username\", \"password\", \"token\")\nif err != nil {\n\tpanic(err)\n}\npastes, err := client.GetAllUserPastes()\nif err != nil {\n\tpanic(err)\n}\nfor _, paste := range pastes {\n\tfmt.Printf(\"key=%s title=%s hits=%d visibility=%d url=%s syntax=%s\\n\", paste.Key, paste.Title, paste.Hits, paste.Visibility, paste.URL, paste.Syntax)\n}\n```\n\n#### GetPasteUsingScrapingAPI\nThis will return the metadata of a single paste.\n```go\npaste, err := pastebin.GetPasteUsingScrapingAPI(\"abcdefgh\")\nif err != nil {\n\tpanic(err)\n}\nfmt.Printf(\"key=%s title=%s hits=%d visibility=%d url=%s syntax=%s\\n\", paste.Key, paste.Title, paste.Hits, paste.Visibility, paste.URL, paste.Syntax)\n```\nBecause this function doesn't require authentication, it only works for public and unlisted pastes.\n\n#### GetRecentPastesUsingScrapingAPI\nThis will return a list of the most recent pastes on Pastebin.\n```go\nrecentPastes, err := pastebin.GetRecentPastesUsingScrapingAPI(\"\", 30)\nif err != nil {\n\tpanic(err)\n}\nfor _, paste := range recentPastes { \n    fmt.Printf(\"key=%s title=%s hits=%d visibility=%d url=%s syntax=%s\\n\", paste.Key, paste.Title, paste.Hits, paste.Visibility, paste.URL, paste.Syntax)\n}\n```\nThis method takes in **syntax** and **limit** as parameters. Leaving the **syntax** string empty applies no filtering. \nThe full list of supported values can be found [here](https://pastebin.com/doc_api#5).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwin%2Fgo-pastebin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftwin%2Fgo-pastebin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwin%2Fgo-pastebin/lists"}