I ♥ NASA. You ♥ NASA. We all ♥ NASA.
So how can I use the images and things they expose in their APIs in Mathematica?
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityI ♥ NASA. You ♥ NASA. We all ♥ NASA.
So how can I use the images and things they expose in their APIs in Mathematica?
I built a ServiceConnect
paclet for this (details on how I did this can be found at the end of this post).
You can access it like so:
PacletInstall[
"ServiceConnection_NASA",
"Site"->
"http://www.wolframcloud.com/objects/b3m2a1.paclets/PacletServer"
]
(note that unless you have BTools installed and have loaded the PacletTools package (e.g. by just calling PacletUpload
raw to get the autoloader to run) you won't get this formatted form)
Then just connect and have at it!
$so = ServiceConnect["NASA"]
$so["PictureOfTheDay"]["Image"]
$so["EarthImages",
"Date" -> Today - Quantity[1, "Weeks"],
"ImportImages" -> True,
"ImportSelection" -> ;; 3
][All, {"Image", "caption"}]
$so["MarsImages",
"earth_date" -> Today, "ImportImages" -> True,
"ImportSelection" -> {1}
][2]
You can get the currently supported requests like so:
$so["Requests"]
{"APIKey", "Authentication", "EarthImages", "ID", \
"ImportEarthImages", "Information", "LandsatAssets", "LandsatImages", \
"MarsImage", "MarsRoverData", "Name", "NeoFeed", "NeoLookup", \
"Patents", "PictureOfTheDay", "RawRequests", "RequestData", \
"RequestParameters", "RoverCameras"}
And you can figure out what to pass to each using the "RequestParameters"
like so:
$so["RequestParameters", "Request" -> "Patents"]
<|"Parameters" -> {"api_key", "query", "concept_tags", "limit"},
"Required" -> {}|>
$so["Patents"]["results", 1, "title"]
"Selective functionalization of carbon nanotubes based upon distance \
traveled"
If you want me to implement more requests I can easily do so
I built this according to the process laid out in my answer to the question Creating a custom web API ServiceConnection.
The actual construction notebook can be obtained here so you can see what went into building it.
Essentially, I just have a template notebook that you fill out and which formats a call to the CustomServiceConnection
function in my BTools package.
ServiceConnections
$\endgroup$