This project may be subject to:
- Bugs
- Bad Code
- Breaking Changes
- Abandonment
This is a (fledgling) Go library for OpenAlex.
OpenAlex is an index of hundreds of millions of interconnected scholarly papers, authors, institutions, and more. OpenAlex offers a robust, open, and free REST API to extract, aggregate, or search scholarly data.
This project aims to be an efficient yet powerful Go interface for the OpenAlex API, analogous to PyAlex.
The following features of OpenAlex are currently supported by this Go library:
- Get single entities
- Filter entities
- Search entities
- Group entities
- Search filters
- Select fields
- Sample
- Pagination
- N-grams
- Autocomplete endpoint
- Authentication
To install the OpenAlex-API library, use the following command:
go get github.com/diverged/goalex
Below are some examples of how to use the OpenAlex-API library.
package main
import (
"fmt"
"log"
"github.com/diverged/goalex/pkg/api"
"github.com/diverged/goalex/pkg/config"
)
func main() {
client := api.NewClient(config.Config{
Email: "your-email@example.com",
})
works := api.NewWorks(client)
work, err := works.GetByOpenAlexID("W12345678")
if err != nil {
log.Fatalf("Error getting work: %v", err)
}
fmt.Printf("Work Title: %s\n", work.Title)
}
package main
import (
"fmt"
"log"
"github.com/diverged/goalex/pkg/api"
"github.com/diverged/goalex/pkg/config"
)
func main() {
client := api.NewClient(config.Config{
Email: "your-email@example.com",
})
works := api.NewWorks(client)
filteredWorks, _, err := works.Filter(map[string]interface{}{
"publication_year": 2020,
}).Get()
if err != nil {
log.Fatalf("Error filtering works: %v", err)
}
for _, work := range filteredWorks {
fmt.Printf("Work Title: %s\n", work.Title)
}
}
This project is licensed under the MIT License. See the LICENSE file for details.