Warning:
Wix Data APIs currently require the site's code editor (Dev mode) to be enabled. For this reason, we recommend against using these APIs for building Wix CLI apps and self-hosted apps, as the apps may be installed on sites where Dev mode isn't enabled. For Headless development, you can use the APIs without any restrictions.
The Wix Data APIs provide a complete solution for accessing, organizing, configuring, and managing data stored in a Wix site's database.
Wix Data APIs include:
- Data items: Access, manage, and perform aggregations on data items stored in a site's existing data collections.
- Collection management: Create and configure data collections, manage access permissions, and organize a site's data structure.
- Operations: Manage background processes and maintenance tasks for a site's data.
- External databases: Connect external databases to a Wix site, allowing you to manage and query external data as if it were stored in native Wix collections.
It's important to note the following points before starting to code:
- A Wix site's database can hold up to 1,000 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 methods such as Query Data Items or Get Data Item 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.
- To speed up data retrieval, the results of certain data queries are cached. Learn more about caching data query results.
- When a site makes a data request, it may take some time to receive a response. Wix Data places limits on how long a response can take before the request times out. If the response time exceeds this limit, Wix Data returns an error instead of the intended result.
- After connecting external database collections to a Wix 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.
When calling a Wix Data method, it may take some time to receive a response. Wix Data places limits on how long a response can take before your request times out. If the response time exceeds this limit, Wix Data returns an error instead of the intended result.
Request timeouts vary depending on the Wix user's Wix plan and the type of collection accessed:
Access to a data collection is controlled by its permissions. These permissions are defined in the collection object and they specify which types of user can perform actions on the data contained in the collection.
Wix Data recognizes 4 roles:
ADMIN: A site owner.
SITE_MEMBER_AUTHOR: A signed-in user who has added content to the collection.
SITE MEMBER: Any signed-in user.
ANYONE: Any site visitor.
For each of the 4 basic actions (inserting, updating, removing, and reading content) the minimal role required must be set. For example, if you want to allow only site members to view data, and only a site owner to insert, update, and remove data, declare permissions as follows:
insert: ADMIN
update: ADMIN
remove: ADMIN
read: SITE_MEMBER
- Backup: A full copy of the live content contained in a Wix site's collections.
- Data collection: A schema determining the structure of data items to store, 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.
- Data movement job: A process that moves data to and from a Wix site.
- External database connection: An adaptor that translates Wix data requests from a Wix site or app into an external database's protocol, and translates the response back into a format that Wix APIs can read. This enables Wix APIs, apps, and sites to treat the external database exactly as if it was an internal data collection.
- External database service provider: A 3rd-party service that implements an interface to allow Wix Data to interact with an external database.
- Index: A map of a collection's data, organized according to selected fields. Use indexes to increase query speed, and in some cases, to enforce unique values.