Datasets vs. Data API

There are 2 main approaches to working with data in your Wix site. You can either use datasets or the Data API. Understanding the strengths and use cases of each approach will help you choose the right tool for your specific needs.

Both approaches work with the same CMS collections and provide access to the same data. The key differences are in how you interact with that data and connect it to page elements.

Note: Data hooks work with both datasets and Data API operations, allowing you to add custom processing logic regardless of which approach you choose.

Datasets

Datasets are invisible page components that bridge your CMS data with visual elements like repeaters, forms, and input fields. They handle the connection automatically, providing a no-code solution that you can extend with low-code Dataset API customizations when needed.

Pros

  • No coding required: Connect data to page elements through the editor without writing any code.
  • Automatic data binding: Changes in connected elements are less likely to break data functionality.
  • Built-in features: Filtering, sorting, pagination, and form handling work out of the box.
  • Fast setup: Get data-driven pages running quickly with minimal configuration.
  • State management: Automatically tracks current items and pagination state.

Cons

  • Limited flexibility: Restricted to built-in functionality, editor configuration options, and the Dataset API.
  • Performance considerations: Not as many options for performance optimization tweaks.
  • Frontend only: Can't use for backend data operations.

When to use datasets

Choose datasets when you need:

  • Simple data display: Show collection items in repeaters, galleries, or lists.
  • Basic forms: Collect visitor input and save it to collections.
  • Standard filtering and sorting: Use built-in controls without custom logic.
  • Dynamic pages: Create template pages that automatically populate with different data.
  • Quick prototyping: Get a data-driven site running without coding.

Data API

The Data API gives you direct programmatic access to a site's collections. You write code to query, insert, update, and delete data, then manually connect that data to your page elements.

Tip: In addition to functionality for working with data items, the Data API also contains functionality for managing collections, indexes, and more.

Pros

  • Full control: Complete flexibility over data operations and business logic.
  • Better performance: More options to tweak performance optimizations.
  • Advanced queries: Complex filtering, aggregations, and field projection.
  • Backend execution: Run operations on the server for improved performance.
  • Bulk operations: Handle multiple items efficiently with dedicated bulk methods.

Cons

  • Coding required: Need to write code to handle all data operations.
  • No automatic binding: Must manually update page elements when data changes.
  • More complex setup: Takes longer to implement compared to datasets.
  • Manual UI updates: Higher probability of UI and data desynchronization.

When to use the Data API

Choose the Data API when you need:

  • Advanced queries: Use aggregations, complex filters, or custom search functionality.
  • Custom integrations: Connect with external systems or APIs.
  • Performance optimization: Handle large datasets or frequent operations efficiently.
  • Backend processing: Perform data operations on the backend.
  • Bulk operations: Process many items at once efficiently.

See also

Did this help?