Learning Library

← Back to Library

Building an API on Microgateway

Key Points

  • The architecture consists of a cloud‑based API Management node (on Bluemix) that the developer accesses via a browser, which forwards calls to a locally‑run standalone microgateway that can then reach internal or external resources.
  • After logging into Bluemix, you create a new API (named “requote”), set it to HTTPS, define its output as HTML, and initially remove any security definitions for simplicity.
  • You add a single GET operation at the path **/requote** and configure an invoke that calls www.brainyquote.com, appending a search term via an environment‑variable query‑string placeholder.
  • Using the “Microgateway Apps” catalog, you create a new product called “requote,” associate the newly defined API with this product, and then save the configuration.
  • The tutorial assumes the microgateway is already installed on the developer’s workstation and that the Bluemix environment is pre‑configured to communicate with it.

Full Transcript

# Building an API on Microgateway **Source:** [https://www.youtube.com/watch?v=YKqxvTMCUQE](https://www.youtube.com/watch?v=YKqxvTMCUQE) **Duration:** 00:09:31 ## Summary - The architecture consists of a cloud‑based API Management node (on Bluemix) that the developer accesses via a browser, which forwards calls to a locally‑run standalone microgateway that can then reach internal or external resources. - After logging into Bluemix, you create a new API (named “requote”), set it to HTTPS, define its output as HTML, and initially remove any security definitions for simplicity. - You add a single GET operation at the path **/requote** and configure an invoke that calls www.brainyquote.com, appending a search term via an environment‑variable query‑string placeholder. - Using the “Microgateway Apps” catalog, you create a new product called “requote,” associate the newly defined API with this product, and then save the configuration. - The tutorial assumes the microgateway is already installed on the developer’s workstation and that the Bluemix environment is pre‑configured to communicate with it. ## Sections - [00:00:00](https://www.youtube.com/watch?v=YKqxvTMCUQE&t=0s) **Building a Microgateway API on Bluemix** - The passage outlines how to set up a micro‑gateway‑based API, describing the cloud‑hosted API management node, the local standalone gateway, and the step‑by‑step process for creating the API in the Bluemix dashboard. ## Full Transcript
0:01this video will show you how to 0:03construct an API that runs on the micro 0:10Gateway here is a visual representation 0:14of the architecture or topology that 0:17will be used for this 0:20course you'll see that the API 0:22management node at the very top is 0:25actually running on Blue miix in the 0:28cloud the API developer or in other 0:31words you is using a browser to access 0:35that API management 0:37node the API management node also 0:40connects to the API Gateway which in 0:43this particular case is the Standalone 0:47micro Gateway this Standalone micro 0:50Gateway will be running on the 0:52developers local 0:55machine once that Gateway is up and 0:58running it can then re reach out onto 1:00the network to any sorts of 1:03resources within the Enterprise or 1:06outside the Enterprise that you directed 1:09to get to note also that when it comes 1:14time to let other people or other 1:16developers know about your micro Gateway 1:20API you can use the developer portal we 1:24will not use that particular step for 1:27this 1:28course 1:30this course assumes that you have 1:33already installed the micro Gateway on 1:36the local developer workstation and that 1:39you have configured your Blu miix 1:42environment to communicate with the 1:45micro 1:46gateway to begin log in to your blue 1:49miix 1:53account from the 1:55dashboard click the menu icon and then 1:58select drafts 2:00once you arrive at drafts click on 2:04apis then click add and click create a 2:08new 2:10API give the new API a 2:13name in this particular case we're going 2:16to call it 2:17[Music] 2:19requote do not associate with any 2:22product and click 2:24add when the new API comes up you'll see 2:28that a number of configuration items are 2:31already set we will set the scheme as 2:40https this API will produce HTML 2:58output 3:10right now we're going to remove the 3:11security definition that can be added 3:14again later when we want 3:17it now we create a 3:23path and this will be the path that 3:26external people call to take advantage 3:29of the U API and this path we call slash 3:35requote the standard operation is a get 3:39and that will suffice for us we have 3:42nothing else to add to this relatively 3:44simple 3:46API now we click 3:49assemble now we click 3:57invoke and we give the invoke a a title 4:01in this particular case a brainy 4:06quote We Now set the 4:08URL that this invoke will invoke to go 4:13and get the resource information that 4:15this API 4:17represents in this particular case we 4:20are going out to 4:22www.brainyquote.com 4:25to get a hold of some brainy 4:28quotes 4:39in this case we are also going to 4:43append a search 4:46term that will be embedded in the 4:48request query 4:51string so we use 4:54this environment variable representation 4:57for query string 5:08scrolling down for the rest of the 5:10invoke configuration we see that we're 5:13not doing anything else beyond the 5:28defaults 5:32now we can actually click the test 5:35button and this will allow us to 5:40create a product first we select the 5:43micro Gateway apps catalog which is the 5:47catalog that points at our micro Gateway 5:50environment now we create a new product 5:54called 5:55requote and we go ahead and ass 5:59associate the API and create the 6:06product now notice that we haven't saved 6:09this yet so we go up and save it and 6:12when we do that the test environment 6:14notices that it's no longer saved 6:18correctly so we republish the 6:22product this sequence of events will 6:25happen every time you change the API and 6:28then want to go ahead and test 6:35it 6:36okay now we go back to our developer 6:41workstation we set our console level 6:45debugging to debug and we restart the 6:51Gateway the Gateway goes out to the API 6:55manager on Blu miix obtains the 6:58configuration for the new API which we 7:01can then now use Curl to actually invoke 7:05our first API is actually up and running 7:08and it 7:10works now let's have a look and see what 7:13we really saw happening here if we 7:16scroll back in the debug of the console 7:20we can see here where the invoke took 7:24advantage of our query string and went 7:26out and invoked brainy quote 7:30that is all very well and good with one 7:33problem all of the links and URLs 7:36embedded in the return from 7:38brainyquote.com 7:40point to brainyquote.com and not back to 7:44our 7:47API so let's fix the fact that we want 7:52all urls to point to our API and not to 7:57the back end so we use a JavaScript that 8:00does exactly 8:06that now we go back and retest our API 8:12we republish it because it has 8:20changed and we can reinvoke 8:26this first we have to get the micro gate 8:29way running on the developer workstation 8:31to pick up the changes from the micro 8:33Gateway API manager so we stop and 8:37restart the micro Gateway once 8:42again now we go over and run the uh curl 8:47command to invoke the 8:50API in this case we're looking for 8:52quotes from 8:54Shakespeare and when we look at the 8:56response from the AP 8:59now we see that the links have been 9:04replaced with our own links that point 9:08back to our own 9:11API this API is now 9:19ready thank you for watching this video 9:23be sure to visit the other two videos in 9:26this 9:28series and