Create a RESTful API in 5 minutes
Full Transcript of Video
In this video, I’ll create a Restful enterprise-level API and pull data from that API into a basic web application...all in just a few minutes.
Now, there are many ways to create an API, but in this video, I’ll be using the m-Power Development Platform to create REST web services. m-Power is a low-code development platform that builds all types of web applications as well as web services.
Let me quickly go over what we’re doing. I have customer data in a database. With m-Power I can build web applications that interact with this data. But instead, let’s suppose that customers or a third party developer want access to this data so they can build their own apps over it. In that case, I'll build web services using m-Power to create an API they can consume in their third-party apps.
I’ll be creating an API that consists of 3 different web services...which will provide access to basic customer data, order data, and support ticket data. To get started, I’ll login to m-Power
Now m-Power creates any type of web application, but in this case I’ll need to choose the web service template and give it a name.
Now, I need to choose which data I want to use in this web service. I’ll be using data from my customer orders database table. I’d like to make all of these fields available so I’ll select them all.
Now, I need to tell m-Power how to sort this data. I’ll sort it by customer number and order number and move on to the next step.
Okay, so I’m all done with the required steps. There are more options like filters and calculations, but I don’t need any of that this time so let’s move on to the build step.
Here, I’ll just click build and wait while m-Power puts my web service together. One important point is that the build process for web services is exactly the same as any other web application I’d create with m-Power. It’s all point and click with no coding required.
Of course, the big difference between this and every other application is that this web service only returns data. If I’m creating a web app with m-Power, clicking this run button here would display a ready-to-use app. But...as you can see with a web service, it’s just data. But the nice part is that I can make this data available to third parties who can then do whatever they want with it.
Now, you’ll notice that I have order data for all of my customers listed here in this web service. If I’m exposing this data to my customers, I need to add some security so they only have access to their own data. Let’s do that now.
First things first, I’ll need to enable security. This means that users now need to sign in to use applications, and more importantly for this video--cannot access web services without authentication.
I also need to go back into my web service and add a row-level security object. Also referred to as multi-tenant security, this means that different users can access this web service but only see the data that they’re authorized to see. So in this case, when a customer accesses this web service API, they’ll only see their orders.
Once I add that, I’ll just need to rebuild. Once this is rebuilt, I’ll have a web service that securely exposes order data to my customers. Also, before the video I created two other web services -- one for basic customer data and one for support ticket data. I won’t walk you through those build processes since they’re exactly the same as what you just saw. But all together, these web services make up my API that I can then give to my customers.
Now, I could end the video here since I have 3 web services available in this API. But, for the sake of making this a complete demo, I want to show you that they work. So, I’ll switch over to the customer side of things and show you how easily they can consume this data from my API.
First though, I need to add an authentication method for this customer. I can secure web services using basic authentication, bearer tokens, or API keys. In this video, I’ll use an API key. I’ll make a new user for one of my customers --let’s say...glenwood industries--and then generate an API key. I’ll need to copy this API key so I can use it to retrieve my web service data.
Okay, so now let’s pretend I’m a developer at Glenwood industries and I want to get our data from this API and display it in a web application.
First, let me paste my API key that I just generated in here. Next, I’ll copy the web service URL and place it here in my app. Then, I just need to pull this data into my app. Okay, so now this app has access to my web service. I’ll do the same thing for the other two web services that I created but will skip through it since it’s identical to what I just showed you. Now I just need to pull out whatever fields I want to display in my app. I’ll go up here and pull out whichever pieces of data I want to display. I just need to add the field names from my web service. I’m speeding through this process since it’s not the point of the video. Rather, I want to show you how easily you can expose your data with m-Power and then access that data in other applications. As you can see, it’s pretty easy. With minimal effort, I can pull this data out of my API and add it to a custom web app.
So, now that we’re done, let’s check it out. It’s pulling data from my web service into a very simple application. First, you can see that the security is working..because my API key is associated with my user and I have row-level security set up, m-Power knows which data to display. So, I can only see data for glenwood industries, which is what I want. I’ve pulled basic customer data and placed it up here. Over here you see my orders and on the right we have our support tickets. Now this is very basic and is just made to show you how easily I can get data from my recently created API. Of course, from a customer perspective, I can add as many features as I want to this or really do anything I want with this data.
So, that wraps it up. In just a few minutes I created a web service API in m-Power and then pulled that data into an outside web application...and even setup security. If you’d like to learn more about m-Power or set up a demo, visit us on the web at mrc-productivity.com. Thanks for watching.
Learn how m-Power can help you
Sign up for a free trial
Sort videos by category using the options below