Skip to content

Simple unofficial client library to send requests to the unpaywall API ( http://unpaywall.org/products/api ) and automatically download documents. http://godoc.org/github.com/JVecsei/go-unpaywall

License

Notifications You must be signed in to change notification settings

JVecsei/go-unpaywall

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-unpaywall

GoDoc Build Status Go Report Card

Simple unofficial library to send requests to the unpaywall API ( http://unpaywall.org/products/api ) and automatically download documents.

Is Unpaywall legal?

"Yes! We harvest content from legal sources including repositories run by universities, governments, and scholarly societies, as well as open content hosted by publishers themselves." (source, April 28, 2018)

Examples

Both Methods are also available for multiple requests / downloads (see godoc), which will be executed concurrently. By default 5 workers are started simultaneously.

Example Request

// your email address
var email string
// DOI
var doi string
u, _ := unpaywall.New(email)
// Request example
result, err := u.RequestByDOI(doi)
if err != nil {
	log.Fatalf("Error: %v", err)
}
fmt.Printf("Search result: %v", result)

Example Download

// your email address
var email string
// DOI
var doi string
u, _ := unpaywall.New(email)
var targetPath = "./"

file, err := u.DownloadByDOI(doi, targetPath)
if err != nil {
	log.Fatalf("Error: %v", err)
}
log.Printf("Success! Downloaded file to %s", file)

Example Multi-Request

// your email address
var email string
//DOIs
var dois []string
u, _ := unpaywall.New(email)
res, err := u.RequestByDOIs(dois)

for err != nil || res != nil {
	select {
	case r, ok := <-res:
		if !ok {
			res = nil
			continue
		}
		fmt.Printf("Found: %s \n", r.BestOaLocation.URLForPdf)
	case e, ok := <-err:
		if !ok {
			err = nil
			continue
		}
		fmt.Printf("Error: %s \n", e)
	}
}

CLI-Tool

The CLI tool in the cmd folder can be used like this:

unpaywall-cmd -doi "your-DOI" -email "your-email-address"

About

Simple unofficial client library to send requests to the unpaywall API ( http://unpaywall.org/products/api ) and automatically download documents. http://godoc.org/github.com/JVecsei/go-unpaywall

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages