About the Data API

The Data API provides comprehensive programmatic access to site data through a suite of backend modules. It enables you to perform CRUD operations, advanced queries, aggregations, and data management tasks directly in your code.

Modules

The Data API consists of several specialized modules, each handling different aspects of data management.

Some of the key modules include:

  • items: The primary interface for working with the actual data in your collections. Includes basic CRUD operations, bulk operations, advanced querying with filtering and sorting, and aggregations.
  • collections: Manage the structure and configuration of your data collections.
  • indexes: Optimize query performance by managing database indexes.
  • events and hooks: Run custom code before or after data operations. Note that events and hooks aren't contained in an SDK module. You create events and hooks using the conventions found in the Velo API reference.

For a full list of available modules, see the Data API documentation.

Permissions

The items module of the Data API uses the role-based permissions system of the CMS. The permissions determine which visitors can perform specific operations on collections. This system is in addition to the API-level identity authentication and focuses on data access control.

You can set permissions manually in the editor or programmatically through the collections module.

You can use elevation to override collection permissions or API-level identity authentication in backend code.

Eventual consistency

The Data API uses an eventually consistent data model for optimal global performance. The system stores data in a primary database instance and replicates it to geographically distributed mirror instances.

This means that immediately after updating data, subsequent queries might not reflect the latest changes if a mirror instance serves them before receiving the updates.

When you need guaranteed up-to-date data immediately after a change, you can bypass the limitations of eventual consistency and read directly from the primary database instance at the cost of possible decreased performance.

Learn more about eventual consistency.

Migrate from Velo

If you're migrating from the Velo wix-data module to the SDK Data API, the method names and basic functionality remain largely the same. However, there are some important changes to be aware of. For a complete migration guide, see Migrate from wix-data to the Data Items SDK.

See also

Did this help?