How to use the Washington, DC Metro API - json

I've been researching how I can take the transit info API that The Washington DC Metro Rail offers, and display it as HTML.
The documentation is on their website, but It does not include many examples. The only instructions I've found is to use one of three URLs.
I have figured out how to see the information using the below code. The problem is that the URLs below are generating all data as text only in my browser. I cannot figure out how to display selected data as HTML.
from their site:
Each method has 2 endpoints: REST and JSON.
URL (REST) example:
api.wmata.com/StationPrediction.svc/GetPrediction/A10?api_key=YOUR_API_KEY
URL (JSON) example:
api.wmata.com/StationPrediction.svc/json/GetPrediction/A10?api_key=YOUR_API_KEY
Additionally, developers can use JSONP if desired by adding a
"callback" parameter to the JSON call:
http://[url to JSON service]?api_key=[your_key]&callback=[name of
callback]
When using JSONP make sure that [name of callback] in the URL
displayed above is the name of a Javascript function needed to process
the JSON data.
Can anyone point me in the right direction for a tutorial or best way to get started?
Thanks!

You should try the WMATA interactive documentation.
http://developer.wmata.com/io-docs
If you've already registered for a key, just sign in, and your API key will be automatically populated into the interactive docs. The I/O Docs interface should help you easily navigate the resources/methods. If you have any other questions, feel free to ask here, and I can help you out.
I'm a platforms evangelist for Mashery, the company that helps WMATA/DC Metro manage their APIs.

Related

Vimeo player restful api documentation

I am looking at a dart library that hits a specific vimeo url...
https://player.vimeo.com/video/{videoId}/config
Hitting this url returns a json file with a lot of fields. I am trying to find any docs that give a description of all of these fields. I have been unable to do so at this point.
When I got to the Vimeo API reference, it refers to language specific apis like the python api or the javascript api, not the restful api (or at least the portion I am looking for).
Does anyone know how to find docs that refer to the json returned from the previously listed URL?
I think you want to go to the API reference docs:
https://developer.vimeo.com/api/reference/videos#search_videos
On that page you can scroll down and review the Response (there are three areas to click: Details, Example and Reference). You want reference.

Is it possible to avoid tolls in Google Maps URLs latest version?

In the old Maps URLs API, you could add "&dirflg=dt" in the URL.
Here's an example URL using the new API taken from Google's official pages here:
https://www.google.com/maps/dir/?api=1&origin=Google+Pyrmont+NSW&destination=QVB&destination_place_id=ChIJISz8NjyuEmsRFTQ9Iw7Ear8&travelmode=driving
In the Google official pages, I was unable to find anything related to sending it flags to avoid tolls so I'm not even sure if it is possible with the new API.
Does someone have any info to enlighten me with? Thanks for reading.
:)
This is not possible with the Maps URL in this version, but you can do this manually after loading the directions.
You can try this:
Load the URL. (eg.:
https://www.google.com/maps/dir/?api=1&origin=Google+Pyrmont+NSW&destination=QVB&destination_place_id=ChIJISz8NjyuEmsRFTQ9Iw7Ear8&travelmode=driving)
On the left part of the screen, click OPTIONS.
Under Avoid, check Tolls.
However, if you want this functionality to be in the parameters, you can send your ideas by going in the Maps URLs Documentation and click SEND FEEDBACK. Or you can submit this as a Feature Request in Google Issue Tracker
Hope this helps!
This is possible, but you have to use "undocumented" features.
Warning: Since these are not documented features, they probably aren't official and likely subject to change without notice. Use in production at your own risk.
tldr:
https://www.google.com/maps/dir/{origin}/{destination}/data=!4m3!4m2!2m1!2b1
Plug in origin and destination and it should load directions, avoiding toll roads.
Explanation:
Here, we are using Google's own data/options string (see: "data=") to get the desired functionality. It is meant to be used by the Google Map's web app itself to communicate options selected on the page. This article (and the ones following it) explain how to create your own "data=" strings to customize how the map is configured. It's quite comprehensive, but like I said above, its not an official feature.

Stored Map Like Google Maps or OpenLayers

Is Their anything like stored maps from where I can get Latitude/Longitude from address and vice versa. Like a database file or something else other than web based services so that I will not have to be connected over Internet while calculating address from Latitude/Longitude and Counter-wise.
Thank You
EDIT : Just to be clear. We use Google API's to find out Routes between two Geo-Locations I need the Same Feature.
Nominatim ? [1] It’s one of the source for the OSM home page.
Source code is on github [2].
1: http://wiki.openstreetmap.org/wiki/Nominatim
2: https://github.com/twain47/Nominatim
EDIT: I didn’t understand correctly. You can checkout OSRM : http://project-osrm.org/
Maybe you can check out Navit it is an open source offline routing and navigation application. They have a wiki over here which also explains a bit about routing.
I have not tried the application, but one of the features mentioned in the wiki is "adress and POI search".
There are several means of contact mentioned in their wiki as well, if you want to ask them about how they did.
You might also want to check out this list to find other interesting apps that provide offline map storage, routing and/or offline address search http://wiki.openstreetmap.org/wiki/Software/Desktop
This looks interesting as well: OSM Automated Navigation Directions.

When using the Google Places API, what is the difference between "using the JavaScript library" and "calling the API directly"?

I have seen the two forms of reference to the Google Places Library/Service, using JavaScript vs calling the API directly, a number of times, but I don't understand the difference. The Google Docs don't describe anything about two methods of accessing the API.
For example, this question talks about 2 ways of accessing the API: OVER_QUERY_LIMIT in a loop
And it appears that there is some type of direct web access taking place in this question: Querying Google Places API using jQuery
Is this something where there was an old way that involved formatting URL parameters and the new way is by utilizing the JavaScript library calls?
FINAL SUMMARY EDIT: There are two distinct ways of requesting data from Google, as described in #Dan Nissenbaum's answer below. And since my original question, the QUERY_LIMIT question referenced above has been edited to also include more information about the two options.
Perhaps you are referring to the distinction between the Google Places API that is intended for use on the SERVER (i.e., utilizing PHP to call the Google Places API directly), and using the completely different approach of the Google Places Javascript Library in which the BROWSER executes Javascript using the Javascript library provided by Google (that internally wraps calls to the Google Places API, so that you, as a Javascript programmer, only need to understand the Javascript library provided by Google, and use that)?
Here are the two scenarios.
Scenario #1: Use the API directly. For this method, you must refer to Google's API documentation for the Google Places API: https://developers.google.com/maps/documentation/places/.
Using this API works as follows (giving a simple example only). Say you want to retrieve places within 1000 meters of latitude=-27.2531166, longitude=138.8655664. You need to hit a URL as described by the API documentation: https://developers.google.com/maps/documentation/places/#PlaceSearchRequests.
In this example, the URL looks like this (it's long):
https://maps.googleapis.com/maps/api/place/search/json?location=-27.2531166,138.8655664&radius=1000&sensor=false&key=AddYourOwnKeyHere
You need a key for your personal use, which I assume you have. There are other options you can specify, such as limiting the results to restaurants, etc.
When you hit this URL, the data will be returned in either JSON, or XML format, as specified by the text json in the URL above (use the text xml for xml). This data is returned exactly like data is returned from any URL call when you hit a URL in your browser.
You can test this by simply typing the URL directly in your browser, and see the results.
To use the API directly from code, you will need to use code that hits the external URL above within code and retrieves the results within code (for example, using the PHP CURL library, or using AJAX in Javascript).
Scenario #2: You use the Javascript library that Google provides that wraps the API, so you don't need to deal with it. I'll update the answer with more details about this, if you don't know what this is.
The docs do discuss the two different approaches. The Places Library utilizes the Google Places services from within the JavaScript Google Maps API. If you are using the Google Maps API in a browser, this is probably the approach for you:
https://developers.google.com/maps/documentation/javascript/places
There is also a web service, which allows you to query directly from your application. You query it using direct http calls to Google services. If you need access to the data on your server or a mobile device, this is the approach you want to take:
https://developers.google.com/maps/documentation/places

Is it possible to get Google Maps Directions using HTTP requests?

Is it possible to use the Google Maps API router just using HTTP? Something like http://maps.google.com?from=blah?to=blah
And have it return some sort of XML or JSON representing the directions?
If you want Google to allow legal access to driving directions via HTTP you might consider voting for the enhancement request: Issue 235. Theoretically, the more people that vote for an enhancement request, the more attention Google give to it.
However, I strongly suspect that there might be contractual issues with the organisations that supply the data. Organisations like TeleAtlas impose restrictions about how Google can use their data. TeleAtlas probably don't want Google to make it legal for people to use their data to create apps for free that directly compete with their own commercial apps and devices.
There is no documented and approved method to access driving directions via an HTTP API request.
This makes it difficult to get driving directions on the server-side, which I assume is your intention.
Not only it is undocumented and difficult to achieve, but it would also violate the restrictions 10.1 and 10.5 of the Google Maps API Terms and Conditions.
However, if you don't mind the challenge, and you believe that rules are there to be broken, you may want to check these articles:
Calculate driving directions using PHP?
Retrieve driving directions from google maps with server-side HTTP calls and show results with static maps for WAP
Actually yes, and they do it themselves
The REST format is like:
http://maps.google.com/maps/nav?output=js&q=from:%20Montreal%20to:%20Toronto&key=apikey
Where q should have the form: "from: x to: y" (url encoded).
Some of the parameters are similar to the HTTP Geocoding service: http://code.google.com/apis/maps/documentation/geocoding/index.html
Mike
As of May, 2010, directions are available via web services:
http://code.google.com/apis/maps/documentation/directions/
Directions are returned in XML or JSON format:
http://maps.google.com/maps/api/directions/json?origin=Boston,MA&destination=Concord,MA&waypoints=Charlestown,MA|Lexington,MA&sensor=false
http://maps.google.com/maps/api/directions/xml?origin=Boston,MA&destination=Concord,MA&waypoints=Charlestown,MA|Lexington,MA&sensor=false
It's pretty danged easy to use.
Here you can find a list of parameters you can pass to the maps.google.com URL. Maybe you'll be able to get the information you need. I don't know what the returned output contains. At least you are able to define different output types.
I have already used this library with python and it works well, although it's against Google Maps API Terms.
API v3 (made the official version in the last six months), does:
http://code.google.com/apis/maps/documentation/directions/
Also note that most of the competing services (Bing Maps, Yahoo, MapQuest, CloudMade, etc) also support RESTful web services along these lines.
As always with these services, check the Terms & Conditions.
I've never used the API but it is pretty easy to get the structured directions data from a google maps page using JS to access the gmap page's DOM.