Proper formatting for NASA API request URL - json

EDIT: NASA data can be accessed via the SODA API (see https://data.nasa.gov/developer), and the API referred to below seems to be deprecated.
I'm trying to use the NASA API (http://nasa.github.io/api-docs/#introduction) to pull information on NASA patents. The docs show what the JSON reponse should look like and list required parameters for the request, but I can't find any examples of a properly formed request URL. So far I have tried (with my API key):
https://api.nasa.gov/patents/optics?api_key=API_KEY
https://api.nasa.gov/patents/optics.json?api_key=API_KEY
I tested the API key out on an example GET request URL for a different data.gov agency and it returned a valid JSON response, but I've had no luck with the NASA requests.
Does anyone know the proper request format for NASA info from the data.gov API?

I think that there may be a be a better api to use that is actually on NASA's site here: https://data.nasa.gov/developer.
If you scroll down to "NASA Patents" you can see some documentation on how to use the api and a few sample requests to get you started, including how to filter on specific fields.

Reading the API documentation, it would seem that the category name (like optics in your example), should be passed a query parameter, not as part of URI as you are showing. I also don't see noted where they say they support https (of course I just skimmed the API). Try,
http://api.nasa.gov/patents?category=optics&api_key=API_KEY

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.

V2 documentation errors?

I am working on an application that will be using the V2 Box API and have noticed that for some calls the response I get from the API differs from the documentation.
How do you want me to handle what I find?
Do you want me to post these points as individual topics here?
Or is there another way to provide the feedback?
You can send any documentation errors you find to API[at]BOXdotCOM.

Google Map Result as XML or JSON

I have this url to view the nearest hospitals with the given coordinates.
http://maps.google.com/maps?q=hospitals+near+{lat},{long}
Is their a way to get the results in XML or JSON?
Thanks!
You have lots of options, starting here. IF you want a URL you can query and get back XML or JSON then go here.
Those are links directly to the Google APIs documentation. You have many options available including a JavaScript API as well as a web service that can retrieve JSON or XML.

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.