The Wix Data APIs support a wide range of data types, including numbers, plain and rich text, arrays, URLs, media files, and more. The APIs accept and return data in JSON format, so it’s important to understand the structure and formatting specific to each data type. To ensure data consistency and minimize potential errors, follow these formats when querying, inserting, and updating items in a collection.
Wix Data works with a schemaless database behind the scenes. In theory, you can store any type of data in any database collection field. In practice, however, it's best to conform to each collection’s schema as defined either in the Content Management System (CMS) or when using the Data Collections API. The schema is used to determine which page elements can connect to which fields and to provide a better experience for site admins when using the CMS. For example, if a field's type is set to Date and Time, its values will appear as dates in the CMS. Site admins can then connect that field to site elements that work with dates.
The following table lists supported field types along with their corresponding data type and format.
Field Type | Data Type | Format |
---|---|---|
Address | Object | An Address object. See the Address Object's structure structure. |
Array | Array | |
Audio | String | A web URL or a Media Manager URL. Learn more about working with media files. |
Boolean | Boolean | true or false |
Date | String | A date string in ISO 8601 date format: YYYY-MM-DD . |
Date and Time | Object | An object in the following format: "someFieldKey": { "$date": "YYYY-MM-DDTHH:mm:ss.sssZ"} Note: Milliseconds can be omitted: "$date": "YYYY-MM-DDTHH:mm:ss" |
Document | String | A web URL or a Media Manager URL. Learn more about working with media files. |
Image | String | A web URL or a Media Manager URL. Learn more about working with media files. |
Media Gallery | Array of image and video URLs | Array items are either web URLs or Media Manager URLs. Learn more about working with media files. |
Number | Number | |
Object | Object | |
Rich Text | String | A string that may contain a subset of HTML tags. |
Single Reference/ Multi- Reference | Single Reference: String/ object Multi-reference: Array of strings/ array of objects | An item ID or multiple item IDs from the referenced collection. See Query Referenced Data Items to learn about item references. |
Tags | Array of strings | |
Text | String | |
Time | String | A string in hh:mm:ss.SSS format. |
URL | String | A valid URL. |
Video | String | A web URL or a Media Manager URL. Learn more about working with media files. |
With the Wix Data APIs, you can manage media items of any supported type. Items can be stored on an external service, or directly on Wix using the Wix Media Manager. Learn more about which data types are supported in the Media Manager.
To learn about uploading files to the Media Manager, see the Upload API and the Resumable Upload API. To learn how media items are stored in the Media Manager, see the List Files and Get File Descriptors endpoints.
Address objects have the following structure:
Name | Type | Description |
---|---|---|
formatted | String | Address in human-readable format. |
location | Object | Address coordinates |
location.latitude | Number | Address latitude |
location.longitude | Number | Address longitude |
streetAddress | Object | Address street name and number |
streetAddress.name | String | Street name |
streetAddress.number | Number | Street number |
city | String | Address city |
subdivision | String | Address subdivision of a country, such as a state or province |
country | String | Address country |
postalCode | String | Address postal code |