In this blog I will be showing how to expose the Nasa APOD (Astronomy Picture of the Day) REST API with SAP API Management and how to use this API with Appgyver to create a simple Astronomy Picture of the Day app. Quoting after the NASA API portal: One of the most popular websites at NASA is the Astronomy Picture of the Day. In fact, this website is one of the most popular websites across all federal agencies. It has the popular appeal of a Justin Bieber video. This endpoint structures the APOD imagery and associated metadata so that it can be repurposed for other applications. ... |
Pre-requisites:
Good to know:
|
The first thing is to acquire an API key to get access to the nasa apis at https://api.nasa.gov. Your API key is personal to you and linked to the email address you have used to obtain the key. Having this key you can start making web service requests. Simply pass the key in the URL when making a web request, for instance:
But wait, does it mean the key will need to be passed in the URL each time to make a web request? Actually, not great when it comes to using it from javascript....for instance in a Single Page Application (SPA). |
Create an API proxy using APIM (which is part of the SAP Integration Suite bundle). See appendix for further details. |
Create an appgyver project in composer and use the Nasa API from APIM to connect the dots... See appendix for further details. |
In a nutshell, Appgyver platform offers an automated build factory for your projects allowing you to build and distribute your apps to many targets at a time like to native iOS/and Android devices and/or have it as a static web app. |
For instance, if you opted for the latter choice you could be deploying your Appgyver-crafted web application to a HTML5 repository on SAP BTP CF: Deploy your AppGyver App to the HTML5 Applications Repository using CLI Plugin | SAP Blogs |
As already said, both APIM and Appgyver Composer/Platform are browser based. However, they both require some upfront learning and trialing. Especially when it comes to APIM if you wanted to implement OAuth2 or OAuth2SamlBearerAssertion security policies for instance. APIM offers an out-of-the-box integration with API Business Hub allowing you to explore the API packages and policies SAP and 3rd parties have shipped... Appgyver offers an integrated app build and distribution service. And indeed. There is no code but there are many screenshots.... |
https://api.nasa.gov
as API provider in APIM:<!-- Key/value pairs can be stored, retrieved, and deleted from named existing maps by configuring this policy by specifying PUT, GET, or DELETE operations -->
<!-- https://help.sap.com/viewer/66d066d903c2473f81ec33acfe2ccdb4/Cloud/en-US/b72dc3f262c1441587e76d0e808... -->
<!-- mapIdentifier refers to the name of the key value map -->
<KeyValueMapOperations mapIdentifier="NasaAPIKey" async="true" continueOnError="false" enabled="true" xmlns="http://www.sap.com/apimgmt">
<Get assignTo="private.sapapim.apiKey" index="1">
<Key><Parameter>api_key</Parameter></Key>
</Get>
<!-- the scope of the key value map. Valid values are environment, organization, apiproxy and policy -->
<Scope>environment</Scope>
</KeyValueMapOperations>
<!-- This policy can be used to create or modify the standard HTTP request and response messages
https://help.sap.com/viewer/66d066d903c2473f81ec33acfe2ccdb4/Cloud/en-US/523efe6d0a9d43beb5d62ad0793...
-->
<AssignMessage async="false" continueOnError="false" enabled="true" xmlns='http://www.sap.com/apimgmt'>
<Add>
<QueryParams>
<QueryParam name="api_key">{private.sapapim.apiKey}</QueryParam>
<!-- <QueryParam name="api_key"><api_key></QueryParam> -->
</QueryParams>
</Add>
<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
<AssignTo createNew="false" type="request">request</AssignTo>
</AssignMessage>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
31 | |
13 | |
12 | |
11 | |
10 | |
9 | |
7 | |
6 | |
6 | |
6 |