---
updatedAt: 2025-07-15T08:38:10.000Z
agentTools:
  projectIndex: https://docs.appery.io/llms.txt
---

# Using Appery Backend APIs in an App

Connecting to API backend from the app.

# Introduction

Every mobile app has a backend or a server which it connects to. The app uses APIs to connect to this backend to view, edit, and store data. The [Appery.io](https://appery.io/) platform provides a complete [backend](https://appery.io/backendservices/) or MBaaS (mobile backend as a service) for your app.

This page explains how to create and connect to an API backend, including 3rd party REST APIs.

# *Backend* Services

The [Appery.io](https://appery.io) platform provides the following [backend services](https://appery.io/backendservices/) for your app:

* **[Database](https://docs.appery.io/docs/database-overview)**;
* **[Server Code](https://docs.appery.io/docs/servercode-overview)**;
* **[Push Notifications](https://docs.appery.io/docs/overview-pushnotifications)**;
* **[API Express;](https://docs.appery.io/docs/apiexpress-overview)**

Every service listed above is exposed via REST APIs and that's how the app connects/talks to the backend.

# Why Invoke *API* from the Server?

There are a number of benefits to invoking a 3rd party API from the server:

* Service *API key* or any other sensitive information is not exposed to the app.
* Easy to update the service, or change to different services without impacting the app. For example, you can reset the *API key* used without making any changes to the client. You can also switch the service provider without making any changes to the client.
* Apply logic to the response before sending it back to the app. For example, sorting data on the server before returning it to the app.
* Apply custom logic before and/or after the service invocation. For example, invoke two or more APIs, combine the response, and return it to the app.
* No cross-domain issues as the service is always invoked from the service.

## Importing *Backend API Services*

As all these services are part of a unified platform, you can quickly import any of these services inside the **[Visual App Builder](https://docs.appery.io/docs/apperyio-visual-builder)**.

> 🚧 Adding Push Notifications
>
> **[Push Notifications](https://docs.appery.io/docs/overview-pushnotifications)** are added to the app another way - via the **[EVENTS](https://docs.appery.io/docs/apperyio-visual-builder#events-tab)** tab.

You can import REST API services into your app easily regardless of what backend service you use: **[Database](https://docs.appery.io/docs/database-overview)**, **[Server Code](https://docs.appery.io/docs/servercode-overview)**, or **[API Express](https://docs.appery.io/docs/apiexpress-overview)**.\
No matter what app you are working with, to import a service inside the **[Visual App Builder](https://docs.appery.io/docs/apperyio-visual-builder)**, select **CREATE NEW** and select the service you want to import..

<Image title="2023-03-22_10-45-41.png" alt={210} align="center" width="smart" border={true} src="https://files.readme.io/df8520f-2023-03-22_10-45-41.png">
  Backend Services import menu.
</Image>

Watch this short video to learn how to import Backend Services APIs:

<Embed url="https://www.youtube.com/watch?v=csoRLsyHHKA" title="How to Import Backend Services APIs Into Your App" favicon="https://www.youtube.com/favicon.ico" image="https://i.ytimg.com/vi/csoRLsyHHKA/hqdefault.jpg" provider="youtube.com" href="https://www.youtube.com/watch?v=csoRLsyHHKA" html="%3Ciframe%20class%3D%22embedly-embed%22%20src%3D%22%2F%2Fcdn.embedly.com%2Fwidgets%2Fmedia.html%3Fsrc%3Dhttps%253A%252F%252Fwww.youtube.com%252Fembed%252FcsoRLsyHHKA%253Ffeature%253Doembed%26url%3Dhttp%253A%252F%252Fwww.youtube.com%252Fwatch%253Fv%253DcsoRLsyHHKA%26image%3Dhttps%253A%252F%252Fi.ytimg.com%252Fvi%252FcsoRLsyHHKA%252Fhqdefault.jpg%26key%3D02466f963b9b4bb8845a05b53d3235d7%26type%3Dtext%252Fhtml%26schema%3Dyoutube%22%20width%3D%22640%22%20height%3D%22480%22%20scrolling%3D%22no%22%20frameborder%3D%220%22%20allowfullscreen%3E%3C%2Fiframe%3E" />

## Testing Services

When importing the service double-check that the service was imported correctly. As the service is imported automatically you shouldn't need to make any changes. But it's always a good idea to test the service before importing it into the app. You should get the same output testing the corresponding service as you get when testing the app in work.

## Editing Services

If you need to modify the service, you can make changes to the service in the **[Visual App Builder](https://docs.appery.io/docs/apperyio-visual-builder)** or remove and re-import the services. The general recommendation is to re-import the service (after deleting them). This way you can go back to the backend services (**[Database](https://docs.appery.io/docs/database-overview)**, **[Server Code](https://docs.appery.io/docs/servercode-overview)**, or **[API Express;](https://docs.appery.io/docs/apiexpress-overview)**), make any changes to the service, and then re-import it. However, be careful with this option as any mappings you set for this service will be removed as well.

> ❗️ Deleting Service Used on a Page
>
> If you remove a service used on the page, all its mappings will be removed as well.

## Using Imported Service on Page

After a service is imported, you can add it and use it from a page. To learn how to do this, jump over to the **[Visual App Builder](https://docs.appery.io/docs/apperyio-visual-builder)** section:

* [Mapping in Ionic apps](https://docs.appery.io/docs/mapping).
* [Mapping in jQuery Mobile apps](https://docs.appery.io/docs/appbuilder-jqm-mapping).

The following sections cover each service type in more detail.

# Importing **API Express** Services (API Express projects)

After you create one or more APIs using [API Express](https://docs.appery.io/docs/apiexpress-overview), you can quickly and easily import (add) those services to your app.

> 👍 Testing services before using them in an app
>
> Before importing and using an [**API Express**](https://docs.appery.io/docs/apiexpress-overview) service in your app, we recommend that you test it in the [API Express dashboard](https://appery.io/apiexpress). After you make sure the service works correctly then start using the service in your app. This approach will save you time debugging and testing your app.

To import the **[API Express](https://docs.appery.io/docs/apiexpress-overview)** services:

1. Inside the **[App Builder](https://appery.io)**, click **CREATE NEW**.
2. In the **Backend Services** section, select **API Express Service**:

<Image align="center" className="border" width="30% " border={true} src="https://files.readme.io/4597f95-2023-03-22_10-46-57.png" />

3. In the next popup, select the **API Express** project from which you want to add services to.
4. After a project is selected you should see the same folder/service structure as in the **[API Express project](https://docs.appery.io/docs/apiexpress-project)**. Select one or more services or a folder to import. When you select a folder all services inside the folder will be checked and imported.
5. After you have selected what you need, click the **Import selected services** button:

<Image align="center" className="border" width="75% " border={true} src="https://files.readme.io/ef6ecb1-2023-03-22_10-48-43.png" />

6. The services that you selected will be imported under the **Services** folder inside the **[App Builder](https://appery.io)**:

<Image align="center" className="border" width="30% " border={true} src="https://files.readme.io/6f4ede9-2023-03-22_10-49-51.png" />

You can now test the service. To do it:

1. Select the service, then go to its **Test** tab.
2. Open the **Query String** tab and click **Test** to test the service. You should see the response in the **Response** section:

<Image align="center" className="border" border={true} src="https://files.readme.io/81f748c-2023-03-22_10-52-00.png" />

> 📘 Want to know more?
>
> You can also check out [this](https://docs.appery.io/docs/connecting-to-a-rest-api) step-by-step tutorial that shows how to connect to a 3rd party REST API using **[API Express](https://appery.io/apiexpress)** and make it work in an Ionic application.

## Importing Auto-generated *API Services*

If you want to auto-generate API services for a relational database, you need the **[API Express Generator](https://docs.appery.io/docs/appclient-using-with-api-express#api-express-generator)** extension to import the services into an app.

The **[API Express Generator](https://docs.appery.io/docs/appclient-using-with-api-express#api-express-generator)** extension is an extension that allows you to generate multiple REST API services for a database table. You can quickly generate the following REST APIs to work with the database:

* **Create** - to add a new record;
* **Find** - to find one or more records;
* **Get** - to retrieve a record;
* **Update** - to update an object;
* **Delete** - to delete a record.

With this extension, the services and JavaScript files are created automatically and can be used in the app as usual to perform **CRUD** operations.

1. Open an app, then click **CREATE NEW > Extensions > API Express Generator**.
2. You will see a domain selection screen. Keep the default **Appery.io** domain selected and click **Next**.
3. On the next screen, select the API Express project and click **Select**.
4. On the next screen, you will see the services inside this API Express project. Locate the service folder which you want to import and click the **generate** link for it:

<Image align="center" className="border" border={true} src="https://files.readme.io/c60d0b6-APIExpressGenerator.jpg" />

4. Enter a name under which the services will be imported in the **[App Builder](https://appery.io)** or keep the default value and click **Generate**.
5. Click **Save** and refresh the **[App Builder](https://appery.io)** browser page to see the newly generated services in the **Services** folder.

All the basic operations services, as well as the JavaScript, have been successfully generated.\
The **[API Express Generator](https://docs.appery.io/docs/appclient-using-with-api-express#api-express-generator)** has created an **AppClientSettings** service file with the data on the **domain** where the project is located and its **apiKey**.

Another way to locate the project API key is to go to **API Express > Project >[Settings](https://docs.appery.io/docs/apiexpress-project#settings)**.

> 🚧 Editing **API Express** Services
>
> If you edit the services in **[API Express](https://appery.io/apiexpress)**, you should regenerate the appropriate services inside the [Appery.io](https://appery.io) **[App Builder](https://docs.appery.io/docs/apperyio-visual-builder)**.

# Importing **Server Code** *Services*

After you create one or more **[Server Code scripts](https://docs.appery.io/docs/servercode-script)**, you can quickly and easily import (add) those services to your app.

> 👍 Tip: Testing services before using them in an app
>
> Before importing and using a **Server Code** service in your app, we recommend that you [test](https://docs.appery.io/docs/servercode-script#test) the [**Server Code** script](https://docs.appery.io/docs/servercode-script). After you make sure the service works correctly you can securely add the service to your app. This approach will save you time debugging and testing your app.

To import a **Server Code** service:

1. Inside the **[App Builder](https://appery.io)**, click **CREATE NEW**.
2. In the **Backend Services** section, select **Server Code**.
3. In the next popup, select the **Server Code** script you want to import the service for.
4. After you select the script, click the **Import selected services** button.
5. The service that you selected will be imported under the **Services** folder inside the **[App Builder](https://appery.io)**:

<Image align="center" className="border" width="30% " border={true} src="https://files.readme.io/4532e94-2023-03-30_12-26-43.png" />

You can now test the service:

<Image align="center" className="border" border={true} src="https://files.readme.io/cc1a809-2023-03-30_12-25-07.png" />

More details can be found in the [this](https://docs.appery.io/docs/quickstart-server-code-tutorial#importing-server-code-script) section.

> 📘 Ionic Quickstart Server Code Tutorial
>
> If you are new to **[Server Code](https://docs.appery.io/docs/servercode-overview)**, this [Ionic Quickstart Server Code Tutorial](https://docs.appery.io/docs/quickstart-server-code-tutorial) will help you start.

# Importing **Database** *Services*

After you created a database, you can quickly and easily import (add) services to work with the database to your app.

To import a database service:

1. Inside the **[App Builder](https://appery.io)**, click **CREATE NEW**.
2. In the **Backend Services** section, select **Database Service**:

<Image align="center" className="border" width="smart" border={true} src="https://files.readme.io/6c24f61-2022-12-16_12-15-28.png" />

3. In the next popup, select the database for which you want to import the services.
4. After you select the services, click the **Import selected services** button. (Check the next section for the explanation on the various services).
5. The service you selected will be imported under the **Services** folder inside the **[App Builder](https://appery.io)**:

<Image align="center" className="border" border={true} src="https://files.readme.io/567d35b-2022-12-16_12-14-41.png" />

You can now select the service to test it:

<Image align="center" className="border" border={true} src="https://files.readme.io/3a6a8a7-2022-12-16_12-19-05.png" />

You can also use it to create a new [datasource](https://docs.appery.io/docs/5-event-handling#defining-events-for-datasources):

<Image align="center" className="border" border={true} src="https://files.readme.io/e79fb65-2022-12-16_12-21-22.png" />

> 📘 Ionic Quickstart Database Tutorial
>
> If you are new to [Appery.io **Database**](https://docs.appery.io/docs/database-overview), this [Ionic Quickstart Database Tutorial](https://docs.appery.io/docs/quickstart-database-tutorial-ionic-5) will help you start.

## **Database** Service Types

In the import window, there are two groups of services you can import.

In the **Database user services** section, you can import the [services](https://docs.appery.io/reference#database-api-user) to work with the **[Users](https://docs.appery.io/docs/database-collections#users)** collection:

* **Login**;
* **Logout**;
* **Signup**;
* **Me**;
* **Update User**;
* **Delete User**;
* **User Queries**;
* **User Details**;
* **All Users**.

<Image align="center" className="border" width="50% " border={true} src="https://files.readme.io/5cdbaf1-Import_DB.jpg" />

In the **Database collection services** section, you can import the services for any custom collection and for the **[Files](https://docs.appery.io/docs/database-collections#files)** collection (\_*files*).

For a custom collection, you can import any of the [following services](https://docs.appery.io/reference#database-api-objects):

* **Create** - to create a new object;
* **Read** - to read one object;
* **Update** - to update an object;
* **Delete** - to delete an object;
* **List** - to list all objects in the collection;
* **Query** - to query (search) for objects;
* **Distinct** - to retrieve all distinct values;
* **Batch Update** - to perform batch update.

For the **[Files](https://docs.appery.io/docs/database-collections#files)** collection, you can import any of the [following services](https://docs.appery.io/reference#database-api-files):

* **Create** - to create a file;
* **Upload** - to upload a file;
* **Read** - to get the file (data);
* **Delete** - to remove the file;
* **List** - to retrieve a files list.

<Image align="center" className="border" width="50% " border={true} src="https://files.readme.io/88f77fe-Import_DB2.jpg" />

> 📘 Want to know more?
>
> Please check out [this](https://docs.appery.io/docs/adding-security-to-your-database) link to learn more about adding security to your [Appery.io](https://appery.io) **[Database](https://appery.io/database/)**.

## Using **Database** in App

The [Appery.io Database](https://docs.appery.io/docs/database-overview) is exposed via REST APIs, which you can import and then use in an app as described in the section above. Connecting to the database directly from the app works okay for very simple or small apps. For example, if your app only needs to load the entire list of objects and display them on a page.

If your app does more than just this (and that's most apps), we recommend using the following approach. Create a [**Server Code** script](https://docs.appery.io/docs/servercode-script) that will access the database. This allows writing any logic in the script which you don't have to do on the client. For example, you can:

* Sort the database results;
* Filter the database results;
* Query the database two or more times;
* Run any custom logic before or after querying the database.

We recommend this as invoking app logic is better on the server. This approach allows you to write as simple or as complicated logic using server-side JavaScript. After you developed the script, it's very simple to [test](https://docs.appery.io/docs/servercode-script#test) it. After the script is tested, use it in your app. If you need to make changes to the script, you can make changes without impacting the app.

You can check our detailed tutorial on working with [Appery.io](https://appery.io) Database and Server Code here: <https://docs.appery.io/docs/working-with-apperyio-database-and-server-code>.\
Here are two more examples that demonstrate the benefits of using **Server Code** to access the database:

* [Moving App Logic to the Server: How to Save and Query an Appery.io Database from Server Code Script](https://maxkatz.org/2016/06/03/moving-app-logic-to-the-server-how-to-save-and-query-an-appery-io-database-from-server-code-script/).
* [Moving App Logic to the Server: How to Query the Database From Appery.io Server Code Script ](https://maxkatz.org/2016/05/25/moving-app-logic-to-the-server-how-to-query-the-database-from-appery-io-server-code-script/)

In addition to accessing the database, you can also send **[Push Notifications](https://docs.appery.io/docs/overview-pushnotifications)** and invoke any 3rd party API from the [**Server Code** script](https://docs.appery.io/docs/servercode-script). For more details, please check [this ](https://blog.appery.io/2015/11/learn-how-to-send-a-push-notification-from-server-code-script-in-one-line-of-code/) post.