Amadeus flask wtforms Search autocomplete suggestions? - autocomplete

Does anyone have an example of Amadeus search location autocomplete using flask and wtforms?
I cannot figure out how to show the locations in the drop-down menu to the user when he tries to type in the destination field. For Example, if he types 'New Yo" it should show him a drop-down menu with suggestions like New York - LGA, New York -JFK

For this, you have to integrate the API from self-service, to fetch the list of cities and airport names by IATA Code, https://developers.amadeus.com/self-service/category/air/api-doc/airport-and-city-search

Related

If watson can return country code according to country name?

I have enabled watson assist sys-location entity, I want to get the country code when I enter country name, for example, after I entered Japan, then watson can recognize it and response JP to me, enter China then return CN, is that possible? thanks.
Watson Assistant does not return such a value by default, but you could use server actions or your app to look up those values. As an example, create a Cloud Function action to search in a list or database for the country code.
https://console.bluemix.net/docs/services/conversation/dialog-actions.html#dialog-actions
No it cant be done automatically.What you can do is train Watson entity with country codes.Its better way than searching in database.

Ember CLI - Custom routing for very basic dropdown

New to ember and ember cli, and not having any JS based framework experience apart from jQuery (which is not a framework)
I find my self stuck at the very beginning compared to work done in Angular,
I have a static list of groups which are on REST api `http://localhost:8000/api/groups' and it is only 8 items there, I needed to show them as dropdown for a search criteria. Nothing fancy
I started with creating a route and model with the name of groups but app stopped working and I had to create a model for group which is identical to groups model, only having 2 items for dropdown
Now i have a url in my ember app http://localhost:4200/groups which I dont need and i dont want it to be there,
But I ignored it and had to create a dropdown of the cities, api is
http://localhost:8000/api/cities <-- All cities list, needed for admin
http://localhost:8000/api/cities/active <-- For clients to show active cities so they can add their records
http://localhost:8000/api/cities/filled <-- For users, to show them where clients are available
So in ember, I created a route and model for cities, and same model is copied as city just to show the list of cities in dropdown, I needed to show cities which are filled, I had created ember g route city/filled and it created folders, but its model is also same like other two models.
Ajax call is not being sent to city/filled url and now I ended up having
http://localhost:4200/cities // useless for me
http://localhost:4200/cities/filled //useless for me
and in filled i see that ajax call is made but to the http://localhost:8000/api/cities two times, loading same data. I tried adding a dropdown on my application and opened http://localhost:4200/cities/filled in browswer, and woosh, it send ajax call to the same url 3 times, one for application.hbs and one for cities.hbs and one for city/filled. Why load the same data 3 times if it is already fetched from same url within single request?
in angular I just call a custom url and I can get the data, but for ember its really hard to get grip on these small things and there is no help around
active and filled are filters for your cities resource and these are not standalone resources, so you should try to use them as query parameters. like
http://localhost:8000/api/cities?type=filled
http://localhost:8000/api/cities?type=active
Facebook uses this style for query params. You can also use query params for getting paginated data of a resource, like for 1st page and 25 records per page, the request will look like:
http://localhost:8000/api/cities?page=1&records=25

Accessing the Yelp Api

In my application I have to add a button, and display the number of stars received from YELP as shown in this image: , and upon clicking it I should navigate to a new View that will show the Yelp reviews.
1.) I have read the Yelp API, and was unable to find a way to append the Store Name to get its ratings in Yelp.
For example: I need to get the YELP ratings of Agra Indian Restaurant, so how should I get the JSON return values pertaining to Agra Indian Restaurant?
Is there any tutorial or sample code that illustrates how I could get this done?
You can get some examples form here:https://github.com/Yelp/yelp-api/tree/master/v2/ .I used php examples.Since the Search Parameters doesn`t contain the store name, you can using the business name as the "term" query parameter and the full business address as the "location"
parameter.
It's worth noting that if you know the business you're looking for specifically, you're
better off using the Phone API to look up info directly.

Missing Cities from Facebook all_cities_final.csv

I'm making Facebook App and I need to match the city from the user on Facebook with the city in my local database.
I've found the list of Cities from this link:
http://developers.facebook.com/attachme … _final.csv
But it seems that this is not the whole list, because there is no city from Macedonia in the list, but they do came up from auto complete when you try to write the city in your Hometown.
Am I missing something here, or is there some other list of Cities that I can find?
Also I've downloaded autocomplete_data.php from
http://developers.facebook.com/docs/reference/rest/ads.getAutoCompleteData/
and it doesn't have all cities.
Thank you.
So I just have the same issue and figured the cities are now places in the graph
https://graph.facebook.com/114897945188014
SELECT name,description,geometry,latitude,longitude,checkin_count,display_subtext FROM place WHERE page_id=114897945188014

Google Search autocomplete API?

Does Google provide API access to autocomplete for search like on the actual site? I have not been able to find anything.
I would like to use Google's autocomplete logic for web search on my own site which relies on Google's search API.
The new url is:
http://suggestqueries.google.com/complete/search?client=firefox&q=YOURQUERY
the client part is required; I did't test other clients.
[EDIT]
If you want the callback use this:
http://suggestqueries.google.com/complete/search?client=chrome&q=YOURQUERY&callback=callback
As #Quandary found out; the callback does not work with client "firefox".
[EDIT2]
As indicated by # user2067021 this api will stop working as of 10-08-2015: Update on the Autocomplete API
First, go to google, click Settings (bottom right corner), change Search Settings to "never show instant results. That way, you'll get regular autocomplete instead of a full page of instant results.
After your settings are saved, go back to the Google main home page. Open your browser's developer tools and go to the Network tab. If you're in Firefox, you might have to reload the page.
Type a letter in the search box. A new line should appear in the Network window you just opened. That line is showing where the autocomplete data came from. Copy that url. It should look something like this:
https://www.google.com/complete/search?client=hp&hl=en&sugexp=msedr&gs_rn=62&gs_ri=hp&cp=1&gs_id=9c&q=a&xhr=t&callback=hello
You'll notice your search term right after the part that says q=.
Add &callback=myAmazingFunction to the end of the url. You may replace myAmazingFunction with whatever you want to name your function that will handle the data.
Here's an example of the code required to show the autocomplete data for the search term "a".
<div id="output"></div>
<script>
/* this function shows the raw data */
function myAmazingFunction(data){
document.getElementById('output').innerHTML = data;
}
</script>
<script src="https://www.google.com/complete/search?client=hp&hl=en&sugexp=msedr&gs_rn=62&gs_ri=hp&cp=1&gs_id=9c&q=a&xhr=t&callback=hello&callback=myAmazingFunction"></script>
Now that you know how to get the data, the next step is to automatically change that last script (the one with the autocomplete url). The basic procedure is: each time the user types something in the search box (onkeyup) replace the search term (q=whatever) in the url, and then append to the body a script with that url. Remove the previous script so that the body doesn't get cluttered.
For more info, see http://simplestepscode.com/autocomplete-data-tutorial/
Most of the above mentioned methods works for me, specifically the following serves my purpose.
http://suggestqueries.google.com/complete/search?client=firefox&q=YOURQUERY
Being a newbie in web programming, I'm not much aware of the "Callback" functionality and the format of the file returned by query. I'm little aware of AJAX and JSON.
Could someone provide more details about the format of file returned by the query.
Thanks.
Hi I don't know if this answer is relevant for you anymore or not but google returns JSON data through following get request (although this isn't an official API but many toolbars are using this API so there's no reason why google might discontinue it):
http://google.com/complete/search?q=<Your keywords here>&hl=en
You should use AutocompleteService and pass that text box value into the service.getPlacePredictions function. It send the data in callback function.
let service = new google.maps.places.AutocompleteService();
let displaySuggestions = function(predictions, status) {
}
service.getPlacePredictions({
input: value
}, displaySuggestions);
Base: https://developers.google.com/maps/documentation/javascript/reference/places-autocomplete-service#AutocompleteService.getPlacePredictions
example: https://dzone.com/articles/implement-and-optimize-autocomplete-with-google-pl
I'm using (( Edrra.com )) API that have google search and suggestions that works with both GET & POST:
Google suggestions:
https://edrra.com/v1/api.php?c=google&f=suggest&k=YOUR_API_KEY&v=YOUR_SEARCH
Google search:
https://edrra.com/v1/api.php?c=google&f=search&k=YOUR_API_KEY&v=YOUR_SEARCH
and more...
What are you trying to use an auto-complete for? More information would help narrow it down.
As far as I know, google does not provide one, but they do exist like jQuery UI's auto-complete.
EDIT:
If you are using their custom search API view here for autocomplete.