Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hashworks/go-xREL-API
A golang package to authorize with and access the complete xrel.to API.
https://github.com/hashworks/go-xREL-API
golang hacktoberfest xrel xrel-api
Last synced: 5 days ago
JSON representation
A golang package to authorize with and access the complete xrel.to API.
- Host: GitHub
- URL: https://github.com/hashworks/go-xREL-API
- Owner: hashworks
- License: gpl-3.0
- Created: 2016-04-16T15:57:03.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-10-30T16:47:20.000Z (about 4 years ago)
- Last Synced: 2024-10-19T22:48:41.411Z (20 days ago)
- Topics: golang, hacktoberfest, xrel, xrel-api
- Language: Go
- Homepage:
- Size: 107 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-starred - hashworks/go-xREL-API - A golang package to authorize with and access the complete xrel.to API. (hacktoberfest)
README
# xREL API Package
[![GoDoc](https://godoc.org/github.com/hashworks/go-xREL-API/xrel?status.svg)](https://godoc.org/github.com/hashworks/go-xREL-API/xrel)
A golang package to authorize with and access the complete xrel.to API.
Import this way:
```go
import github.com/hashworks/go-xREL-API/xrel
```All methods may return a `types.Error` struct, which implements the normal `error` type.
Additional to the `Error()` function this struct contains the variables `Type` and `Code`.
Errors with type `api` are [xREL.to errors](https://www.xrel.to/wiki/6435/api-errors.html), for all other
types and error codes see the `xrel/types/errors.go` file.To use this in your code try to cast it:
```go
err := xrel.SomeMethod()
if eErr, ok := err.(*types.Error); ok {
// Is of type types.Error, you can use the variables
} else {
// Is normal error
}
```If you use the OAuth authentication make sure to save the Config variable somewhere and set it again on your next run.
Here is an example how to use the OAuth2 authentication:```go
xrel.ConfigureOAuth2("OAUTH2_CLIENT_KEY", "OAUTH2_CLIENT_SECRET", "", []string{"viewnfo", "addproof"})fmt.Println("(1) Go to: " + xrel.GetOAuth2AuthURL(""))
fmt.Println("(2) Grant access, you should get back a verification code.")
fmt.Print("(3) Enter that verification code here: ")
verificationCode := ""
fmt.Scanln(&verificationCode)err := xrel.PerformOAuth2UserAuthentication(verificationCode)
ok(err)```