{"id":28139203,"url":"https://github.com/kenpratt/wikipedia-client","last_synced_at":"2025-05-14T17:19:25.565Z","repository":{"id":46287640,"uuid":"556662","full_name":"kenpratt/wikipedia-client","owner":"kenpratt","description":"Ruby client for the Wikipedia API","archived":false,"fork":false,"pushed_at":"2023-02-22T16:46:00.000Z","size":236,"stargazers_count":308,"open_issues_count":8,"forks_count":76,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-27T07:05:51.149Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://github.com/kenpratt/wikipedia-client","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kenpratt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2010-03-10T22:41:54.000Z","updated_at":"2025-03-14T12:34:26.000Z","dependencies_parsed_at":"2024-01-05T22:00:57.964Z","dependency_job_id":null,"html_url":"https://github.com/kenpratt/wikipedia-client","commit_stats":{"total_commits":204,"total_committers":32,"mean_commits":6.375,"dds":0.6764705882352942,"last_synced_commit":"74ecc8bc5d1fb88e88ef1424caf7993068ef9e74"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kenpratt%2Fwikipedia-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kenpratt%2Fwikipedia-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kenpratt%2Fwikipedia-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kenpratt%2Fwikipedia-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kenpratt","download_url":"https://codeload.github.com/kenpratt/wikipedia-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254190387,"owners_count":22029639,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-14T17:18:58.842Z","updated_at":"2025-05-14T17:19:25.550Z","avatar_url":"https://github.com/kenpratt.png","language":"Ruby","readme":"# Wikipedia API Client\n\n[![Gem Version](https://badge.fury.io/rb/wikipedia-client.svg)](https://badge.fury.io/rb/wikipedia-client)\n[![Build Status](https://github.com/kenpratt/wikipedia-client/workflows/Test/badge.svg)](https://github.com/kenpratt/wikipedia-client/actions?query=workflow%3ATest)\n\nAllows you to get wikipedia content through their API. This uses the\nalpha API, not the deprecated query.php API type.\n\nWikipedia API reference: \u003chttp://en.wikipedia.org/w/api.php\u003e\n\nAdopted from: \u003chttp://code.google.com/p/wikipedia-client/\u003e\n\n## Installation\n\n```\ngem install wikipedia-client\n```\n\n## Usage\n\n```ruby\nrequire 'wikipedia'\npage = Wikipedia.find( 'Getting Things Done' )\n#=\u003e #\u003cWikipedia:Page\u003e\n\npage.title\n#=\u003e 'Getting Things Done'\n\npage.fullurl\n#=\u003e 'http://en.wikipedia.org/wiki/Getting_Things_Done'\n\npage.text\n#=\u003e 'Getting Things Done is a time-management method...'\n\npage.content\n#=\u003e all the wiki markup appears here...\n\npage.summary\n#=\u003e only the wiki summary appears here...\n\npage.categories\n#=\u003e [..., \"Category:Self-help books\", ...]\n\npage.links\n#=\u003e [..., \"Business\", \"Cult following\", ...]\n\npage.extlinks\n# =\u003e [..., \"http://www.example.com/\", ...]\n\npage.images\n#=\u003e [\"File:Getting Things Done.jpg\", ...]\n\npage.image_urls\n#=\u003e [\"http://upload.wikimedia.org/wikipedia/en/e/e1/Getting_Things_Done.jpg\"]\n\npage.image_thumburls\n#=\u003e [\"https://upload.wikimedia.org/wikipedia/en/thumb/e/e1/Getting_Things_Done.jpg/200px-Getting_Things_Done.jpg\"]\n\n# or with custom width argument:\npage.image_thumburls(100)\n#=\u003e [\"https://upload.wikimedia.org/wikipedia/en/thumb/e/e1/Getting_Things_Done.jpg/100px-Getting_Things_Done.jpg\"]\n\npage.image_descriptionurls\n#=\u003e [\"http://en.wikipedia.org/wiki/File:Getting_Things_Done.jpg\"]\n\npage.main_image_url\n#=\u003e \"https://upload.wikimedia.org/wikipedia/en/e/e1/Getting_Things_Done.jpg\"\n\npage.coordinates\n#=\u003e [48.853, 2.3498, \"\", \"earth\"]\n\npage.templates\n#=\u003e [..., \"Template:About\", ...]\n\npage.langlinks\n#=\u003e {..., \"de\"=\u003e\"Getting Things Done\", \"eo\"=\u003e\"Igi aferojn finitaj\",  \"zh\"=\u003e\"尽管去做\", ...}\n```\n\n## Configuration\n\n### Global\n\nThis is by default configured like this:\n\n```ruby\nWikipedia.configure {\n  domain 'en.wikipedia.org'\n  path   'w/api.php'\n}\n```\n\n### Local\n\nIf you need to query multiple wikis indiviual clients with individual configurations can be\nused:\n\n```ruby\nconfig_en = Wikipedia::Configuration.new(domain: 'en.wikipedia.org')\nconfig_de = Wikipedia::Configuration.new(domain: 'de.wikipedia.org')\n\nclient_en = Wikipedia::Client.new(config_en)\nclient_de = Wikipedia::Client.new(config_de)\nclient_en.find( 'Getting Things Done' )\nclient_de.find( 'Buch' )\n```\n\n## Advanced\n\nSee the API spec at \u003chttp://en.wikipedia.org/w/api.php\u003e.\n\nIf you need data that is not already present, you can override parameters.\n\nFor example, to retrieve only the page info:\n\n```ruby\npage = Wikipedia.find( 'Getting Things Done', :prop =\u003e \"info\" )\n\npage.title\n#=\u003e \"Getting Things Done\"\n\npage.raw_data\n#=\u003e {\"query\"=\u003e{\"pages\"=\u003e{\"959928\"=\u003e{\"pageid\"=\u003e959928, \"ns\"=\u003e0,\n\"title\"=\u003e\"Getting Things Done\", \"touched\"=\u003e\"2010-03-10T00:04:09Z\",\n\"lastrevid\"=\u003e348481810, \"counter\"=\u003e0, \"length\"=\u003e7891}}}}\n```\n\n### Additional HTTP headers\n\nSome API features require tweaking HTTP headers. You can add additional headers via configuration.\n\nFor example, to retrieve the same page in different language variants:\n\n```ruby\nWikipedia.configure do\n   domain 'zh.wikipedia.org'\n   headers({ 'Accept-Language' =\u003e 'zh-tw' })\nend\n\nWikipedia.find('牛肉').summary #=\u003e \"牛肉是指從牛身上得出的肉，為常見的肉品之一。肌肉部分可以切成牛排、牛肉塊或牛仔骨，也可以與其他的肉混合做成香腸或血腸。\"\n\nWikipedia.configure do\n   domain 'zh.wikipedia.org'\n   headers({ 'Accept-Language' =\u003e 'zh-cn' })\nend\n\nWikipedia.find('牛肉').summary #=\u003e \"牛肉是指从牛身上得出的肉，为常见的肉品之一。肌肉部分可以切成牛排、牛肉块或牛仔骨，也可以与其他的肉混合做成香肠或血肠。\"\n```\n\n\n## Contributing\n\n### Getting the code, and running the tests\n\n```\ngit clone git@github.com:kenpratt/wikipedia-client.git\ncd wikipedia-client\nbundle install\nbundle exec rspec\n```\n\n### Pushing a new release of the Gem\n\n1. Edit `lib/wikipedia/version.rb`, changing `VERSION`.\n2. Test that the current branch will work as a gem, by testing in an external directory:\n3. Make a test directory.\n4. Add a `Gemfile` with:\n\n   ```\n   source 'https://rubygems.org'\n\n   gem 'wikipedia-client', :path =\u003e '/path/to/local/wikipedia-client'\n   ```\n\n5. And a `test.rb` file with:\n\n   ```\n   require 'wikipedia'\n\n   page = Wikipedia.find('Ruby')\n   puts page.title\n   ```\n\n6. And then run `bundle install \u0026\u0026 bundle exec ruby test.rb`\n7. Build the gem: `bundle exec gem build wikipedia-client.gemspec`.\n8. Commit the changes: `git commit -a -m 'Version bump to 1.4.0' \u0026\u0026 git tag v1.4.0 \u0026\u0026 git push \u0026\u0026 git push --tag`\n9. Publish the result to RubyGems: `bundle exec gem push wikipedia-client-1.4.0.gem`.\n10. Test the released gem in an external directory:\n11. Make a test directory.\n12. Add a `Gemfile` with:\n\n    ```\n    source 'https://rubygems.org'\n\n    gem 'wikipedia-client'\n    ```\n\n13. And a `test.rb` file with:\n\n    ```\n    require 'wikipedia'\n\n    page = Wikipedia.find('Ruby')\n    puts page.title\n    ```\n\n14. And then run `bundle install \u0026\u0026 bundle exec ruby test.rb`\n\n## Thanks!\n\nCopyright (c) 2008 Cyril David, released under the MIT license\n\nAdopted by Ken Pratt (ken@kenpratt.net) in 2010/03\n\nThanks to all the [Contributors](https://github.com/kenpratt/wikipedia-client/graphs/contributors).\n","funding_links":[],"categories":["Third-party APIs"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkenpratt%2Fwikipedia-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkenpratt%2Fwikipedia-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkenpratt%2Fwikipedia-client/lists"}