Skip to content

SpeciesFileGroup/syconium

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Syconium

Syconium is a Ruby wrapper on the OpenAlex API. Code follow the spirit/approach of the Gem serrano, and indeed much of the wrapping utility is copied 1:1 from that repo, thanks @sckott.

Installation

Add this line to your application's Gemfile:

gem 'syconium'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install syconium

Usage

To use the OpenAlex API via the Syconium Ruby gem, you must supply either your email address or your api_key. Providing your email helps OpenAlex get in touch with your if there is a problem with your software.

Pagination

For pagination, you can browse up to 10,000 results with the page and per_page parameters:

Syconium.works(email: "[email protected]", page: 5, per_page:25) #  => Hash

Beyond 10,000 results it is strongly recommended to use the data snapshot instead of the API, but you can also use a cursor, which you can request with a *:

Syconium.works(email: "[email protected]", per_page:1, cursor="*") #  => Hash

The metadata will contain the next_cursor to browse the next page:

Syconium.works(email: "[email protected]", per_page:1, cursor="IlsxMDAuMCwgNTM2NCwgJ2h0dHBzOi8vb3BlbmFsZXgub3JnL1czMDEwNDQxNzMyJ10i")

Endpoints

All of the endpoints (authors, funders, keywords, institutions, publishers, sources, topics, works) are wrapped and function similarly.

List authors:

Syconium.authors() #  => Hash

Search authors:

Syconium.authors(email: "[email protected]", search: "Smith") #  => Hash

For autocomplete, use the q parameter as the autocomplete field and also optionally you can use the filter and search parameters:

Syconium.authors(email: "[email protected]", autocomplete: true, q: "Smi") #  => Hash
Syconium.authors(email: "[email protected]", autocomplete: true, q: "Smi", search: "John") #  => Hash

Filter authors by attributes:

Syconium.authors(email: "[email protected]", filter: 'has_orcid:true') #  => Hash

Group results by attributes:

Syconium.authors(email: "[email protected]", group_by: 'has_orcid') #  => Hash

Get an author by ID:

Syconium.authors(email: "[email protected]", id: 'A1234567') #  => Hash
Syconium.authors(email: "[email protected]", id: 'orcid:0000-0000-0000-0000') #  => Hash

Get a random author:

Syconium.authors(email: "[email protected]", random: true) #  => Hash

Get a random sample of 25 authors:

Syconium.authors(email: "[email protected]", sample: 25) #  => Hash

The concepts endpoints should work, but they are depreciated/unmaintained so it is recommended to use Topics instead.

List funders:

Syconium.funders() #  => Hash

Search funders:

Syconium.funders(email: "[email protected]", search: "Smith") #  => Hash

For autocomplete, use the q parameter as the autocomplete field and also optionally you can use the filter and search parameters:

Syconium.funders(email: "[email protected]", autocomplete: true, q: "Nationa") #  => Hash
Syconium.funders(email: "[email protected]", autocomplete: true, q: "Nationa", search: "Biodiversity") #  => Hash

Filter funders by attributes:

Syconium.funders(email: "[email protected]", filter: 'country_code:ca') #  => Hash

Group results by attributes:

Syconium.funders(email: "[email protected]", group_by: 'country_code') #  => Hash

Get a funder by ID:

Syconium.funders(email: "[email protected]", id: 'F4320306076') #  => Hash
Syconium.funders(email: "[email protected]", id: 'ror:021nxhr62') #  => Hash

Get a random funders:

Syconium.funders(email: "[email protected]", random: true) #  => Hash

Get a random sample of 25 funders:

Syconium.funders(email: "[email protected]", sample: 25) #  => Hash

List institutions:

Syconium.institutions() #  => Hash

Search institutions:

Syconium.institutions(email: "[email protected]", search: "biodiversity") #  => Hash

For autocomplete, use the q parameter as the autocomplete field and also optionally you can use the filter and search parameters:

Syconium.institutions(email: "[email protected]", autocomplete: true, q: "biodiv") #  => Hash
Syconium.institutions(email: "[email protected]", autocomplete: true, q: "greenhou", search: "frogs") #  => Hash

Filter institutions by attributes:

Syconium.institutions(email: "[email protected]", filter: 'is_oa:true') #  => Hash

Group results by attributes:

Syconium.institutions(email: "[email protected]", group_by: 'oa_status') #  => Hash

Get an institution by ID:

Syconium.institutions(email: "[email protected]", id: 'I157725225') #  => Hash
Syconium.institutions(email: "[email protected]", id: 'ror:047426m28') #  => Hash

Get a random institution:

Syconium.institutions(email: "[email protected]", random: true) #  => Hash

Get a random sample of 25 institutions:

Syconium.institutions(email: "[email protected]", sample: 25) #  => Hash

List keywords:

Syconium.keywords() #  => Hash

Search keywords:

Syconium.keywords(email: "[email protected]", search: "biodiversity") #  => Hash

For autocomplete, use the q parameter as the autocomplete field and also optionally you can use the filter and search parameters:

Syconium.keywords(email: "[email protected]", autocomplete: true, q: "biodiv") #  => Hash
Syconium.keywords(email: "[email protected]", autocomplete: true, q: "ani", search: "evolution")) #  => Hash

Filter keywords by attributes:

Syconium.keywords(email: "[email protected]", filter: 'works_count:1') #  => Hash

Group results by attributes:

Syconium.keywords(email: "[email protected]", group_by: 'cited_by_count') #  => Hash

Get a keywords by ID:

Syconium.keywords(email: "[email protected]", id: 'biodiversity-conservation') #  => Hash

Get a random sample of 5 keywords:

Syconium.keywords(email: "[email protected]", sample: 25) #  => Hash

List publishers:

Syconium.publishers() #  => Hash

Search publishers:

Syconium.publishers(email: "[email protected]", search: "biodiversity") #  => Hash

For autocomplete, use the q parameter as the autocomplete field and also optionally you can use the filter and search parameters:

Syconium.publishers(email: "[email protected]", autocomplete: true, q: "biodiv") #  => Hash
Syconium.publishers(email: "[email protected]", autocomplete: true, q: "greenhou", search: "frogs") #  => Hash

Filter publishers by attributes:

Syconium.publishers(email: "[email protected]", filter: 'hierarchy_level:0') #  => Hash

Group results by attributes:

Syconium.publishers(email: "[email protected]", group_by: 'country_codes') #  => Hash

Get a publishers by ID:

Syconium.publishers(email: "[email protected]", id: 'P4310315930') #  => Hash
Syconium.publishers(email: "[email protected]", id: 'ror:047426m28') #  => Hash

Get a random publishers:

Syconium.publishers(email: "[email protected]", random: true) #  => Hash

Get a random sample of 25 publishers:

Syconium.publishers(email: "[email protected]", sample: 25) #  => Hash

Sources are where works are hosted and include several types: conferences, journals, preprint repositories, institutional repositories, etc.

List sources:

Syconium.sources() #  => Hash

Search sources:

Syconium.sources(email: "[email protected]", search: "biodiversity") #  => Hash

For autocomplete, use the q parameter as the autocomplete field and also optionally you can use the filter and search parameters:

Syconium.sources(email: "[email protected]", autocomplete: true, q: "eco") #  => Hash
Syconium.sources(email: "[email protected]", autocomplete: true, q: "eco", search: "biodiversity") #  => Hash

Filter sources by attributes:

Syconium.sources(email: "[email protected]", filter: 'is_oa:true') #  => Hash

Group results by attributes:

Syconium.sources(email: "[email protected]", group_by: 'oa_status') #  => Hash

Get a sources by ID:

Syconium.sources(email: "[email protected]", id: 'S4306402618') #  => Hash
Syconium.sources(email: "[email protected]", id: 'issn:1314-2828') #  => Hash

Get a random source:

Syconium.sources(email: "[email protected]", random: true) #  => Hash

Get a random sample of 25 sources:

Syconium.sources(email: "[email protected]", sample: 25) #  => Hash

List topics:

Syconium.topics() #  => Hash

Search topics:

Syconium.topics(email: "[email protected]", search: "biodiversity") #  => Hash

For autocomplete, use the q parameter as the autocomplete field and also optionally you can use the filter and search parameters:

Syconium.topics(email: "[email protected]", autocomplete: true, q: "biodiv") #  => Hash
Syconium.topics(email: "[email protected]", autocomplete: true, q: "greenhou", search: "frogs") #  => Hash

Filter topics by attributes:

Syconium.topics(email: "[email protected]", filter: 'subfield.id:1311') #  => Hash

Group results by attributes:

Syconium.topics(email: "[email protected]", group_by: 'subfield.id') #  => Hash

Get a topics by ID:

Syconium.topics(email: "[email protected]", id: 'T10319') #  => Hash

Get a random topics:

Syconium.topics(email: "[email protected]", random: true) #  => Hash

Get a random sample of 25 works:

Syconium.topics(email: "[email protected]", sample: 25) #  => Hash

List works:

Syconium.works() #  => Hash

Search works:

Syconium.works(email: "[email protected]", search: "biodiversity") #  => Hash

For autocomplete, use the q parameter as the autocomplete field and also optionally you can use the filter and search parameters:

Syconium.works(email: "[email protected]", autocomplete: true, q: "biodiv") #  => Hash
Syconium.works(email: "[email protected]", autocomplete: true, q: "greenhou", search: "frogs") #  => Hash

Filter works by attributes:

Syconium.works(email: "[email protected]", filter: 'is_oa:true') #  => Hash

Group results by attributes:

Syconium.works(email: "[email protected]", group_by: 'oa_status') #  => Hash

Get a work by ID:

Syconium.works(email: "[email protected]", id: 'pmid:33982150') #  => Hash
Syconium.works(email: "[email protected]", id: 'doi:10.48550/arXiv.2205.01833') #  => Hash
Syconium.works(email: "[email protected]", id: 'https://doi.org/10.48550/arXiv.2205.01833') #  => Hash

Get a random work:

Syconium.works(email: "[email protected]", random: true) #  => Hash

Get a random sample of 25 works:

Syconium.works(email: "[email protected]", sample: 25) #  => Hash

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, update the CHANGELOG.md, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/SpeciesFileGroup/syconium. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT license. You can learn more about the MIT license on Wikipedia and compare it with other open source licenses at the Open Source Initiative.

Code of Conduct

Everyone interacting in the Syconium project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

About

Ruby wrapper for the OpenAlex API

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published