1

I am trying to use the Google Knowledge graph API. I already have the API key and also use the library instead of the RESTful API.

kgSearch = Kgsearch::KgsearchService.new
response = kgSearch.search_entities(query: query)

I have tried to instantiate the service as below

kgSearch = Kgsearch::KgsearchService.new(api: 'klfkdlfkdlm')

it's rejected because the init expect no arguments.

Any idea, how to add the api_key ??

I try also:

response = kgSearch.search_entities(query: query, api: 'fjfkjfl')

same things

Any ideas?

Seb
  • 2,929
  • 4
  • 30
  • 73

1 Answers1

0

According to the Ruby Docs for the Google Api Client, key is an instance method where you can assign your api key (http://www.rubydoc.info/github/google/google-api-ruby-client/Google/Apis/KgsearchV1/KgsearchService#key-instance_method).

So I believe you'd do something like the following:

kgSearch = Kgsearch::KgsearchService.new
kgSearch.key = 'your_key_here'
response = kgSearch.search_entities(query: query) # and any other options that are necessary
bwalshy
  • 1,096
  • 11
  • 19