Is it safe to use Algolia directly from my Android and iOS app?

Hi all,

I am new in Algolia. I am actually an Android and iOS developer. so I have limited knowledge about backend. I make a query directly from my mobile app like this

        let client = Client(appID: "K7CCTL91111E", apiKey: "search key in here")
        let index = client.index(withName: "production_EVENTS")
        let query = Query(query: searchedKeyword)


        index.search(query, completionHandler: { (content, error) -> Void in

        })

I will not hardcode my search key, it will be fetched periodically from backend, so if something goes wrong I can change the search key

search key is read-only access, so malicious users can’t delete my documents in the index, but I am worried that will be a malicious unauthorized user that can expose the endpoint make millions of requests in short period of time and it will make my algolia account down.

so is it safe to fetch data directly from mobile app just like this ?

Hi there!
Yes, it is completely safe and the recommended way to do it.
If you are worried about users makeing too many queries, one solution could be to rate limit the API key per IP: see https://www.algolia.com/doc/guides/security/api-keys/in-depth/api-key-restrictions/#rate-limit