Is accessing Realm or Atlas directly through the App Secure

I am creating a Kotlin App with MongoDB Atlas. I wanted to know if openeing Client connection directly from the App without API secure? Also, same for Realm Connections is it secure to directly use such as db.collection.find() without having an API ?

Thank you.

Hi, opening a client that connects directly to the database is not very secure or scalable.

  1. Connections to the DB are limited
  2. It limits your ability to have IP whitelists for clients that can connect to the database
  3. There is no ability to enforce document-level permissions

Realm is an ideal in-between for accessing your data in MongoDB from a Mobile Client. Most of the SDK’s have a remote mongodb client (

I am not certain if Kotlin has this as well yet, but if not, you can also just use the normal MongoDB driver and connect it to realm using the Wire Protocol:,Connection%20Strings,application-specific%20appName%20query%20parameter.&text=You%20must%20URL%20encode%20connection,to%20connect%20to%20MongoDB%20Realm.

Hope that this is helpful,

First of all thank you for the fast reply, So from my understanding. I should use Realm and not Atlas to access the database directly? However, i saw that i can combine Realm and Atlas? and there will be no need to make an Api ? right?

Thank You

Yes, that is what I mentioned above. You can use a MongoDB driver the same as you would when connecting to Atlas, but instead, connect to Realm which will then connect to Atlas. That will be more scalable than having every mobile device connect to Atlas (which has security concerns).

ok, one more question as far as i know there is Realm sync and without Sync. The one that will connect to Atlas is which one ?

Thank you for your help in advance

Realm Sync is a service that will seamlessly sync data between your mobile phone and Atlas so that you dont need to make any DB calls whatsoever.

There is also just Realm Cloud which exposes various methods (GraphQL, DataAPI, MongoDB API) to get data and query on Atlas and return the results to the SDK.

They are both helpful in different contexts so it depends on what you are trying to do.

I want to make an E-Commerce mobile application. I was using Data API Preview. However, when i was trying to do pagination using Paging Library 3 all the examples showed that you need to connect to database. Therefore, i thought of using Realm with Atlas? am i correct with this approach? or are their documents showing how i can integrate paging with MongoDB using Android?