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

# 8. Setting up Server Code

This section provides the Server Code overview

# Introduction to **Server Code**

**[Server Code](https://appery.io/servercode)** allows writing custom app code using JavaScript that will run (execute) on the [Appery.io](https://appery.io) server. You write the logic inside a **Server Code** [script](https://docs.appery.io/docs/servercode-script). A script can be easily tested right inside the [**Server Code** dashboard](https://appery.io/servercode).

With [Appery.io](https://appery.io) **[Server Code](https://appery.io/servercode/)** option, you can:

* Create a new **[Server Code](https://appery.io/servercode/)** [script](https://docs.appery.io/docs/servercode-script) or [library](https://docs.appery.io/docs/servercode-libraries);
* View the list of existing [scripts](https://docs.appery.io/docs/servercode-script) and [libraries](https://docs.appery.io/docs/servercode-libraries);
* Open and edit a [script](https://docs.appery.io/docs/servercode-script) or [library](https://docs.appery.io/docs/servercode-libraries);
* View statistics and reports for any script or all scripts;
* Import a **[Server Code](https://appery.io/servercode)** [plugin](https://docs.appery.io/docs/servercode-plugins);
* Schedule a script to run periodically ([schedule a job](https://docs.appery.io/docs/servercode-scheduling-jobs)).

**[Server Code](https://appery.io/servercode)** allows writing any app logic.\
For example, in the script you can:

* Perform calculations;
* Connect to the [Appery.io](https://appery.io) **[Database](https://appery.io/database/)** to retrieve, update or create data;
* Send **[Push Notification](https://docs.appery.io/docs/overview-pushnotifications)** messages;
* Invoke any 3rd party REST API;
* And anything else you might need.

> 📘 Server Code Quickstart
>
> If you are new to [Appery.io](https://appery.io), this **[Ionic Quickstart Server Code Tutorial](https://docs.appery.io/docs/quickstart-server-code-tutorial)** can be a good place to start.\
> Also, you can check [this](https://docs.appery.io/docs/working-with-apperyio-database-and-server-code) document to learn more about how to work with [Appery.io](https://appery.io) **[Database](https://appery.io/database/)** and **[Server Code](https://appery.io/servercode)**.
>
> This video will provide you with more understanding of how you can benefit from using the **[Appery.io Server Code](https://docs.appery.io/docs/servercode-overview)** functionality:

<HTMLBlock>{`
<iframe width="615" height="315" src="https://www.youtube.com/embed/WAsPtU6ndpI" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
`}</HTMLBlock>

Complete [**Server Code** API](https://docs.appery.io/reference/server-code-api-overview).

# Dashboard

The [**Server Code** dashboard](https://appery.io/servercode/) has information about your scripts, libraries, and statistics.\
Working with server codes is organized under the **[Server Code](https://appery.io/servercode/)** tab, where the lists of [scripts](https://docs.appery.io/docs/servercode-script) (or [script folders](https://docs.appery.io/docs/servercode-script#organizing-server-code-scripts-in-folders)) and [libraries](https://docs.appery.io/docs/servercode-libraries) are organized in the left view:

<Image title="Screenshot_107.png" alt={1236} align="center" border={true} src="https://files.readme.io/e815944-Screenshot_107.png">
  Server Code dashboard
</Image>

You can click on the **Server Code** link in the **[App Builder Toolbar](https://docs.appery.io/docs/apperyio-visual-builder#toolbar)** to be redirected to the [Appery.io](https://appery.io) **Server Code** [console](https://appery.io/servercode/):

<Image align="center" className="border" border={true} src="https://files.readme.io/251f41b-small-2023-05-15_16-27-37.png" />

> 🚧
>
> The [**Server Code** page](https://appery.io/servercode) appears empty if your subscription expires (Subscription status: *“Your subscription has expired”*). To regain access, sign in any time and purchase a [paid plan](https://appery.io/pricing/) (or renew your suspended plan payment).

# *Scripts*

**[Server Code](https://appery.io/servercode)** uses JavaScript as the language to write the script logic. A script is where you write/develop your logic. You have access to almost all the standard JavaScript APIs.

**[Server Code](https://appery.io/servercode)** also provides the following APIs out-of-the-box:

* Console - to display debug information;
* Database - to access the  [Appery.io](https://appery.io) **[Database](https://appery.io/database/)**;
* Database user - to access the [*Users*](https://docs.appery.io/docs/database-collections#users) collection inside the database;
* Push Notification - to send [**Push Notification**](https://docs.appery.io/docs/overview-pushnotifications) messages;
* ScriptCall - for invoking another [**Server Code** script](https://docs.appery.io/docs/servercode-script);
* XMLHttpRequest - for invoking any 3rd party APIs;
* In Memory Data - a fast cache for storing short-lived data;
* Request - for working with input parameters into the [script](https://docs.appery.io/docs/servercode-script);
* Response - for setting up [script ](https://docs.appery.io/docs/servercode-script)response.

> 📘 Is Server Code the same as Node.js?
>
> Both **Server Code** and Node.js are based on Google V8 JavaScript engine, but Server Code doesn't run Node.js.

## Managing *Scripts*

When you open a [script ](https://docs.appery.io/docs/servercode-script)or create a new one, the [**Script** tab](https://docs.appery.io/docs/servercode-script#script-tab) opens. The [**API information**](https://docs.appery.io/docs/servercode-script#rest-api-information) block contains information about your script: **Service URL**, **Description URL**, and **Alias**:

<Image align="center" className="border" border={true} src="https://files.readme.io/68547da-Screenshot_126.png" />

You can turn off public access to this script by clicking the toggle under **Maintenance mode**. That means that all rest requests to the service URL will respond with a predefined maintenance message response.

While editing your script in the JavaScript editor under the **Edit** tab, you can use ***Autocomplete*** and ***Help*** hints.

The source code editor has other useful features. Check [this ](https://docs.appery.io/docs/servercode-script#script-editor) link to learn more.

### Creating *Scripts*

To create a new [script](https://docs.appery.io/docs/servercode-script), click the **Create script** button.

When a new [script](https://docs.appery.io/docs/servercode-script) opens, you can select the ***Load from file*** option to upload the previously saved or prepared script or use the predefined [*snippets*](https://docs.appery.io/docs/servercode-script#snippets) created by the [Appery.io](https://appery.io) team:

<Image align="center" className="border" border={true} src="https://files.readme.io/e3116f7-Screenshot_111.png" />

Every [**Server Code** snippet](https://docs.appery.io/docs/servercode-script#snippets) provides some out-of-the-box piece of code that you can quickly import into your script and start using it. It actually is a script plus any dependent [libraries](https://docs.appery.io/docs/servercode-libraries). Click **insert** to add it to the script code, name the script, and click **Save**:

<Image align="center" className="border" border={true} src="https://files.readme.io/8ae8be4-Screenshot_112.png" />

Now, the script is added to the **Scripts** list in your **[App Builder](https://idp.appery.io/idp/)** **[Server Code](https://appery.io/servercode/)** tab and you can select the ***Download*** option to save the script for future use.

### Organizing *Scripts* in Folders

You can also create folders to organize your scripts. Please read [here](https://docs.appery.io/docs/servercode-script#organizing-server-code-scripts-in-folders) for more details.

## Working with **Server Code** *Scripts*

When you select your script on the list in your [**App Builder**](https://docs.appery.io/docs/apperyio-visual-builder) **[Server Code](https://appery.io/servercode/)** tab, the following views appear where you can:

* **[Script](https://docs.appery.io/docs/servercode-script#script-tab)**: edit the script, load it from a file or download it;
* **[Trace](https://docs.appery.io/docs/servercode-script#trace-tab)**: see the trace information for the script;
* **[Statistics](https://docs.appery.io/docs/servercode-script#statistics-tab)**: view statistical information;
* **[Dependencies](https://docs.appery.io/docs/servercode-script#dependencies-tab)**: select the libraries your script depends on;
* **[Versions](https://docs.appery.io/docs/servercode-script#versions-tab)**: handle your script versions;
* **[Permissions](https://docs.appery.io/docs/servercode-script#permissions-tab)**: set and change access permissions;
* **[Settings](https://docs.appery.io/docs/servercode-script#settings-tab)**: choose the database for managing user access;
* **[Jobs](https://docs.appery.io/docs/servercode-scheduling-jobs)**: schedule your script jobs.

# Using in an App

Every [**Server Code** script](https://docs.appery.io/docs/servercode-script) has a REST API which you invoke from the app. Inside the [**App Builder**](https://docs.appery.io/docs/apperyio-visual-builder) , we offer a wizard to import (generate) the API for the script automatically. Go to [Using APIs in an App](https://docs.appery.io/docs/using-apis-in-an-app) to learn more.

> 📘 Good to Know
>
> To the app (or the outside world), a script is simply a REST API. Another way to look at it, **[Server Code](https://appery.io/servercode/)** allows you to create custom APIs very quickly.

# *Libraries*

**[Server Code](https://appery.io/servercode/)** provides a number of out-of-the-box libraries. A [library](https://docs.appery.io/docs/servercode-libraries) can be included in any script. This allows you to invoke any function from the \[library]\(**[Server Code](https://appery.io/servercode/)**).\
To create a new library, click the **Create library** button.\
You can also create custom libraries.

## Working with **Server Code** *Libraries*

You can also organize your [libraries](https://docs.appery.io/docs/servercode-libraries): under the **[Server Code](https://appery.io/servercode/)** tab, scroll down to the **Libraries** section, select the library, and click ***Load from file*** (to upload the previously saved or prepared [library](https://docs.appery.io/docs/servercode-libraries)) or ***Download*** (to save your **[Server Code](https://appery.io/servercode/)** [library](https://docs.appery.io/docs/servercode-libraries) for future use):

<Image align="center" className="border" border={true} src="https://files.readme.io/a62302e-Screenshot_114.png" />

# *Plugins*

A [**Server Code** *plugin*](https://docs.appery.io/docs/servercode-plugins) provides some out-of-the-box functionality that you can quickly import into your account and start using it. A [**Server Code** *plugin*](https://docs.appery.io/docs/servercode-plugins) is a script plus any dependent libraries.\
[**Server Code** *plugin*](https://docs.appery.io/docs/servercode-plugins)s are created by the [Appery.io](https://appery.io) team:

<Image align="center" className="border" border={true} src="https://files.readme.io/b2b3709-Screenshot_6.png" />

> 📘 Want to Know More?
>
> You can check out the following documents for more details about how to work with [Appery.io](https://appery.io)  [**Server Code** plugins](https://docs.appery.io/docs/servercode-plugins):
>
> * [EncodeBase64 and DecodeBase64 Server Code System Libraries](https://docs.appery.io/docs/encodebase64-and-decodebase64-server-code-system-libraries);
> * [Using SendGrid Plugin for Bulk Mailing](https://docs.appery.io/docs/using-sendgrid-plugin-for-bulk-mailing);
> * [Working with Mailgun Email Templates](https://docs.appery.io/docs/working-with-mailgun-email-templates).

# **Server Code** *Jobs*

A script can be scheduled to run periodically. Scheduling jobs is managed from under the **[Jobs](https://docs.appery.io/docs/servercode-scheduling-jobs)** tab:

<Image align="center" className="border" border={true} src="https://files.readme.io/a8cfe61-Screenshot_116.png" />

For example, you can schedule a script to run every 24 hours to check the database for inventory levels.

# *Statistics*

The [main **Server Code** page](https://appery.io/servercode/) also displays total script statistics:

<Image align="center" className="border" border={true} src="https://files.readme.io/af31eac-Screenshot_117.png" />

The following information about all your scripts is available:

* **Script size** - storage used by all scripts;
* **Execution count** - the total number of all calls to scripts;
* **Total calls** - the total number of all API calls to backend services.

> 📘 Note
>
> There are also statistics separately for each script when you open a script for editing.

> 👍 Need More Details?
>
> Below are the links with more details about the [Appery.io](https://appery.io) **[Database](https://docs.appery.io/docs/database-overview)**:
>
> **[Server Code Scripts](https://docs.appery.io/docs/servercode-script)**,\
> **[Server Code Plugins](https://docs.appery.io/docs/servercode-plugins)**,\
> **[Server Code  Jobs](https://docs.appery.io/docs/servercode-scheduling-jobs)**,\
> **[Server Code libraries](https://docs.appery.io/docs/servercode-libraries)**,\
> and\
> **[Server Code limits](https://docs.appery.io/docs/servercode-limits)**.