About the External Database Connections API

The External Database Connections API enables you to connect an external database to a Wix project or site.

Internal vs. external databases

Wix provides a comprehensive platform with integrated database capabilities. You can use the Data Collections API to create, modify, and delete data collections in a Wix project or site, and you can use the Data Items API to access and manage data within those collections.

Wix's database capabilities cover a wide range of use cases for apps that need to store data. However, certain projects have very specific requirements that make it necessary to use an external database. For example, you may need to access existing data that is already stored on an external service, or you may need your data to be stored in a relational database.

Once the connection between an external database and a Wix project or site is established, you can access the collection using Wix Data APIs, including the Data Items API, in the same way you would with a native collection. You can also access the collection through the Content Management System(CMS).

For more information on connecting external databases with a Wix site, see Integrating External Databases with Your Wix Site.

Preparing an external database

Before the External Database Connections API can connect a Wix project or site with an external database, you need to prepare the external database by creating an external database adaptor.

An external database adaptor is a server 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.

If your database is hosted on one of the major cloud platforms, you can consult one of our tutorials for instructions on how to deploy an external database adaptor.

Otherwise, for details on the required specifications for an external database adaptor, see the External Database Collections SPI.

Ensuring read-write access

If you want to enable read-write access to your external database using the Data Items API, ensure your external database's table or schema includes the following fields:

  • _id
  • _createdDate
  • _updatedDate
  • _owner If these fields are absent, access to the external database is read-only. You may prefer this option for data that your app only needs to retrieve and doesn't need to manage.

Supported databases

The External Database Connections API works with several kinds of databases. For a full list, see Supported Databases.

Was this helpful?
Yes
No

Setup

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

Copy
1
npm install @wix/data

or

Copy
1
yarn add @wix/data

Then import { externalDatabaseConnections } from @wix/data:

Copy
1
import { externalDatabaseConnections } from '@wix/data'
Was this helpful?
Yes
No

createExternalDatabaseConnection( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Creates a new external database connection.

The externalDatabaseConnection parameter must include a name, endpoint, and configuration details for the external database. If any of these are missing, the external database connection isn't created.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage External Database Connections
Learn more about permission scopes.
Copy
function createExternalDatabaseConnection(externalDatabaseConnection: ExternalDatabaseConnection, options: CreateExternalDatabaseConnectionOptions): Promise<ExternalDatabaseConnection>
Method Parameters
externalDatabaseConnectionExternalDatabaseConnectionRequired
External database connection details.

optionsCreateExternalDatabaseConnectionOptionsRequired
Options for creating an external database connection.
Returns
Return Type:Promise<ExternalDatabaseConnection>
Was this helpful?
Yes
No

deleteExternalDatabaseConnection( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Deletes an external database connection.

Note: Once an external database connection is deleted, it can't be restored. To reconnect the database you need to create a new external database connection.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage External Database Connections
Learn more about permission scopes.
Copy
function deleteExternalDatabaseConnection(name: string): Promise<void>
Method Parameters
namestringRequired
Name of the external database connection to delete.
Returns
Return Type:Promise<void>
Was this helpful?
Yes
No

getExternalDatabaseConnection( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Retrieves an external database connection by name.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage External Database Connections
Learn more about permission scopes.
Copy
function getExternalDatabaseConnection(name: string): Promise<ExternalDatabaseConnection>
Method Parameters
namestringRequired
Name of the external database connection to retrieve.
Returns
Return Type:Promise<ExternalDatabaseConnection>
Was this helpful?
Yes
No

listExternalDatabaseConnections( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Retrieves a list of all external database collections associated with the site or project.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage External Database Connections
Learn more about permission scopes.
Copy
function listExternalDatabaseConnections(options: ListExternalDatabaseConnectionsOptions): Promise<ListExternalDatabaseConnectionsResponse>
Method Parameters
optionsListExternalDatabaseConnectionsOptions
Returns
Return Type:Promise<ListExternalDatabaseConnectionsResponse>
Was this helpful?
Yes
No

updateExternalDatabaseConnection( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Updates an external database connection.

An external database collection name must be provided in name. If an existing external database connection is found with the same name, that connection's details are updated. If no external database connection has that name, the request fails.

Note: After an external database connection is updated, it only contains the values provided in the request. All previous values are lost.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage External Database Connections
Learn more about permission scopes.
Copy
function updateExternalDatabaseConnection(name: string, externalDatabaseConnection: UpdateExternalDatabaseConnection): Promise<ExternalDatabaseConnection>
Method Parameters
namestringRequired
Name of the external database connection. An external database connection may connect to one or more external data collections or tables. These are represented as connectionName/dataCollectionId.

externalDatabaseConnectionUpdateExternalDatabaseConnectionRequired
Updated external database connection details. The existing connection is replaced with this version.
Returns
Return Type:Promise<ExternalDatabaseConnection>
Was this helpful?
Yes
No