REST API for driving distance? - api

Is there a service that will give me the driving distance between two addresses? Apparently Google Maps API requires you to display a map, which I don't want to do (on that particular page), and I'd like to just snag the data and save it to my DB after a user submits a form, rather than waiting for JS to do it's thing.
If it's relevant, this is going into a Django app. I discovered that CloudMade offers a Python API, which is nice, except their latest dev release has a bug in it (can't use the API object), but more importantly, it's support for Canada is awful (couldn't find directions from any major city around here!).

MapQuest's Directions API is HTTP Querystring based (I'm not sure if it's entirely RESTful). Can get XML or JSON response. Just need to send it an HTTP GET Request.
http://developer.mapquest.com/web/products/open/directions-service
Use the "distance" response parameter.

I don't have a high enough reputation on SO to comment on an answer but I just wanted to be clear that contrary to the voted correct answer, Google Directions API has to adhere to the Google Maps API. If you scroll down the supplied link, you will see:
Note: the Directions API may only be used in conjunction with displaying results on a Google map; using Directions data without displaying a map for which directions data was requested is prohibited. Additionally, calculation of directions generates copyrights and warnings which must be displayed to the user in some fashion. For complete details on allowed usage, consult the Maps API Terms of Service License Restrictions.

Would it be possible to use Google Maps GDirections object? This can return the textual directions instead of the map overlay if called with a div object. From there you can use the getDistance (or getDuration) functions. You can always use an invisible div for the returns if you don't want anything to be displayed on the page.
Start here
http://code.google.com/apis/maps/documentation/examples/directions-advanced.html
http://code.google.com/apis/maps/documentation/reference.html#GDirections
And use this sample code
var map;
var directionsPanel;
var directions;
function initialize() {
directionsPanel = document.getElementById("route");
directions = new GDirections(null, directionsPanel);
GEvent.addListener(directions , "load", onGDirectionsLoad);
directions.load("from: 500 Memorial Drive, Cambridge, MA to: 4 Yawkey Way, Boston, MA 02215 (Fenway Park)");
}
function onGDirectionsLoad(){
alert(directions.getDistance().html);
}

Here is my solution:
Signup for Mapquest Developer network.
Get AppId
Open your command shell and run the following command(or use fiddler) But running it through curl will give you flexibility to automate your request
curl -X POST -H "Content-Type: application/json" -d '{locations: ["Salt Lake City, UT","Ogden, UT",],options: {allToAll: false}}' http://www.mapquestapi.com/directions/v2/routematrix?key=YOURKEYGOESHERE >> distance.txt
Save above command with all your destinations into batch or sh file.
Now grep and parse out your distance.txt file for what you need.

There are free services out there, but the quality of the data may be questionable/non-existent in areas. Be aware of licences on the data too, storing in your own DB may be a breach.
http://openrouteservice.org/

Take a look at Navteq. I used their service in developing a driving directions application about 5 years ago, and got good results. Can't speak for them lately though. I believe the best URL is Navteq Routing Service

You can use the new Google Directions API directly, without using any javascript.
http://code.google.com/apis/maps/documentation/directions/

Related

How do I programatically download bank of America transactions?

I use quicken, which can automatically download bank of America transactions. However, it truncates all the payees so I lose data. I'd like to work around this and I'm thinking of downloading the transaction data and generating my own QFX file with the full payee info.
Is there a way that I can download transactions programmatically, or download something like a .qif (available on their website) programmatically? For the latter, I could convert the gif to a QFX myself.
If anyone has other ideas to download all of the transaction information without losing the payee info, I would welcome those ideas as well.
Do they provide an api for this? but most probably not for 3p without a contract. since its bank , there must be check for browser etc along with standard sign in so it'll hard for curl. you can have a browser plugin to read all the data from the page and do auto scroll to get new transactions if not fitting in page. it's a hacky solution but good to get what we need as you told that data is available on the page and have to revisit with updates but changes in basic structure is rare.
A quick search for bank of america api yielded this BofA API. They even have many options for types of payment information you could query here as well as lots of individual account types that you can access it as.
It looks pretty comprehensive. If you don't see what you are looking for there I put another option below, just in case.
I don't use BofA. So I can't speak to what they have natively available. But you could always use a bot to scrape it if they present it anywhere in the User Interface.
I would agree with Meena that you should not be able to use curl. But selenium uses a browser to programmatically do just about anything that you would want to do with any website. They also have bindings for many languages. So you could just pick your favorite and go to town...
It seems the API will return a JSON so you may need to find a tool to convert that to a qif or qfx if that part is important. After digging further, I can't test this without having a CashPro account but it seems what you need to do is...
Step 1:
Get an access token from here. You'll need to send this in the header of any requests
Step 2:
Send an http request with a header in the following format:
{
"accounts": [
{
"accountNumber": "xxxxxxx",
"bankId": "xxxxxxx"
}
],
"fromDate": "yyyy-mm-dd",
"toDate": "yyyy-mm-dd"
}
to https://developer.bankofamerica.com/cashpro/reporting/v1/transaction-inquiries/previous-day
Step 3:
You should get a JSON as a response
As mentioned, I can't test this but here's the documentation of the specific API endpoint you need

Endpoint with Google Flex env

There is bit of a confusion, wondering if somebody can help me with this.
Here is an example which is a year old and uses goapp with polymer and endpoint
https://github.com/googlesamples/cloud-polymer-go
Here is a recent example using gcloud
https://github.com/GoogleCloudPlatform/golang-samples/tree/master/appengine_flexible/endpoints
Both are different as google changed its approach.
As per second example, I am able to create endpoint functions which uses json for input and output. However there are 2 problems
1st. It is throwing error if I put functions in different file under same package. It works when I run go run .go. but then I dont understand how app.yaml come into picture. I think this url /_ah/spi/. should work
2nd. I am using postman app to check the request and response from endpoint. Is there a better way? I thought google does provide a platform to test endpoint.
Is there any example which implements examples similar to 1st one with new libraries?
looking forward for your help. Thanks.

Official way to fetch the number of tweets for a URL

Twitter has private endpoints like this one:
http://urls.api.twitter.com/1/urls/count.json
Tweet counts can be fetched from here, but this is not recommended by Twitter. Besides, they keep saying they gonna shut down these endpoints in the near future.
The Site Streams API is now in closed beta, they don't accept applications.
https://dev.twitter.com/streaming/sitestreams
So that leaves is with only one option, the REST API, but I don't see any endpoint there which could return the number of tweets for a given URL.
What's the best way to get this data? Is there an "official" endpoint for this?
Or the only way is to use something like the Public stream API or the REST API search endpoints and filter the results?
The private endpoint will be shut down by 20 Nov and there'll be nothing to replace it. This blog post from Twitter explains the background: apparently it's to do with their move to their new "real-time, multi-tenant distributed database" system codenamed Manhattan.
The REST API will be of limited use for this purpose. You'd have to do a search for your URL, collect each page of results and add up the total number of tweets yourself. For example this request
https://api.twitter.com/1.1/search/tweets.json?q=metro.co.uk&count=100
will get tweets associated with http://metro.co.uk. (It won't work if you just paste this into your browser - you have to authenticate first. You can try this on the Twitter API console tool.) But the Search API returns a max of 100 tweets per page of results, and it only returns tweets from the last 7 days.
It seems the only solution (explained here) is an elaborate one using a Twitter Streaming API. Basically you'd have to create your own app to count relevant tweets. It would open a connection to stream.twitter.com passing your URL as a track parameter. Twitter will return a tweet every time anyone tweets the address, and your app will have to count them. The example given in that post is:
curl -u user:password "https://stream.twitter.com/1/statuses/filter.json" -d "track=https%3A%2F%2Fdev.twitter.com%2Fdiscussions%2F5653"
I'm not sure how you would deal with shortened URLs in this scenario.
This change has meant that third-party services like SharedCount that report a count of Twitter shares are having to stop offering that data. Sorry to give you bad news - I'm really disappointed with this situation myself. It seems crazy that we can't just get a total of tweets for a given URL.
You can find a little bit more about this in this thread.

Spotify API get Related Artists

Is there a way to get a list of related artists through the spotify api. Like the small list that displays in the actual program?
Would be very useful if so, but I am not so sure
Cheers
Yes, it's available through libspotify. There's a SPArtistBrowse class that contains a lot of metadata, including the related artists. Check out the
CocoaLibSpotify comes with a documentation package, where you can find more details on what's included: https://github.com/spotify/cocoalibspotify.
Do note that it's currently extremely slow to load an entire SPArtistBrowse object. I'm assuming it's got something to do with libspotify loading it all in one chunk and on the main thread (?). From what I know, Spotify are suppose to remedy that in an upcoming version of libspotify, though.
Get an artist's related artists is now available through the Spotify Web API.
GET https://api.spotify.com/v1/artists/{id}/related-artists is the format.
https://api.spotify.com/v1/artists/43ZHCT0cAZBISjO8DG9PnE/related-artists is an example request.
For more information, see the API documentation.
There is also a JSFiddle demo app.
Definitely! All you need is the "artist_id" and the SpotifyPublicAPI can return a list of the related artists. You don't need an access_token at all.
You can easily test the API call here on RapidAPI. I've specifically linked you to the getArtistsRelatedArtists endpoint. Rapid will provide you with a code snippet you can copy and paste directly into your code to make the call.
Here is an example testing the API call using Beyonce's artist_id:
Here is a sample code snippet provided by RapidAPI wth Beyonce's artist_id passed as a parameter:

How to detect if a query string is relevant for a Google Map Static API lookup

I am currently developing a web app that uses Google's Static Map API, in order to display maps of places upon user's request.
My problem is the following: How can I detect if a given string is relevant or not to searching Google Maps ?
Examples:
Searching for "North Beach San Francisco" with the following URL returns a relevant map of what is asked.
http://maps.google.com/maps/api/staticmap?size=270x185&maptype=roadmap&sensor=false&markers=north%20beach%20san%20francisco
However, searching for something that is not an address like Orwell's "1984" with the following URL does also return a map but it is absolutely not relevant to the query.
http://maps.google.com/maps/api/staticmap?size=270x185&maptype=roadmap&sensor=false&markers=1984
My point is, I don't need to parse the query since Google Maps Static API can find an address pretty easily, but I need to know if the string the user submitted should be searched in Maps or just regular search.
There is a lot of address-parsing related questions on SO, but I repeat that I don't want to have a full address parsing process, I just want to know if Google would have displayed a map link if I had searched the same thing on their website.
I do know the Google Geocoding API but it's roughly the same, as it will return coordinates even for unadapted queries like "1984". (And I'm not even talking about the limitations that make it pretty impossible to use in a large-scale web application)
Thank you for your time !
Gael
What I eventually did:
Google Geocoding API has a response parameter that indicates the accuracy of the geocoding lookup. Using this parameter, I was able to determine if my query is a real address or just a standard query looking like an address.
Keep in mind that both Geocoding Service and Javascript Geocoding API have limitations (as of now, 2,500 requests per IP per day)
Do post a comment if you want further information about that !