scottrohrig/got-hops

API syntax documentation for project-relevant queries

Closed this issue · 1 comments

Description

  • make a note of the relevant api url syntax
  • note the types of queries we may encounter for the project

Building the query URLs:

We will use position stack so that when the user searches for a city, we can get the coordinates (lon, lat).

  • positionstack - 'city' - http://api.positionstack.com/v1/forward?access_key={positionAPIKey}&query={city}
    Using the coordinates we will will obtain the list of breweries, each containing its relevant info.
  • openbrewerydb - 'by_dist' - https://api.openbrewerydb.org/breweries?by_dist={latitude},{longitude}

Parsing the results:

Positionstack

// returns an array of location objects [{city1},{city2},...]
var data = [
    {
    ....
    confidence: 1,
    continent: "North America",
    country: "United States",
    country_code: "USA",
    county: "Alameda County",
    label: "Oakland, CA, USA",    // potentially relevant 
    latitude: 37.785199,              // relevant
    locality: "Oakland",
    longitude: -122.197811,        // relevant
    name: "Oakland",
    region: "California",
    region_code: "CA",
    street: null,
    type: "locality"
    },
    {
    ....
    }, 
    ....

// to use in openbrewerydb
var lon = data[0].longitude
var lat = data[0].latitude

openbrewerydb

// returns a list of brewery objects [{brew1},{brew2},...]
var breweries = [
  {
  brewery_type: "micro",  // <--
  city: "Oakland",
  country: "United States",
  id: "ale-industries-oakland",  // consider storing for favorite
  latitude: "37.7761111",
  longitude: "-122.2281897",
  name: "Ale Industries",  // <--
  phone: "9254705280",  // <--
  postal_code: "94601-2960",
  state: "California",
  street: "3096 E 10th St",
  website_url: "http://www.aleindustries.com"  // <--
  },
  {...},
  ...

for (var i = 0; i > breweries.length; i++) {
    var type = breweries[i].brewery_type;
    var id = breweries[i].id
    ...