HERE autosuggest get complete address informations - javascript

I'm currently working with HERE API, using autosuggest to get my results.
In the adress object of each response I only got "label" who look like this :
"address": { "label": "Resort Mark Brandenburg, An der Seepromenade 20, 16816 Neuruppin, Germany" },
Is there a way to optain complete informations like discover or autocomplete do ?
Like having countryCode, city, street in the address object ?
On this page https://developer.here.com/documentation/geocoding-search-api/api-reference-swagger.html at autosuggest menu we can see all the informations in the response samples.
I'm using this query at the moment :
https://autosuggest.search.hereapi.com/v1/autosuggest?apiKey=MYAPIKEY&result_types=address,place&in=bbox:0.5833,42.9667,2.241295,44.210550&in=countryCode:FRA&q=apitol&limit=5&content-type=application/json&lang=fr-fr

Add this parameter "&show=details" for show address details.

If some additional fields to be rendered in the response, then you have to pass the "show" tag in the request query string. Please note that some of the fields involve additional webservice calls and can increase the overall response time.
More details regarding "show" tag are covered in below API specs.
https://developer.here.com/documentation/geocoding-search-api/api-reference-swagger.html
Sample Request Query.
https://autosuggest.search.hereapi.com/v1/autosuggest?apiKey=YOUR_API_KEY&result_types=address,place&in=bbox:0.5833,42.9667,2.241295,44.210550&in=countryCode:FRA&q=apitol&limit=5&content-type=application/json&lang=fr-fr&show=details

Related

Is There anyone who knows what this piece of code does?

I am very new to javascript .. and my teacher provided us with this piece of code along with html and css file which on any date you enter gives you images of mars taken from ISS..
Would anyone care to explain what is happening inside the data: {} and how to get such API URL'S? I mean from where do we get that?
var input_box=$('#div-date input');
var button=$('#div-button button');
var container2=$('#container2');
button.click(function()
{
$.ajax({
method: "GET",
url: "https://api.nasa.gov/mars-photos/api/v1/rovers/curiosity/photos",
data:
{
earth_date:parseInt(input_box.val().split('/')[2]).toString()+"-
"+parseInt(input_box.val().split('/')[1]).toString()+"-
"+parseInt(input_box.val().split('/')[0]).toString(),
api_key:"zrVafsMHD8r1SC8mHyg91mnNguuzdIoPRXGD1BvS"
},
The ajax method is a call to NASA endpoint where you are doing a GET call to the URL. I thinks this is clear.
Now, what does data?
earth_date is a value with the actual date parsed to a specific format. It get the date from the input_box with format 00/00/0000 and parse to format 0000-00-00
api_key is the key you need to authenticate and get the data.
And data itself is the way to send variables into URL. So, your url looks like this:
https://api.nasa.gov/mars-photos/api/v1/rovers/curiosity/photos?earth_date=YOUR_DATE&api_key=YOUR_API_KEY
Note that is compound by:
url+ ?earth_date + api_key.
Updated to answer the question:
The API key is a way to secure the API.
An API key is a way to identify who is calling the endpoint. So only calls that have the API key will be able to reach the endpoint (or whatever the developer want).
Is an string generated by the owner so the only way to get the API key is NASA to give it to you. I suppose NASA give free API keys, but is not a "general string" or something like that. Every organization will secure their apis in a way, NASA provide api keys to reach his 'free' endpoints.
The code in the data transform the date format '30/12/2019' to '2019-12-30' since only the later format is valid for the request.

How to read data response from Wikidata API?

I am making a ReactJS application to show information about people when they search for it. I am trying to use MediaWiki to get the information about a person from Wikipedia. I am making an API call and the response is very weird. I am getting this whole bunch of "claims" in the API response from which I don't know how to take the useful info
This is the response I get:
Now what should I do with these claims? The information itself is scattered there. For example: "Date of birth" key is in some other claim and the value of "Date of death" is in some other claim. I want to show information like this in my page:
How can I do it? I couldn't get any guide for this.
All information you need for item Q2038656 is in your response. For example:
P18 is image - located in P18/mainsnak/datavalue/value/Vinod Khanna at Esha Deol's wedding at ISCKON temple 11 (cropped).jpg (check here how to get the link to the image)
P19 is place of birth - in P19/mainsnak/datavalue/value/id/Q1113311 (you can get the name of this item by this query: Peshawar)
P569 is date of birth - in P569/mainsnak/datavalue/value/time/+1946-10-06T00:00:00Z
...continue in the same way for all other properties.

Codebird.js for Twitter API won't return more than one tweet in single call

Codebird.js is not working when I try to return a list of n number of tweets by adding to my params object.
It works when I include just the property screen_name to get a single tweet but when I add count in, as below, the response I get is still for only one tweet
params = {
"screen_name": screenName,
"count": "3"
};
I can't seem to find any codebird.js documentation besides the README.MD on the main github page.
Is my syntax correct? Am I approaching this the correct way by adding to params
Solved it. Turns out I was using the wrong api endpoint and should have been using statuses/user_timeline.
Note: Check this part of the docs to see how to map this endpoint's string to the right format https://github.com/jublonet/codebird-js#mapping-api-methods-to-codebird-function-calls

How to retrieve the list of positions including all the fields using the LinkedIn javascript sdk?

I want to get the id, title, summary, start-date, end-date, is-current and company name for each position that a LinkedIn member has entered on its profile.
I tested a query on the REST Console and I got the desired result. The query is "https://api.linkedin.com/v1/people/~/positions:(id,title,summary,start-date,end-date,is-current,company)?format=json".
The problem is that when I try to do the same thing using the LinkedIn javascript SDK I'm not getting the whole list of fields for each position. I'm getting the complete list of positions, but not all the fields for each position.
This is the call that I'm doing with the javascript SDK:
//in this function I'm specifying the list of fields that I want to retrieve for each position
//but I'm getting only some fields (id, start-date and end-date)
function getProfileData() {
IN.API.Raw("/people/~/positions:(id,title,summary,start-date,end-date,is-current,company)?format=json").result(onSuccess).error(onError);
}
Somebody has any idea of what I need to do to get the same result than using the REST Console?
Requesting URL is wrong.
Use following for positions
https://api.linkedin.com/v1/people/~:(id,positions)?format=json
Use following for locations
https://api.linkedin.com/v1/people/~:(id,location)?format=json
If you want to retrieve your profile data use this,
IN.API.Profile("me")
.fields([
"firstName","lastName","headline","positions:(company,title,summary,startDate,endDate,isCurrent)","industry",
"location:(name,country:(code))","pictureUrl","publicProfileUrl","emailAddress",
"educations","dateOfBirth"])
.result(onSuccess)
.error(onError);
(or) If you want to retrieve other profile data then replace "me" with "<public profile url>"
IN.API.Profile("url=https://nl.linkedin.com/in/williamhgates")
.fields([
"firstName","lastName","headline","positions:(company,title,summary,startDate,endDate,isCurrent)","industry",
"location:(name,country:(code))","pictureUrl","publicProfileUrl","emailAddress",
"educations","dateOfBirth"])
.result(onSuccess)
.error(onError);

HTML form with intermediate web service service call before submit

I have an HTML form to update the address in the account that submits to a Java servlet.
The problem is that, the form should not accept free flowing address text. Instead the user should enter the zip code/house number/street name, and hit a search button.
This search needs to go to a webservice, perform authentication and get a list of valid addresses that match the search criteria.
This list of addresses should be displayed to the user in the same form (either unhide a hidden element or use a modal dialog), so the user can pick his address.
Only after the valid address is picked, the user should be able to hit the form submit button which sends the data back to the servlet.
I am not sure how to have these 2 buttons do different actions in the form. I am very new to JavaScript and any pointers or examples are much appreciated.
For your webservice build an output of the values based on a search result (a basic string). Put this data in a JSON statement or just a javascript array.
Return something that looks like this.
['SearchResult1', 'SearchResult2', 'SearchREsult3']
On your search box. Bind a function on change or blur.
$('#SearchBox').bind('change', function(){
var val = $(this).val();
//Please reference the Jquery Ajax function as im typing this from memory and i always mix one or two things up :).
$.ajax({
"type" : "post",
"url" : "yoururlhere",
"data" : { "search":val },
success : function(dataset){
//When it comes back here check to see if its valid data etc etc
//After you validate you can populate a picklist on the page with the values. Or do anything you want with the values like this
for(x in dataset){
$('#DocumentElement').append('<p>'+ dataset[x] +'</p>');
}
}
});
});
This should start you out. After that you can just do more things on the callback, or modify the dom in a way which suits you better :).

Categories