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: "your_email@example.com", page: 5, per_page:25) # => HashBeyond 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: "your_email@example.com", per_page:1, cursor="*") # => HashThe metadata will contain the next_cursor to browse the next page:
Syconium.works(email: "your_email@example.com", 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() # => HashSearch authors:
Syconium.authors(email: "your_email@example.com", search: "Smith") # => HashFor autocomplete, use the q parameter as the autocomplete field and also optionally you can use the filter and search parameters:
Syconium.authors(email: "your_email@example.com", autocomplete: true, q: "Smi") # => Hash
Syconium.authors(email: "your_email@example.com", autocomplete: true, q: "Smi", search: "John") # => HashFilter authors by attributes:
Syconium.authors(email: "your_email@example.com", filter: 'has_orcid:true') # => HashGroup results by attributes:
Syconium.authors(email: "your_email@example.com", group_by: 'has_orcid') # => HashGet an author by ID:
Syconium.authors(email: "your_email@example.com", id: 'A1234567') # => Hash
Syconium.authors(email: "your_email@example.com", id: 'orcid:0000-0000-0000-0000') # => HashGet a random author:
Syconium.authors(email: "your_email@example.com", random: true) # => HashGet a random sample of 25 authors:
Syconium.authors(email: "your_email@example.com", sample: 25) # => HashThe concepts endpoints should work, but they are depreciated/unmaintained so it is recommended to use Topics instead.
List funders:
Syconium.funders() # => HashSearch funders:
Syconium.funders(email: "your_email@example.com", search: "Smith") # => HashFor autocomplete, use the q parameter as the autocomplete field and also optionally you can use the filter and search parameters:
Syconium.funders(email: "your_email@example.com", autocomplete: true, q: "Nationa") # => Hash
Syconium.funders(email: "your_email@example.com", autocomplete: true, q: "Nationa", search: "Biodiversity") # => HashFilter funders by attributes:
Syconium.funders(email: "your_email@example.com", filter: 'country_code:ca') # => HashGroup results by attributes:
Syconium.funders(email: "your_email@example.com", group_by: 'country_code') # => HashGet a funder by ID:
Syconium.funders(email: "your_email@example.com", id: 'F4320306076') # => Hash
Syconium.funders(email: "your_email@example.com", id: 'ror:021nxhr62') # => HashGet a random funders:
Syconium.funders(email: "your_email@example.com", random: true) # => HashGet a random sample of 25 funders:
Syconium.funders(email: "your_email@example.com", sample: 25) # => HashList institutions:
Syconium.institutions() # => HashSearch institutions:
Syconium.institutions(email: "your_email@example.com", search: "biodiversity") # => HashFor autocomplete, use the q parameter as the autocomplete field and also optionally you can use the filter and search parameters:
Syconium.institutions(email: "your_email@example.com", autocomplete: true, q: "biodiv") # => Hash
Syconium.institutions(email: "your_email@example.com", autocomplete: true, q: "greenhou", search: "frogs") # => HashFilter institutions by attributes:
Syconium.institutions(email: "your_email@example.com", filter: 'is_oa:true') # => HashGroup results by attributes:
Syconium.institutions(email: "your_email@example.com", group_by: 'oa_status') # => HashGet an institution by ID:
Syconium.institutions(email: "your_email@example.com", id: 'I157725225') # => Hash
Syconium.institutions(email: "your_email@example.com", id: 'ror:047426m28') # => HashGet a random institution:
Syconium.institutions(email: "your_email@example.com", random: true) # => HashGet a random sample of 25 institutions:
Syconium.institutions(email: "your_email@example.com", sample: 25) # => HashList keywords:
Syconium.keywords() # => HashSearch keywords:
Syconium.keywords(email: "your_email@example.com", search: "biodiversity") # => HashFor autocomplete, use the q parameter as the autocomplete field and also optionally you can use the filter and search parameters:
Syconium.keywords(email: "your_email@example.com", autocomplete: true, q: "biodiv") # => Hash
Syconium.keywords(email: "your_email@example.com", autocomplete: true, q: "ani", search: "evolution")) # => HashFilter keywords by attributes:
Syconium.keywords(email: "your_email@example.com", filter: 'works_count:1') # => HashGroup results by attributes:
Syconium.keywords(email: "your_email@example.com", group_by: 'cited_by_count') # => HashGet a keywords by ID:
Syconium.keywords(email: "your_email@example.com", id: 'biodiversity-conservation') # => HashGet a random sample of 5 keywords:
Syconium.keywords(email: "your_email@example.com", sample: 25) # => HashList publishers:
Syconium.publishers() # => HashSearch publishers:
Syconium.publishers(email: "your_email@example.com", search: "biodiversity") # => HashFor autocomplete, use the q parameter as the autocomplete field and also optionally you can use the filter and search parameters:
Syconium.publishers(email: "your_email@example.com", autocomplete: true, q: "biodiv") # => Hash
Syconium.publishers(email: "your_email@example.com", autocomplete: true, q: "greenhou", search: "frogs") # => HashFilter publishers by attributes:
Syconium.publishers(email: "your_email@example.com", filter: 'hierarchy_level:0') # => HashGroup results by attributes:
Syconium.publishers(email: "your_email@example.com", group_by: 'country_codes') # => HashGet a publishers by ID:
Syconium.publishers(email: "your_email@example.com", id: 'P4310315930') # => Hash
Syconium.publishers(email: "your_email@example.com", id: 'ror:047426m28') # => HashGet a random publishers:
Syconium.publishers(email: "your_email@example.com", random: true) # => HashGet a random sample of 25 publishers:
Syconium.publishers(email: "your_email@example.com", sample: 25) # => HashSources are where works are hosted and include several types: conferences, journals, preprint repositories, institutional repositories, etc.
List sources:
Syconium.sources() # => HashSearch sources:
Syconium.sources(email: "your_email@example.com", search: "biodiversity") # => HashFor autocomplete, use the q parameter as the autocomplete field and also optionally you can use the filter and search parameters:
Syconium.sources(email: "your_email@example.com", autocomplete: true, q: "eco") # => Hash
Syconium.sources(email: "your_email@example.com", autocomplete: true, q: "eco", search: "biodiversity") # => HashFilter sources by attributes:
Syconium.sources(email: "your_email@example.com", filter: 'is_oa:true') # => Hash
Group results by attributes:
Syconium.sources(email: "your_email@example.com", group_by: 'oa_status') # => HashGet a sources by ID:
Syconium.sources(email: "your_email@example.com", id: 'S4306402618') # => Hash
Syconium.sources(email: "your_email@example.com", id: 'issn:1314-2828') # => HashGet a random source:
Syconium.sources(email: "your_email@example.com", random: true) # => HashGet a random sample of 25 sources:
Syconium.sources(email: "your_email@example.com", sample: 25) # => HashList topics:
Syconium.topics() # => HashSearch topics:
Syconium.topics(email: "your_email@example.com", search: "biodiversity") # => HashFor autocomplete, use the q parameter as the autocomplete field and also optionally you can use the filter and search parameters:
Syconium.topics(email: "your_email@example.com", autocomplete: true, q: "biodiv") # => Hash
Syconium.topics(email: "your_email@example.com", autocomplete: true, q: "greenhou", search: "frogs") # => HashFilter topics by attributes:
Syconium.topics(email: "your_email@example.com", filter: 'subfield.id:1311') # => HashGroup results by attributes:
Syconium.topics(email: "your_email@example.com", group_by: 'subfield.id') # => HashGet a topics by ID:
Syconium.topics(email: "your_email@example.com", id: 'T10319') # => HashGet a random topics:
Syconium.topics(email: "your_email@example.com", random: true) # => HashGet a random sample of 25 works:
Syconium.topics(email: "your_email@example.com", sample: 25) # => HashList works:
Syconium.works() # => HashSearch works:
Syconium.works(email: "your_email@example.com", search: "biodiversity") # => HashFor autocomplete, use the q parameter as the autocomplete field and also optionally you can use the filter and search parameters:
Syconium.works(email: "your_email@example.com", autocomplete: true, q: "biodiv") # => Hash
Syconium.works(email: "your_email@example.com", autocomplete: true, q: "greenhou", search: "frogs") # => HashFilter works by attributes:
Syconium.works(email: "your_email@example.com", filter: 'is_oa:true') # => HashGroup results by attributes:
Syconium.works(email: "your_email@example.com", group_by: 'oa_status') # => HashGet a work by ID:
Syconium.works(email: "your_email@example.com", id: 'pmid:33982150') # => Hash
Syconium.works(email: "your_email@example.com", id: 'doi:10.48550/arXiv.2205.01833') # => Hash
Syconium.works(email: "your_email@example.com", id: 'https://doi.org/10.48550/arXiv.2205.01833') # => HashGet a random work:
Syconium.works(email: "your_email@example.com", random: true) # => HashGet a random sample of 25 works:
Syconium.works(email: "your_email@example.com", sample: 25) # => HashDevelopment
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.