Class: Factual::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/factual.rb

Overview

The start point of using Factual API

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Api

To initialize a Factual::Api, you will have to get an API Key from Factual Developer Tools

Params: opts as a hash

  • opts[:api_key] required

  • opts[:debug] optional, default is false. If you set it as true, it will print the Factual Api Call URLs on the screen

  • opts[:domain] optional, default value is www.factual.com (only configurable by Factual employees)

Sample:

api = Factual::Api.new(:api_key => MY_API_KEY, :debug => true)


28
29
30
31
32
33
34
35
# File 'lib/factual.rb', line 28

def initialize(opts)
  @api_key = opts[:api_key]
  @version = 2
  @domain  = opts[:domain] || 'www.factual.com'
  @debug   = opts[:debug]

  @adapter = Adapter.new(@api_key, @version, @domain, @debug)
end

Instance Method Details

#get_table(table_key) ⇒ Object

Get a Factual::Table object by table_key

Sample:

api.get_table('g9R1u2')


41
42
43
# File 'lib/factual.rb', line 41

def get_table(table_key)
  Table.new(table_key, @adapter)
end

#get_token(unique_id) ⇒ Object

Get the token of a , it is a partner-only feature.



46
47
48
# File 'lib/factual.rb', line 46

def get_token(unique_id)
  return @adapter.get_token(unique_id)
end