Rails google places client https://github.com/qpowell/google_places Gemfile gem 'google_places' Make a PORO class GooglePlacesClient def initialize @client = GooglePlaces::Client.new ENV["GOOGLE_MAPS_API_KEY"] end # Returns search results for schools in array of hashes. # Radius is in meters. def fetch_schools(lat:, lon:, radius: 10_000) results = @client.spots(lat, lon, types: [:school, :university], radius: radius) format_results_json(results) end private def format_results_json(results) results.map do |result| { name: result.name, place_id: result.place_id, reference: result.reference, types: result.types, formatted_address: result.formatted_address, lat: result.lat, lng: result.lng, viewport: result.viewport, } end end end