Integrating Wix Data API with a Custom Mobile App for Dynamic Content

Hi everyone,

I’m working on a mobile app project that needs to dynamically fetch and display data from a Wix website. The goal is to leverage the Wix Data API to allow real-time updates between the mobile app and the website’s backend database.

Here’s what I’ve done so far:

  1. Set up a collection in Wix to store the dynamic data.
  2. Enabled API access through Wix’s Developer Tools.
  3. Used a backend API endpoint in Wix to fetch data from the collection.

Here’s an example of a Wix backend API function I’ve written:

javascript

CopyEdit

// backend/data.jsw  
import { query } from 'wix-data';  

export async function fetchData(collectionName) {  
  return query(collectionName)  
    .limit(100)  
    .find()  
    .then((results) => {  
      return results.items;  
    })  
    .catch((error) => {  
      console.error('Error fetching data:', error);  
      throw new Error('Unable to fetch data');  
    });  
}  

Now, I’m integrating this API with my mobile app using Axios:

javascript

CopyEdit

import axios from 'axios';  

const fetchWixData = async () => {  
  try {  
    const response = await axios.post('https://your-wix-site.com/_functions/fetchData', {  
      collectionName: 'yourCollection',  
    });  
    console.log(response.data);  
  } catch (error) {  
    console.error('Error fetching Wix data:', error);  
  }  
};  

fetchWixData();  

While the integration works, I’m facing challenges with:

  • Handling large datasets efficiently.
  • Implementing secure authentication for the API requests.
  • Real-time synchronization between Wix and the mobile app.

I came across mobile app development company that specialize in building seamless integrations for platforms like Wix, but I’d love to hear from the community:

Have you integrated Wix APIs with a mobile app before? How do you ensure security, scalability, and real-time updates in such setups? Any best practices or tools you recommend?

Thanks in advance for your insights!

Another approach. is to use Wix Headless

This is for eCommerce, but the approach would be similar for the CMS if you want to consider a headless solution. You would either use OAuth or API Key for authentication

Here is an example with CMS for a NextJS implementation Data Quick Start