Module: Biostars::API

Defined in:
lib/biostars/api.rb,
lib/biostars/api/post.rb,
lib/biostars/api/user.rb,
lib/biostars/api/vote.rb,
lib/biostars/api/stats.rb,
lib/biostars/api/traffic.rb,
lib/biostars/api/version.rb

Overview

API wrapper for www.biostars.org public API

See Also:

Author:

Defined Under Namespace

Classes: Post, Stats, Traffic, User, Vote

Constant Summary collapse

API_URL =

Used for API requests

'https://www.biostars.org/api'
VERSION =

Biostars::API Gem version.

"0.1.4"

Class Method Summary collapse

Class Method Details

.get(url) ⇒ Hash

Used for general GET http requests to the API

Parameters:

  • url (String)

    API request endpoint.

Returns:

  • (Hash)

    returns API response



41
42
43
44
# File 'lib/biostars/api.rb', line 41

def self.get(url)
  response = HTTParty.get "#{API_URL}/#{url}"
  response.success? ? JSON.parse(response.body) : false
end

.trafficTraffic

Number of post views over the last 60 min filtered by unique IPs.

Returns:

  • (Traffic)

    returns a Traffic object.

Raises:



32
33
34
35
# File 'lib/biostars/api.rb', line 32

def self.traffic
	attributes = Biostars::API.get "traffic"
   attributes ? Biostars::API::Traffic.new(attributes) : raise(Biostars::Error)
end