Documentation
¶
Index ¶
Constants ¶
const ( LoginApiUrl = "https://pastebin.com/api/api_login.php" PostApiUrl = "https://pastebin.com/api/api_post.php" RawApiUrl = "https://pastebin.com/api/api_raw.php" // ScrapingApiUrl is one of the URLs of Pastebin's scraping API // // Requires PRO Pastebin account with a linked IP // See https://pastebin.com/doc_scraping_api ScrapingApiUrl = "https://scrape.pastebin.com/api_scraping.php" // ScrapeItemApiUrl is one of the URLs for Pastebin's scraping API // // Requires PRO Pastebin account with a linked IP // See https://pastebin.com/doc_scraping_api ScrapeItemApiUrl = "https://scrape.pastebin.com/api_scrape_item.php" // ScrapeItemMetadataApiUrl is one of the URLs for Pastebin's scraping API // // Requires PRO Pastebin account with a linked IP // See https://pastebin.com/doc_scraping_api ScrapeItemMetadataApiUrl = "https://scrape.pastebin.com/api_scrape_item_meta.php" // RawUrlPrefix is not part of the supported API, but can still be used to fetch raw pastes. // // See GetPasteContent RawUrlPrefix = "https://pastebin.com/raw" )
Variables ¶
var (
ErrNotAuthenticated = errors.New("must be authenticated to perform this action")
)
Functions ¶
func GetPasteContent ¶
GetPasteContent retrieves the content of a paste by using the raw endpoint (https://pastebin.com/raw/{pasteKey}) This does not require authentication, but only works with public and unlisted pastes.
WARNING: Using this excessively could lead to your IP being blocked. You may want to use GetPasteContentUsingScrapingAPI instead.
func GetPasteContentUsingScrapingAPI ¶
GetPasteContentUsingScrapingAPI retrieves the content of a paste by using the Scraping API (ScrapingApiUrl) This does not require authentication, but only works with public and unlisted pastes.
To use the scraping API, you must link your IP to your Pastebin account, or it will not work. See https://pastebin.com/doc_scraping_api
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the Pastebin client for performing operations that require authentication
func NewClient ¶
NewClient creates a new Client and authenticates said client before returning if the username parameter is passed.
Note that the only thing you can do without providing a username and a password is creating a new guest paste.
func (*Client) CreatePaste ¶
func (c *Client) CreatePaste(request *CreatePasteRequest) (string, error)
CreatePaste creates a new paste and returns the paste key If the client was only provided with a developer API key, a guest paste will be created. You can get the URL by simply appending the output key to "https://pastebin.com/"
func (*Client) DeletePaste ¶
DeletePaste removes a paste owned by the authenticated user
func (*Client) GetAllUserPastes ¶
GetAllUserPastes retrieves a list of pastes owned by the authenticated user
func (*Client) GetUserPasteContent ¶
GetUserPasteContent retrieves the content of a paste owned by the authenticated user Unlike GetPasteContent, this function can only get the content of a paste that belongs to the authenticated user, even if the paste is public.
type CreatePasteRequest ¶
type CreatePasteRequest struct { Title string Code string Expiration Expiration // Visibility of the paste that will be created. // Note that a Client configured without username/password cannot create a private paste Visibility Visibility // Syntax is the format of the paste (e.g. go, javascript, json, ...) // See https://pastebin.com/doc_api#5 for a full list of supported values Syntax string }
func NewCreatePasteRequest ¶
func NewCreatePasteRequest(title, code string, expiration Expiration, visibility Visibility, syntax string) *CreatePasteRequest
NewCreatePasteRequest creates a new CreatePasteRequest struct
Should be used as parameter to the Client.CreatePaste method
type Expiration ¶
type Expiration string
const ( ExpirationTenMinutes Expiration = "10M" ExpirationOneHour Expiration = "1H" ExpirationOneDay Expiration = "1D" ExpirationOneWeek Expiration = "1W" ExpirationTwoWeeks Expiration = "2W" ExpirationOneMonth Expiration = "1M" ExpirationSixMonth Expiration = "6M" ExpirationOneYear Expiration = "1Y" ExpirationNever Expiration = "N" )
type Paste ¶
type Paste struct { Key string Title string User string URL string Hits int Size int Date time.Time ExpireDate time.Time Visibility Visibility Syntax string }
func GetPasteUsingScrapingAPI ¶
GetPasteUsingScrapingAPI retrieves the metadata of a paste by using the Scraping API (ScrapingApiUrl) This does not require authentication, but only works with public and unlisted pastes.
To use the scraping API, you must link your IP to your Pastebin account, or it will not work. See https://pastebin.com/doc_scraping_api
func GetRecentPastesUsingScrapingAPI ¶
GetRecentPastesUsingScrapingAPI retrieves the most recent pastes using Pastebin's scraping API If you don't want to filter by language, you can pass an empty string as syntax. The maximum value for the limit parameter is 250.
To use the scraping API, you must link your IP to your Pastebin account, or it will not work. See https://pastebin.com/doc_scraping_api
type Visibility ¶
type Visibility int
const ( VisibilityPublic Visibility = 0 VisibilityUnlisted Visibility = 1 VisibilityPrivate Visibility = 2 )
func (Visibility) String ¶
func (v Visibility) String() string