To use the Data API, install the @wix/data package using npm or Yarn:

Copy Code
npm install @wix/data


Copy Code
yarn add @wix/data

Then import data from @wix/data:

Copy Code
import data from '@wix/data'
Was this helpful?

About the Wix Data API

The Wix Data API provides a complete solution for accessing, organizing, configuring, and managing data stored in a Wix project or site's database.

With the Wix Data API, you can:

  • Create, modify, and delete data collections.
  • Access, manage, and perform aggregations on data items stored in a project or site's existing data collections.
  • Create indexes for data collections, to speed up data queries.
  • Connect external databases to a Wix project or site.

Before you begin

It's important to note the following points before starting to code:

  • A Wix project or site's database can store up to 10 GB of data.
  • A Wix project or site's database can hold up to 1000 data collections.
  • The maximum size of an item you can save to a collection is 500 kb.
  • When naming fields in data collections, we recommend avoiding special characters. You can do this by using field names that match this regex pattern: [a-zA-Z_][a-zA-Z0-9_-]{0,63}.
  • Each data collection defines a schema of fields for the items it contains. However, this schema isn't enforced. This means that if you add or update an item containing a field or data type that doesn't match the collection's schema specification, your data is stored anyway.
  • When using data retrieval functions such as queryDataItems() or getDataItem() following an update to a collection's data, the data retrieved may not yet contain the most recent changes. See Wix Data and Eventual Consistency for more information and instructions for overriding this.
  • After connecting external database collections to a Wix project or site using the External Database Connections API, you can use the Data Items API to manage and retrieve data from those collections as if they were Wix Data collections.


  • Data collection: A schema determining the structure of data items to be stored, defining the fields each item should contain and the data type of each field.
  • Data item: A single data entry in a collection, in JSON format.
  • Index: A map of a collection's data, organized according to selected fields. An index is used to increase query speed, and in some cases, to enforce unique values.
  • External database connection: An adaptor that translates Wix data requests from a Wix project or site into an external database's protocol, and translates the response back into a format that Wix APIs can read. This enables Wix APIs, projects, and sites to treat the external database exactly as if it was an internal data collection.
Was this helpful?

Wix Data and Eventual Consistency

Wix Data stores your data in a primary database instance, as well as several geographically dispersed mirror instances. The Wix Data API is eventually consistent, meaning that it always updates your data in the primary database instance first, then propagates your changes to the mirror instances. When you update your database collection, there may be a short delay (typically a few seconds) until all mirror instances are up to date with your recent changes.

When you call a data retrieval function, such as queryDataItems() or getDataItem(), your request goes to the closest mirror database instance. This saves time, as the request and response don't have to travel as far. However, if you attempt to retrieve data shortly after updating it, your latest changes may not yet be reflected in the data you get back.

If you need a data retrieval function to get fully up-to-date data immediately after an update, you can set the consistentRead body parameter to true. This slows down the operation but ensures the data is retrieved from the up-to-date primary database instance.

Was this helpful?