Twingly Search API Ruby
A Ruby gem for Twingly's Search API (previously known as Analytics API). Twingly is a blog search service that provides a searchable API known as Twingly Search API.
Install via RubyGems
gem install twingly-search
Or add to your application's Gemfile and then run
require 'twingly/search' client = Twingly::Search::Client.new do |client| client.user_agent = "MyCompany/1.0" end query = client.query do |query| query.pattern = 'github page-size:10' query.language = 'sv' end result = query.execute => #<Twingly::Search::Result:0x3ff7adcbe3d4 @posts, @number_of_matches_returned=10, @number_of_matches_total=3035221> result.posts # will include all returned posts
twingly-search gem talks to a commercial blog search API and requires an API key. Best practice is to set the
TWINGLY_SEARCH_KEY environment variable to the obtained key.
Twingly::Search::Client can be passed a key at initialization if your setup does not allow environment variables.
Example code can be found in examples/.
Too learn more about the capabilities of this API you should read the Twingly Search API documentation.
- API key, contact [email protected] to get one
- Ruby 1.9, 2.0, 2.1, 2.2
- JRuby 9000
Development and release
- Make sure the master branch has an up-to-date changelog. Generate with
rake changelog. Set
CHANGELOG_GITHUB_TOKENto a personal access token to increase the API rate limit. (The changelog uses GitHub Changelog Generator)
- Bump version in
lib/twingly/search/version.rb, follow Semantic Versioning 2.0.0
- Build and release gem with
bundle exec rake release. This will create a git tag for the version and push the
.gemfile to https://rubygems.org/.
- Update release information on the releases page.
This gem is documented using YARD. To start a local YARD server run:
bundle exec rake yard:server
The YARD server reloads the documentation automatically so there is no need to restart it when making changes.
The MIT License (MIT)
Copyright (c) 2013 Twingly AB
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.