I am currently writing my first "webapp" using javascript and the untappd API. The API documentation can be found here: https://untappd.com/api/docs#start
For those who don't know, untappd is an app that let's you checkin and rate beers with your phone. My plan is to make something that can recommend you a beer based on your own top rated beers in untappd! Just a hobby project.
So far I have been able to make the API call based on the username you fill in, parse the JSON data and display the top 10 beers in HTML cards on a webpage.
The next step would be to take certain characteristics of the top 10 beers (type of beer, brewery, rating for example) and use them as parameters to search for similar beers.
The problem however is that the "search beer" API of untappd seems quite limited. E.g. it doesnt return the global rating of the beers you find. Also you cannot search for a specific type of beer. For example if you query IPA - American" it might return a "IPA - Imperial/Double Black". You can find the untappd search beer API here: https://untappd.com/api/docs#beersearch
I was also thinking of using a different beer database to make the search however it doesnt seem there is a good public database around that I could use for this.
So basically I am looking for idea's. Maybe there's a better solution that I'm not seeing. Or some workaround that I can't think off.
It looks like the /beer/info/{bid} endpoint returns more details for each beer, so you could potentially perform the search, then iterate on each beer to grab additional details. Could use Promises.all() to help.
As far as filtering on specific type, unfortunately I think that is a calculated limitation in their public API to prevent API consumers from building robust integrations that may draw more attention to said integration. So you could also use the above endpoint to perform your own filtering on your end to only grab beers by type.
Related
I didn't want to ask such a basic question but I seem to not be able to find the answer on my own.
How can I query a specific plant without knowing its id?
Such as using the common name or binomial name.
I see that according to the documentation the path is /api/species/{id}, it might be my inexperience on using APIs but I'm left clueless on how to query a specific plant without prior knowledge of their id.
Would anyone be able to give me an explanation of how it works or even better link me to an article to fill the gaps of my API knowledge?
My current knowledge stems from the freecodecamp JSON APIs and AJAX short course which doesn't help when faced with this sort of documentation.
I got the response from another forum and then complemented it by learning more about REST APIs - APIs for Beginners - How to use an API (Full Course / Tutorial)
At the basic level in the form of a URL:
You start with the provided URL - https://trefle.io/api
Select which type of data you want such as Kingdom, subKingdom,
division, etc All the way down to plants or species. -
https://trefle.io/api/plants. As it is mentioned, "Plants
are all main species, without all the varieties, cultivars,
subspecies and forms", and species will give you all that belongs
to that species meaning several plants.
You provide the parameters that you want, with some being required and others being optional.
To know which parameters to use you can read underneath here, such as token, page_size, page, etc.
The first parameters
would go in front of the former link like so with ? -
https://trefle.io/api/plants?q=strawberry and the following parameters
are separated with a & like so -
https://trefle.io/api/plants?q=strawberry&token=yourAPIkey and
you can add any parameters to that such as showing only items with complete
data, minimum ph, or others that might interest you.
But do keep in mind that the database still seems to be particularly incomplete.
Also, this is in the form of a URL, in practice, this would be done differently, I recommend watching the video I linked above where he goes through a lot of this information and showcases helpful tools such as Postman.
I have a use case where I need to do complicated string matching on records of which there are about 5.1 Million of. When I say complicated string matching, I mean using library to do fuzzy string matching. (http://blog.bripkens.de/fuzzy.js/demo/)
The database we use at work is SAP Hana which is excellent for retrieving and querying because it's in memory so I would like to avoid pulling data out of there and re-populating it in memory on the application layer but at the same time I cannot take advantages of the libraries (there is an API for fuzzy matching in the DB but it's not comprehensive enough for us).
What is the middle ground here? If I do pre-processing and associate words in the DB with certain keywords the user might search for I can cut down the overhead but are there any best practises that are employed when It comes to this ?
If it matters. The list is a list of Billing Descriptors (that show up on CC statements) therefore, the user will search these descriptors to find out which companies the descriptor belongs too.
Assuming your "billing descriptor" is a single column, probably of type (N)VARCHAR I would start with a very simple SAP HANA fuzzy search, e.g.:
SELECT top 100 SCORE() AS score, <more fields>
FROM <billing_documents>
WHERE CONTAINS(<bill_descr_col>, <user_input>, FUZZY(0.7))
ORDER BY score DESC;
Maybe this is already good enough when you want to apply your js library on the result set. If not, I would start to experiment with the similarCalculationMode option, like 'similarcalculationmode=substringsearch' etc. And I would always have a look at the response times, they can be higher when using some of the options.
Only if response times are to high, or many active concurrent users are using your query, I would try to create a fuzzy search index on your search column. If you need more search options, you can also create a fullext index.
But that all really depends on you use case, the values you want to compare etc.
There is a very comprehensive set of features and options for different use cases, check help.sap.com/hana/SAP_HANA_Search_Developer_Guide_en.pdf.
In a project we did a free style search on several address columns (name, surname, company name, post code, street) and we got response times of 100-200ms on ca 6 Mio records WITHOUT using any special indexes.
I'm building a custom admin dashboard for users on our site who create posts. I want to show them the active amount of visitors on their posts only (not on the entire site).
I want it to act exactly like GA does it:
I was originally thinking of building this from scratch, but in retrospect it might be easier to use the GA API?
I've stared at the docs for forever and I'm just not groking it, so I'm coming here for help.
We have ~5,000 posts total, and I some people on our site have authored over 1000 posts, so the 'input' to GA will be anywhere from 1 to 1000+ slugs (for only their posts).
I want a combined amount of on-site traffic for their posts only.
Optionally, maybe it would have to be reversed... I'm not sure if GA can show it, but even better probably would be to get a content breakdown of the realtime visitors from the API, with 5000 max results. From there I can filter through the result set slugs (along with then number of users on each), and compare those results to each slug which belongs to that user, then just sum the totals on my end.
Is this something the Google API could help me with? which API endpoint would I need to use? Is it possible to have 5000+ max results for URLs with traffic on them from the API?
Thanks!
Yes, it is possible.
It seems that you should utilize Real Time Data: get endpoint.
Additionally, to limit results for specific pages (posts) only, you should use dimension filters (filters which will select only specific page views before calculating aggregated result), and 'ga:pagePath' looks like the one you need:
ga:pagePath
UI Name: Page
A page on your website specified by path and/or query parameters. Use in conjunction with hostname to get the full URL of the page.
Source
You might prefer using ga:pageTitle instead, if you have similar title for posts of a single author, and you haven't got common path elements in posts of the same author.
So you do something like:
GET https://www.googleapis.com/analytics/v3/data/realtime
ids=ga:<your_analytics_id>
metrics=rt:activeUsers
dimensions=rt:pagePath
filters=rt:pagePath=~/authors/123/*
Please notice that there maybe slight difference in real time and non-realtime API (e.g. use of 'rt' instead of 'ga' above), and generally realtime-API is still in beta.
Generally speaking, you should go here: Real Time Reporting API - Developer Guide and look through the links in the table of contents (left part of the page).
What about 'building from scratch' idea: it's rather simple from the developer's perspective, but it could be complex from the dev-ops perspective. I.e., it's not a problem to write code which would aggregate such metrics. But it could be a problem to make a system which will sustain required for that task amount of requests per second.
I think you will want to apply your second approach: pull down realtime visitors for all slugs and then aggregate by author on your own server.
There is a quota of 10,000 queries per profile per day. Using your first approach, it sounds like you would be performing a query for each author. Say you have 50 authors. This would leave you only 20 queries/day/author (10,000/50). Factoring in the time dimension, this would allow you only 8.33 (200/24) queries per hour for each author. Not very "realtime like".
If you have problems getting it going, check out http://www.embeddedanalytics.com - we have done many implementations such as this. In fact, we even have hat "Right Now" realtime widget.
Is there a way to determine the author based on the slug title?
Let me begin by saying, I have been searching for resources for this question for more than 3 days, so I truly hope I did not miss an "answer" anywhere.
Background:
I am working on a website/app built in HTML/CSS/Javascript that will use geolocation (Google Maps & Places API) to find a users location and return them the (for example) top 5 closest water parks to them at that location they are currently at.
Question:
I want to control the list of results the API picks from. So let's say, it'll only give them 5 out of 30 water parks that are near them and I have previously specified the names/locations of those 30 water parks.
The reason I want to do this is because after searching via Google Maps for "water parks nearby 123 Main Street, City, State" - it doesn't return all the results I want it to, just some.
As I stated, I have looked far and wide for this answer. I have read almost all of the relevant Google Places API and Maps API documentation with no clear cut answer. I have also found a few website that let you use a Google Docs spreadsheet to specify locations, but you can't get the code from them. And I have seen a few example using XML, but nothing exactly what I'm looking for.
I will also note that I am familiar with C# and PHP if that helps get me closer to my goal. But it seems like Javascript is the way to go.
Any help/hints/tips would be greatly appreciated! Thanks!!
Store the data in a database that supports spatial queries(may be a FusionTable for example), then you may use ST_DISTANCE to order the results by distance and LIMIT to limit the resultset.
Im working with the google-mapquest mapping API. I need to add some Points of Interest near a certain area from a given latitude-longitude location.
I search the google and mapquest documentation to figure out if there is a method to get all zip-codes in that area but i didnt find anything that does that.
I tried the harvesine implementation to calculate the nearest point given in that radiuos/latitude-longitude and it works fine. The problem with this approach is that i need to update constatntly the database, so i dont like it much.
The question is: Is there a service (google-mapquest or another) that gives you this information?.
No, there is no API for either service that I am aware of. Your best bet is to just get a ZIP Code database and use that. Some really good inexpensive ones are out there. I prefer http://www.zip-codes.com/zip-code-database.asp. Their $40 package is very accurate, updated monthly, and licensed by the USPS (so you know it's quality data).
UPDATE:
I found a WebService that does exactly what i need. You could provide only a simple ZipCode and a country or perhaps a full address and in the response you get the longitude/latitude. Then i send the Latitude and Longitude returned to get a list of all the ZipCodes near the provided coordinates and a given Radius that also can be customized.
You can filter the total rows you want the service to return, or even if you are gonna use miles or kilometers as the measure unit.
So, basically with the returned information, i feed those coordinates for each of the nearest ZipCodes obtained to the google API and render those points of interest into the map that you need to show.
The services are provided by GeoNames. Its an organization dedicated to Geolocalization services. They offer also premium data, but in particular these services are free of use, obviously the information is not as accurate as the premium one, but actually in my tests i found that that is trustful and the response also is very fast.
Another good advantage is that the process to get a Key for use Geonames services it's quite simple.
I left you the link of the services that i'm talking about.
List of available services:
http://www.geonames.org/export/web-services.html
Hope it helps many people.
Regards!