How to connect Firemonkey mobile app to a server

How to connect a mobile app built with Firemonkey to a remote server using BlockChain.API server

Posted by: Alex A. Publish date: 20.10.2021

Within the process of mobile app development, quite often there is a necessity to get data from a remote server and later process them. To solve this task, it is required to fulfill the following steps:

  • To get connected to a remote server via an API
  • To receive data in one of the available formats (usually it will be JSON or XML)
  • To process the received data
  • To present data in a human-readable format

In this series of posts we will show how to perform each step based on the example of a multi-device application written with the help of FMX, the BlockChain.API server and ready-made Embarcadero Delphi components.


Step 1. Connection to a remote server via an API

The connection to the BlockChain.API server will be executed via the REST technology that has become a standard for data exchange between an app and a remote server thanks to the fact that:

  1. client apps, regardless of their type (mobile, web, etc.) can use the same API for sending requests and getting information;
  2. REST allows standardizing the development of services and facilitates the work with them for developers of apps on a client’s side.

The client app sends a request to the server (usually it is a GET or POST request) and gets a response in a particular format. Quite often it will be JSON or XML.

JSON has a more simplified structure if we compare it with XML which can be seen in the table below.


Thanks to its structure, data sending and parsing for the JSON format are significantly faster than in the case of XML.

In our situation, we will send a GET request to the server.

For getting connected to the remote server and receiving data (via the GET request) we will use a standard non-visual component TNetHttpClient. It doesn’t require any settings for being used. It is necessary just to take it from the Component Palette and place it on the form.


For checking the working capacity and the correctness of formulating API commands, we can make a testing connection and send a request to the BlockChain.Api server in a web browser.

If everything is done correctly and the connection with the server has been successfully established, we can proceed to the next step and get the necessary data.

get the necessary data


Step 2. Pull data from the server

The response received from the server will be saved in the TMemoryStream object.

The response received from the server will be saved in the TMemoryStream object


The StreamToString function is used for getting text information from the TMemoryStream stream.

The StreamToString function is used for getting text information from the TMemoryStream stream
the TMemoryStream stream

Read about Data parsing & visualization in the next post.

Talk to us and get your project moving
Book a free consultation with a solution expert.
This field is required
Company web site
This field is required
Phone Number
This field is required

Subscribe to our newsletter and get amazing content right in your inbox.

You can unsubscribe from the newsletter at any time

This field is required
This field is required Invalid email address

You're almost there...

A confirmation was sent to your email

confirm your subscription, make sure to check
your promotions/spam folder