https://github.com/cgxeiji/crossref
Access to CrossRef API
https://github.com/cgxeiji/crossref
crossref-api go golang
Last synced: 3 months ago
JSON representation
Access to CrossRef API
- Host: GitHub
- URL: https://github.com/cgxeiji/crossref
- Owner: cgxeiji
- License: mit
- Created: 2018-10-27T03:24:55.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-10-26T10:59:06.000Z (over 5 years ago)
- Last Synced: 2025-01-13T20:46:33.259Z (about 1 year ago)
- Topics: crossref-api, go, golang
- Language: Go
- Size: 18.6 KB
- Stars: 1
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# crossref
Access to Crossref API with Go
Full documentation of this package is [here](https://godoc.org/github.com/cgxeiji/crossref).
For a detailed explanation of the JSON fields, go to [Crossref API
Documentation](https://github.com/Crossref/rest-api-doc/blob/master/api_format.md).
## Example Code
``` Go
package main
import (
"fmt"
"github.com/cgxeiji/crossref"
)
var client = crossref.NewClient("Crossref Go", "mail@example.com")
func main() {
// If you want to debug the library, uncomment the following line:
// crossref.Debug()
// Search for a publication by doing a query. This returns up to 10 works
// that match the query terms.
search := "Slow Robots for Unobtrusive Posture Correction"
works, err := client.Query(search)
switch err {
case crossref.ErrZeroWorks:
fmt.Println("No works found")
case crossref.ErrEmptyQuery:
fmt.Println("An empty query was requested")
case nil:
default:
panic(err)
}
fmt.Printf("Found %d article(s) for query:\n > %q\n", len(works), search)
// Retrieve information directly from a DOI
doi := works[0].DOI
work, err := client.DOI(doi)
switch err {
case crossref.ErrZeroWorks:
fmt.Println("No works found")
case crossref.ErrEmptyQuery:
fmt.Println("An empty query was requested")
case nil:
default:
panic(err)
}
fmt.Printf("For DOI: %q found:\n", doi)
fmt.Printf(" > %q, (%v) %q\n", work.Title, work.Date, work.Authors)
// Output:
// Found 10 article(s) for query:
// > "Slow Robots for Unobtrusive Posture Correction"
// For DOI: "10.1145/3290605.3300843" found:
// > "Slow Robots for Unobtrusive Posture Correction", (2019) ["Shin, Joon-Gi" "Onchi, Eiji" "Reyes, Maria Jose" "Song, Junbong" "Lee, Uichin" "Lee, Seung-Hee" "Saakes, Daniel"]
}
```