With the API Connect service, you can easily serve your APIs over a secure developer platform. Traditionally, developers prepare their APIs for a web service then implement or develop another service for serving APIs in a secure way. API Connect allows developers focus on APIs while it does the rest of the work. API connect can:
- Categorize APIs,
- Limit APIs with certain restrictions,
- Allow identifying different roles on APIs,
- Allow managing different web services together,
- Allow developers to version APIs,
- Give a graphical programming interface for manipulation,
- Create sample code examples for different languages and tools like cURL, Node.js, and Python.
- Create a Python web app with boilerplate code
- Use REST APIs over Python
- Serve your Python REST APIs with API Connect
- IBM Cloud account – sign up if you don’t have an account yet
- A provisioned API Connect instance
- A provisioned Python Web Starter instance
Assuming you have an IBM Cloud account setup, this guide should take around 30 mins to complete.
Creating Python Flask Web App Boilerplate
Let’s start our how-to with preparing example web application. We will use the Python Flask Web Starter boilerplate for that purpose. Open you IBM Cloud catalog and write python in the search bar. Select Python Flask Application. 1. Give it a name and create the application
Wait for the application to start and now you should have a python application up and running. See the application by clicking on Visit App URL or by going to
Once the application is open, you will see an example landing page like the one seen below:
You can also try some of the other APIs available by default in the boilerplate app. Navigate to:
https://<application-name>.mybluemix.net/api/people: Returns a templated list of people returned by the server.
https://<application-name>.mybluemix.net/api/people/person1: Returns back a string,
Hello person1, where
person1is a variable name you can pass to the server.
Set up API Connect Service
To create an API Connect service, go to the IBM Cloud catalog and search for API Connect, click the only result. When prompted to create the service, give it a name and go ahead with provisioning the service.
Configuring an API Connect endpoint
We now need to configure API Connect, let’s add a new API by launching the API Connect tool and selecting the Add button.
Select New API from the drop down menu.
Now fill in the API details, specifically, the Base Path should be
Once the new API has been created you should see a bunch of new configuration options on the left side menu bar.
Let’s select the Path option from the menu and add a new entry called
/api, with the same name and path.
Also, ensure that the security option is enabled, For this example we will enable the option to use an API key in the header.
Save any changes using the disk icon on the top right.
Now we head over to Assemble menu and click on the Play button.
In the tab that opens on the right, enter the application URL (ex.
https://<application-name>.mybluemix.net/api/people), set the method as
GET, and choose
No Cache for the Cache type.
Ensure the changes are saved. We’ve now completed the minimal amount of configuration necessary for API Connect.
Creating an API Connect product
Head back to Drafts section and select Products to setup a new API Connect product, which is a collection of endpoints.
Give the new product a name, such as
python-app and click Create product
Once created, head over to the API section in the left hand menu and add an API. Select the API we created in the previous step and select Apply.
Save any changes by clicking the disk icon.
We’ve now created our API Connect product, our last step is to publish our APIs.
Publish APIs to the web
Head over to the Dashboard and select Sandbox.
Under Products, find the product you created in the previous step.
Publish the product.
Congratulations!, you have published your first API with API Connect.
You can test your APIs but heading over to Drafts > APIs > Assemble and clicking on the Play button next to the search bar.
get /api operation, and then click the Invoke button.
This response should be the same as the response as earlier in our how-to.
You can also navigate to the developer portal by going Dashboard > Sandbox > Settings > Portal to view the link to invite collaborators.
With API connect you can connect various web services built in any language (such as Python) to your API Connect platform. With API connect, you can expose APIs, manage and track usage, all while ensuring your product is secure at the same time.
In this how-to, we just simply created one web service and binded it to API Connect. We covered how to:
- Create a basic Python flask app with IBM Cloud
- Create and publish APIs with API Connect