Skip to content

Add Ability to search by state #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
aric87 opened this issue Oct 17, 2018 · 3 comments
Open

Add Ability to search by state #13

aric87 opened this issue Oct 17, 2018 · 3 comments

Comments

@aric87
Copy link

aric87 commented Oct 17, 2018

It would be cool to be able to find breweries by state.

@darrenrector91
Copy link
Contributor

Giving this a try

@darrenrector91
Copy link
Contributor

After looking over the API and the JS code I believe if you just type a state name in the input that will return the breweries in the corresponding state. I did find that the documentation for the API is wrong in that you have to give the entire state name not just the state abbreviation in order to return data. I could be wrong about this but I searched multiple states and the return was only for the state searched. I don't know if its returning all possible outcomes but the search with an entire state name does return quite a few results.

@tristandenyer
Copy link
Owner

tristandenyer commented Oct 18, 2018

Thanks for looking into this.

You are correct in that doing a search on the site for a state name will work like a filter. But, I have found that some breweries have state names in their names, and are not in that state. And searching for "Maine" brings back odd results because of their use of elastic search ("Main st" gets caught up in it.)

I tried the following two URLs, and both worked for me in that they returned only California breweries:
https://api.openbrewerydb.org/breweries?by_state=CA
https://api.openbrewerydb.org/breweries?by_state=california

You're right: definitely getting less results than our little app shows here. Their default is 20 results for state endpoint (looks like the search endpoint default is 50). You can up the state one to 50 by appending the parameters like so:
https://api.openbrewerydb.org/breweries?by_state=california&page=2&per_page=50
(50 breweries from page 2 of the results)

Also, be sure to look at #14 for some previous work and comments on this state search by another contributor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants