https://github.com/sunhill666/goalex

GoAlex is a Go library for OpenAlex API.

https://github.com/sunhill666/goalex

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (9.7%) to scientific vocabulary

Keywords

go golang openalex research scholarly-articles scholarly-metadata sdk sdk-go
Last synced: 6 months ago · JSON representation

Repository

GoAlex is a Go library for OpenAlex API.

Basic Info
  • Host: GitHub
  • Owner: Sunhill666
  • License: mit
  • Language: Go
  • Default Branch: main
  • Homepage:
  • Size: 56.6 KB
Statistics
  • Stars: 2
  • Watchers: 0
  • Forks: 0
  • Open Issues: 0
  • Releases: 3
Topics
go golang openalex research scholarly-articles scholarly-metadata sdk sdk-go
Created 9 months ago · Last pushed 8 months ago
Metadata Files
Readme License

README.md

GoAlex

GoAlex is a Go client library for the OpenAlex API.

OpenAlex is a fully open catalog of the global research system, created by the nonprofit organization OurResearch. It's named after the ancient Library of Alexandria.

Features

  • Provides Go structs for OpenAlex entities: works, authors, sources, institutions, concepts, and venues
  • Lightweight and easy-to-use API client
  • Supports:

    • Pagination (standard and cursor)
    • Filtering and full-text search
    • Sorting, field selection, and random sampling
    • Grouping and aggregation
    • Autocomplete
  • Polite pool support for higher rate limits

  • Authentication support for premium access

Roadmap

The project is in active development. The following features have been implemented:

  • [x] Core data structures
  • [x] Polite pool support
  • [x] Basic API client
  • [x] Authentication support
  • [x] Pagination support
  • [x] Filtering and searching
  • [x] Sorting, selecting, and sampling
  • [x] Random result retrieval
  • [x] Grouping support
  • [x] Cursor pagination
  • [x] Autocomplete support
  • [ ] N-gram support (Not yet available in OpenAlex)

Community contributions are welcome!

Installation

bash go get -u github.com/Sunhill666/goalex

Usage

Client Initialization

Create a new client with:

go client := goalex.NewClient()

You can customize the client with options:

go client := goalex.NewClient(goalex.WithRetry(3, 2 * time.Second), goalex.WithTimeout(10 * time.Second))

To use a custom HTTP client, you can pass it as an option:

go client := goalex.NewClient(goalex.WithHTTPClient(&http.Client{ Timeout: 10 * time.Second }))

To use the polite pool (recommended for higher rate limits), provide an email:

go client := goalex.NewClient(goalex.PolitePool("you@example.com"))

To use authentication (for premium features):

go client := goalex.NewClient(goalex.Auth("your_api_key"))


Fetch a Single Entity

Retrieve a work by ID:

go work, err := client.Works().Get("W2741809807")


Fetch a Random Entity

Get a random work:

go work, err := client.Works().GetRandom()


List Entities

Fetch a list of works:

go works, err := client.Works().List()

With pagination:

go works, err := client.Works().Page(1).PerPage(10).List()

With metadata:

go resultWithMeta, err := client.Works().ListWithMeta() results, meta := resultWithMeta.Results, resultWithMeta.Meta


Cursor Pagination

For large result sets:

go works, nextCursor, err := client.Works().Filter("publication_year", 2020).PerPage(100).Cursor()

To get the next page:

go nextWorks, _, err := client.Works().Filter("publication_year", 2020).PerPage(100).Cursor(nextCursor)


Filtering and Searching

Filtering

go works, err := client.Works().FilterMap(map[string]any{ "institutions.country_code": "fr+gb", "authors_count": ">2", }).List()

Searching

go works, err := client.Works().Search("machine learning").List()

Combined Search + Filter

go works, err := client.Works().SearchFilter(map[string]string{ "display_name": "surgery", "title": "surgery", }, true).List()


Sorting, Selecting, and Sampling

Sorting

go works, err := client.Works().SortMap(map[string]bool{ "publication_year": true, "relevance_score": true, }).List()

Selecting Fields

go works, err := client.Works().Select("id", "doi", "display_name").List()

Sampling

go works, err := client.Works().Sample(2).Seed(42).List()


Grouping

go grouped, err := client.Works().GroupBy("authorships.countries", true).ListGroupBy()


Autocomplete

Institutions

go results, err := client.Institutions().AutoComplete("flori").List()

Works with filter and search

go results, err := client.Works(). Filter("publication_year", 2010). Search("frogs"). AutoComplete("greenhouse"). List()


License

Licensed under the MIT License.

Issues & Contributions

Found a bug or have a feature request? Feel free to open an issue or submit a PR on the GitHub repo.

Owner

  • Name: 游柏豪
  • Login: Sunhill666
  • Kind: user
  • Company: Nons

WRYYYYYYYYYYYYYYYYYY!!!!!

GitHub Events

Total
  • Release event: 3
  • Watch event: 1
  • Push event: 11
  • Create event: 5
Last Year
  • Release event: 3
  • Watch event: 1
  • Push event: 11
  • Create event: 5

Packages

  • Total packages: 2
  • Total downloads: unknown
  • Total dependent packages: 0
    (may contain duplicates)
  • Total dependent repositories: 0
    (may contain duplicates)
  • Total versions: 10
proxy.golang.org: github.com/Sunhill666/goalex
  • Versions: 5
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 6 months ago
proxy.golang.org: github.com/sunhill666/goalex
  • Versions: 5
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 6 months ago

Dependencies

go.mod go