alexreisner/geocoder

Unable to configure API Key for Lookup separately from IP Lookup

joseph-vo opened this issue · 2 comments

Given a lookup service like Google, which does not provide IP Lookup services. And given an IP Lookup service like Abstract, which does not provide Lookup services. There appears to be no official way to configure the paid API key(s) for both services.

Is there currently any way to configure API keys separately for API Lookup and Lookup services?

Yes, you can set any lookup-specific values for all config options by using the lookup's name as a key in the config hash. See here for an example: https://github.com/alexreisner/geocoder#configuring-multiple-services

This is great. Thanks for the help! I stopped too soon in the README at Please see lib/geocoder/configuration.rb for a complete list of configuration options. In this case, the following was implemented and worked perfectly:

Geocoder.configure(
  lookup: :google,
  ip_lookup: :abstract_api,
  google: {
    api_key: "abc1234",
  },
  abstract_api: {
    api_key: "def5678",
  }
)