How to get all Gems names via web?

ruby, rubygems

Solution

You could use `https://rubygems.org/latest_specs.4.8.gz` which returns gzipped marshal dumped array like this:

[["abscss", Gem::Version.new("0.0.1"), "ruby"],
["absee", Gem::Version.new("1.0"), "ruby"],
["absentee_camper", Gem::Version.new("0.0.7"), "ruby"],
["absgit", Gem::Version.new("0.3.0"), "ruby"],
["absinthe", Gem::Version.new("0.0.3"), "ruby"],
["absolute", Gem::Version.new("0.0.5"), "ruby"],
["AbsoluteRenamer", Gem::Version.new("1.1.2"), "ruby"],
["AbsoluteRenamer-date", Gem::Version.new("0.1.0"), "ruby"]]

But if you're in Ruby, I strongly recommend using the gem fetcher:

require 'rubygems/spec_fetcher'
fetcher = Gem::SpecFetcher.fetcher
tuples = fetcher.detect(:released) { true }

`tuples` is now an array of tuples of `[Gem::NameTuple, Gem::Remote]`. Some examples of what you can do with this:

tuples[1337][0].name # => GraphvizR
tuples[1337][0].version.to_s # => "0.1.0"

Problem

`https://rubygems.org/api/v1/search.json` provides only 30 gems, but in my local machine I can get all gems using `gem list --remote`. I read `http://guides.rubygems.org/rubygems-org-api/` , and an API which can get all gems in the list does not exist. How can I get the list via the web? Or, does anyone provide this? I want the gem's name at a minimum but, if possible, I want to get the name and version. I think `gem list --remote` is via web, so I can get all gem lists.

Original source