finding both "Shopping_mall" and "food" within single URL for google places API - iphone

I tried following URLs to get both "shopping_mall" and "food" within a single request.
https://maps.googleapis.com/maps/api/place/search/json?location=%#,%#&radius=1500&sensor=true&key=%#&types=shopping_mall|food
This gives me response with only "food" type of places.
But,
https://maps.googleapis.com/maps/api/place/search/json?location=%#,%#&radius=1500&sensor=true&key=%#&types=shopping_mall
Gives the result with "shopping_mall" only. Also, The same URL with "food" only give the result same as "shopping_mall|food".
Has anyone faced this issue. I have searched across but cannot find any useful answer to that.
P.S. I have gone through this link and this link , too.

If you are getting only food in the first request, and you're getting 20 results, then it is likely Google believes the most relevant results are food. You may have to do 2 requests. You can try adding keyword=shopping, but that may limit your food results.

Related

How can I use "hints" in runtime optimization?

The OSRM Routing engine returns "hints" in many of its outputs, and you are able to pass these back into a new request, which saves on lookup time and thereby optimizes the query.
My question is how do I pass these "hints" back into the
/table/v1/car
API call as per the example below?
EXAMPLE:
An OSRM API request of
/table/v1/car/-0.693000,52.078000;-0.724000,52.040000
gives back (snippet) :
"sources": [
{
"hint": "uImugOqJroBBAAAAAAAAALoBAAAAAAAA7WvYQQAAAACaUzhDAAAAAEEAAAAAAAAAugEAAAAAAAAXCgAAmXb1__mxGgP4bPX_sKUaAwYALwrjJ41R",
"distance": 388.619802,
"location": [
-0.690535,
52.081145
],
"name": ""
},
The original coordinates:
-0.693000, 52.078000
have been fixed up to:
-0.690535, 52.081145
(snapped to a nearby road and the hint is as above).
So I would like to utilise these "hints" in a new API query for the same LAT/LNG location, which should optimize the query.
The manual says about hints:
This can be used on subsequent request to significantly speed up the query and to connect multiple services.
I've tried various combinations and looking at the manual, but so far nothing has worked.
Has anybody successfully passed "hint" data into the /table/v1/car
API for OSRM Routing?
If so, please would you let me know what you did
I tried your request:
/table/v1/car/-0.693000,52.078000;-0.724000,52.040000
and got response:
{"code":"Ok",
"durations":[[0,596.2],[615.9,0]],"destinations":[
{"hint":"teJ0h-fidIdBAAAAAAAAALoBAAAAAAAA7WvYQQAAAACaUzhDAAAAAEEAAAAAAAAAugEAAAAAAACrkAAAmXb1__mxGgP4bPX_sKUaAwYALwr88AjE",
"distance":388.619802,"name":"","location":[-0.690535,52.081145]},{"hint":"dbcDgLevA4BpAAAAAAAAAAQGAAAwCAAA4-dpQQAAAACIYVZDGSCSQzQAAAAAAAAAAgMAABwEAACrkAAATvb0_48VGgPg8_T_QBEaAw4Afwf88AjE",
"distance":129.943557,"name":"","location":[-0.723378,52.041103]}],
"sources":[
{"hint":"teJ0h-fidIdBAAAAAAAAALoBAAAAAAAA7WvYQQAAAACaUzhDAAAAAEEAAAAAAAAAugEAAAAAAACrkAAAmXb1__mxGgP4bPX_sKUaAwYALwr88AjE",
"distance":388.619802,"name":"","location":[-0.690535,52.081145]},{"hint":"dbcDgLevA4BpAAAAAAAAAAQGAAAwCAAA4-dpQQAAAACIYVZDGSCSQzQAAAAAAAAAAgMAABwEAACrkAAATvb0_48VGgPg8_T_QBEaAw4Afwf88AjE",
"distance":129.943557,"name":"","location":[-0.723378,52.041103]}]}
Your request has 2 points, so you have to add 2 hints, one for each point.
So, the request with hints is:
/table/v1/car/-0.693000,52.078000;-0.724000,52.040000?hints=teJ0h-fidIdBAAAAAAAAALoBAAAAAAAA7WvYQQAAAACaUzhDAAAAAEEAAAAAAAAAugEAAAAAAACrkAAAmXb1__mxGgP4bPX_sKUaAwYALwr88AjE;dbcDgLevA4BpAAAAAAAAAAQGAAAwCAAA4-dpQQAAAACIYVZDGSCSQzQAAAAAAAAAAgMAABwEAACrkAAATvb0_48VGgPg8_T_QBEaAw4Afwf88AjE
where hints are separated by semicolon.

Mongo conditional find

So I have this article page and I need to place related articles below the current article body.
There are certain attributes that I use to find similar articles but in case there isn't any, or if there is less than 2 found, I need to add just some other articles to the result.
So if a given article has a tag "Development", I need to search for 2 other articles with that tag, and if there is less than 2 that have this tag, I need to pull just some other articles.
Right now the flow is:
I make a request to get an article using query
I make request for related articles using the result of the first request.
But now I have difficulty understand how to make another request or put a condition into the second request to optimally get another article(s).
I appreciate any help
const article =await "your collection". find({tag:"Development"}).limit(2);
const x=2 - article.length
while(x>0){
var y=await "your collection". findOne();
article.push(y);
x--;
}

Yahoo finance webservice API

I am trying to get realtime stock data from BSE and NSE using yahoo finance web-services. I was able to get some data using following URL
http://finance.yahoo.com/webservice/v1/symbols/COALINDIA.NS/quote?format=json
But it gives me very limited information.
{
"list": {
"meta": {
"type": "resource-list",
"start": 0,
"count": 1
},
"resources": [
{
"resource": {
"classname": "Quote",
"fields": {
"name": "COAL INDIA LTD",
"price": "367.649994",
"symbol": "COALINDIA.NS",
"ts": "1418895539",
"type": "equity",
"utctime": "2014-12-18T09:38:59+0000",
"volume": "2826975"
}
}
}
]
}
}
I need more information like yearly high, low, last traded price etc. and I couldn't find any documentation related to this from yahoo where it details how to get more information.
Is there documentation available related to these services? Or please suggest if there are any alternatives available.
I don't know where the definitive documentation might be but for your particular example try appending &view=detail to your URL.
http://finance.yahoo.com/webservice/v1/symbols/COALINDIA.NS/quote?format=json&view=detail
This will at least give you the year_high and year_low that you asked after.
Now, even though the following won't work for your COALINDIA.NS symbol (I suspect the exchange is not supported), it might be worth exploring the following two examples:
Example 1: As before, but for Apple and Yahoo symbols, with &view=detail appended:
http://finance.yahoo.com/webservice/v1/symbols/YHOO,AAPL/quote?format=json&view=detail
Example 2: And now using a completely different url, resulting in much more response data. One key caveat is this data is delayed by 15 minutes:
http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20IN%20(%22YHOO%22,%22AAPL%22)&format=json&env=http://datatables.org/alltables.env
If you discover the major differences between those two options and what impact they might have then please do let us all know; I'd be interested in finding out more.
If you are fine with getting NSE qoutes, you can use this package for the purpose, it is extremely easy to setup.
http://nsetools.readthedocs.org/en/latest/index.html
Since it uses NSE website/services as data source, the quotes will not be delayed (max few seconds).
Beware that these data are both delayed and inconsistent. You are not getting anything even remotely close to tick or real-time data.
From example 2, refresh a few times, and inspect the "LastTradeWithTime" key-value pair. I sometimes get different quotes from different times of day, for no apparent reason. They are sometimes delayed up to three hours.
You get what you pay for; in other words, this is not a free lunch.
For those who are curious about the different options available in the Yahoo Finance URLs, I think these links might help. If it's not what you're looking for, sorry.
http://internetbandaid.com/2009/03/31/yahoo-stocks-api/
https://ilmusaham.wordpress.com/tag/stock-yahoo-data/
Note: the wordpress site contains information that was taken from a site called gummy-stuff.org which is listed in full at the bottom of the above site (I can only list 2 urls in this post so I had to do the round-about way). Oddly, I found this site on my own yesterday. Funny how stuff comes back around. If you visit this site you'll just see a statement from Yahoo that the info he had originally listed (you're looking at some of this site on the above wordpress site) was never intended to be for public consumption and is a violation of Yahoo's terms and conditions agreement as it can apparently be used for hacking purposes. I was curious to see what was on the original post so I searched for it on the WayBack Machine. BTW, the links to the spread sheets are still active in the archive.
Cheers. Thom

How to get exact phrase match out of Graph API search

Looking for a way to get an exact phrase match out of the Graph API's search endpoint. For example, all activities with "dogs and cats" in them. Putting the phrase in quotes doesn't seem to work, the API will return activities containing those words, but in any order.
curl -v "https://graph.facebook.com/search?q=%22dogs%20and%20cats%22&type=post&limit=75&access_token=&since=Wed+Jan+25+20%3A59%3A30&until=Wed+Jan+25+20%3A59%3A40"
returns and activity whose text is:
"Ohhh man it's raining dogs cats lobsters crab birds and horses up here. I'm scared!"
"dogs" "cats" and "and" are all in that post, but not in order.
Yeah I faced the same problem. There's a similar question that might help Using the Facebook Graph API to search for an exact string
Facebook doesnt allow exact phrasal matching drectly, atleast not at the API level, You would have to fetch the entire data and programmically check for exact matches (too slow though).

Search Facebook events and pagination (Graph API)

I am requesting this page to get the events with the keyword
"conference":https://graph.facebook.com/search?q=conference&type=event
This works fine.
The problem is the pagination returned:
"paging": {
"previous":"https://graph.facebook.com/search?q=conference&type=event&limit=25&since=2010-12-18T17%3A00%3A00%2B0000",
"next":"https://graph.facebook.com/search?q=conference&type=event&limit=25&until=2010-11-04T16%3A29%3A59%2B0000"
}
It seems to have more events with "conference", but requesting these 2 pagination URLS returns no data.
It's weird because it's the same for any requested keyword, and the pagination URLs returned by the Facebook API seems to always returns empty data.
Does anyone know what's the issue?
Thanks
I encountered similar confusion with a query against places. The "next" URL behaved exactly as you described it.
I could query location information using a url like this:
https://graph.facebook.com/search?access_token=INSERT_TOKEN&type=place&center=55.8660,-4.2715&distance=150&limit=10
And got back JSON with the first 10 places plus the following fragment which suggests the existence of paging params:
"paging": {
"next": "https://graph.facebook.com/search?access_token=INSERT_TOKEN&type=place&center=55.8660\u00252C-4.2715&distance=150&limit=10&offset=10"
Hitting that URL doesn't work. But I did figure out a combination of limit and offset params that gave me effective paging.
limit=10 & offset not defined => first 10 results
limit=20 & offset=10 => next 10 results
limit=30 & offset=20 => next 10 results
limit=40 & offset=30 => last 8 results (can stop here because less than 10 back)
limit=50 & offset=40 => confirmation that there are no more results
I realise that I've got "limit" and "offset" rather than the "limit" and "until" params that you get, but, hopefully you could apply the same technique i.e. keep incrementing the limit and inc the date/time to that of your last result?
I think this is a standard practice in Facebook Graph API. I think if your request resulted to a non empty JSON, they will always give you the next paging, even though it might be empty.
I am however not 100% sure, because Facebook Graph API does not seem to be very well documented... (for example they said we can modify this pagination thing but did not explain clearly how to do it).
Seems facebook has changed it recently.
Here's the fix:
For a datetime returned in next and previous as
"2011-01-18T08\u00253A42\u00253A35\u00252B0000",
replace all occurrences of "\u0025" with "%" and it should work fine.
If you notice the facebook's datetime format, it is
2011-01-18T08:42:35+0000
(date accepted by strtotime C function)