API Express: Expose SQL Databases with REST APIs

Posted: May 28th, 2015Author:

api_express_logo

Wondering how to access your SQL database from a mobile app? We’ve got the answer. API Express, recently released by Appery.io, can make your existing SQL database RESTful in minutes, allowing you to perform CRUD operations from any external source, whether it’s a mobile app or a web page.

Databases play an important role in a mobile development. They are the best way to securely store and easily manage app data. By using the SQL databases, developers can gain powerful database management systems. With help of DBMS, developers can perform database operations of varying complexity in a simple, convenient way. The challenge is when the database needs to be used externally from a mobile app. With the help of Appery.io API Express, you can quickly and securely expose your existing SQL database with a REST API. Find the list of supported databases here.

Connecting a SQL database with API Express

Integrating your database with API Express does not require any advanced skills. Its flow looks like the following:

  1. Creating a database connection. On this step you simply specifying your database type and name, host, port and user credentials.
  2. Creating an API Express project. Project contains different models and folders that are involved in URL generation.
  3. Creating a model. During creating a model, you can choose which database connection to use (you can use different databases), which table should be processed, and which CRUD operations should be turned on. You can test the model directly in API Express to see that integration is working.
  4. Creating a custom service. It’s an optional step, but if simple CRUD actions don’t fit your needs, you can create your own operation by adding any custom logic (built as SQL).
  5. Triggering REST URL. Once the database is connected and models are created, you’ll find the REST URLs by clicking “test” to the right of the appropriate model. That’s it.

test_model

You can give it a try by completing the step-by-step tutorial we’ve prepared. You can use your existing database in this tutorial, create a new one on your server, or use any 3-rd party service that allows you to create and maintain SQL databases. For example, we have another API Express tutorial, that shows how to create a PostgreSQL database on Amazon Web Services, integrate it into Appery.io via API Express, and perform CRUD actions from the mobile app built with Bootstrap & AngularJS Visual Builder. You can find this tutorial here.

Using API Express in an Appery.io mobile app

Because Appery.io has integrated backend services, API Express is tightly integrated into the Visual Builder too. This means that using the API Express together with the Appery.io Visual Builder is an extremely rapid way to build a mobile app with existing SQL databases.

Once you connect your database with API Express, you can use the API Express Generator Extension to create multiple REST services in a few clicks. Simply use the REST service name in your JavaScript code to trigger the needed service and handle the result via callbacks.
get_service

API Express offline mode

Another great feature of API Express is offline mode. Here is how it works:

  • Every request to the server is going to be reflected in the Cache.
  • When the client goes offline, all change-requests (POST, PUT, DELETE) to the server are going to be queued waiting to go online.
  • When the client goes online, the queue of deferred change-requests will be handled, and one after one, all the requests will be executed. All exceptions (in case of concurrent modification of the record) will be logged.

ClientSDK.JS

Appery.io uses clientsdk.js inside its core to manage all the API Express service operations (API Express Generator uses it). Offline mode supported via ClientSDK.JS too. There is a ClientSDK webpage page that you can use to test created database connections, user authentication, perform CRUD operations, and more, all in one place.

Try this tool when you need to simulate mobile app behavior without the need to create one. You can find some helpful tips for using it here, and don’t worry about its look – we will add some attractive styling soon!

You can find more details about the API Express on the documentation page. Please help us make this tool even more useful by giving your feedback.

 

sign_up_for_free_plan