Databases#

API version: v1alpha1

DoltHub provides API endpoints for creating, forking, and listing forks of a database.

Note: please send requests to https://www.dolthub.com, not https://dolthub.com.

Create database#

Here’s an example of how to create a new database called museum-collections under the organization dolthub using an authorization token.

Creating a database requires authentication, so you must include this authorization header in your request. See the Authentication section for more details.

headers = {
    'authorization': 'token [api token you created]'
}
POST /database

Create a new Dolt database

This API allows you to create a new Dolt database.

URL https://www.dolthub.com/api/v1alpha1/database
Request Body

Content-Type: application/json

FieldTypeRequiredDescription
descriptionstringNoA description of the database.
ownerNamestringYesThe name of the owner of the database.
repoNamestringYesThe name of the repository for the database.
visibilitystringYesThe visibility of the database (public or private).
Responses
200 Database created successfully.

Body — application/json

{
  "status": "Success",
  "description": "Records from museums around the world.",
  "repository_owner": "dolthub",
  "repository_name": "museum-collections",
  "visibility": "public"
}
FieldTypeDescription
statusstring
descriptionstring
repository_ownerstring
repository_namestring
visibilitystring
400 Bad request. The request was invalid or could not be processed.

Body — application/json

{
  "status": "Error",
  "message": "Error creating a database.",
  "description": "Records from museums around the world.",
  "repository_owner": "dolthub",
  "repository_name": "museum-collections",
  "visibility": "public"
}
FieldTypeDescription
statusstring
messagestring
descriptionstring
repository_ownerstring
repository_namestring
visibilitystring

Fork database#

Here’s an example of how to fork a database called dolthub/museum-collections to the username taylor using an authorization token. Note that the fork operation is asynchronous and creates an operation that can be polled to get the result.

To poll the operation and check its status, you can use the operationName in the returned response of the fork request to query the API. Once the operation is complete, the response will contain the new database owner and name.

Keep in mind that the time it takes for the fork operation to complete can vary depending on the size of the database.

Forking a database requires authentication, so you must include this authorization header in your request. See the Authentication section for more details.

headers = {
    'authorization': 'token [api token you created]'
}
POST /fork

Fork an existing Dolt database

This API allows you to fork an existing Dolt database.

URL https://www.dolthub.com/api/v1alpha1/fork
Request Body

Content-Type: application/json

FieldTypeRequiredDescription
parentOwnerNamestringNoThe name of the owner of the parent database.
parentDatabaseNamestringNoThe name of the parent database.
ownerNamestringNoThe name of the owner to fork to.
Responses
200 Success.

Body — application/json

{
  "status": "Success",
  "parent_owner": "dolthub",
  "parent_database": "museum-collections",
  "forked_owner": "myusername",
  "operation_name": "operations/b09a9221-9dcb-4a15-9ca8-a64656946f12"
}
FieldTypeDescription
statusstring
parent_ownerstring
parent_databasestring
forked_ownerstring
operation_namestring
400 Bad request. The request was invalid or could not be processed.

Body — application/json

{
  "status": "Error",
  "message": "Error creating a database.",
  "parent_owner": "dolthub",
  "parent_database": "museum-collections",
  "forked_owner": "myusername"
}
FieldTypeDescription
statusstring
messagestring
parent_ownerstring
parent_databasestring
forked_ownerstring

Then use GET to poll the operation to check if the fork operation is done.

GET /fork

Check fork operation status

Poll the operation to check if the fork operation is done

URL https://www.dolthub.com/api/v1alpha1/fork
Parameters
NameInTypeRequiredDescription
operationNamequerystringYesThe operation name to check Example: operations/b09a9221-9dcb-4a15-9ca8-a64656946f12
Responses
200 The status of the fork operation

Body — application/json

{
  "status": "Success",
  "done": true,
  "operation_name": "operations/jobs/b09a9221-9dcb-4a15-9ca8-a64656946f12",
  "database_owner": "myusername",
  "database_name": "museum-collections"
}
FieldTypeDescription
statusstringThe status of the operation, Success if the fork creation was successful
donebooleanTrue if the fork operation is done, false otherwise
operation_namestringThe operation name
database_ownerstringThe owner of the newly forked database
database_namestringThe name of the newly forked database
400 Bad request. The request was invalid or could not be processed.

Body — application/json

{
  "status": "Error",
  "message": "Error polling an operation status.",
  "operation_name": "operations/jobs/b09a9221-9dcb-4a15-9ca8-a64656946f12"
}
FieldTypeDescription
statusstring
messagestring
operation_namestring

List forks#

Here’s an example of how to list the databases within the fork network of a database called dolthub/museum-collections using an authorization token.

headers = {
    'authorization': 'token [api token you created]'
}
GET /{owner}/{database}/forks

List Forks

This API endpoint allows you to list all forks within the fork network of a database.

URL https://www.dolthub.com/api/v1alpha1/{owner}/{database}/forks
Parameters
NameInTypeRequiredDescription
ownerpathstringYesThe name of the owner of the database. Example: dolthub
databasepathstringYesThe name of the database. Example: museum-collections
Responses
200 Success

Body — application/json

{
  "status": "Success",
  "database_owner": "dolthub",
  "database_name": "museum-collections",
  "forks": [
    {
      "database_owner": "anotherOrg",
      "database_name": "museum-collections"
    }
  ],
  "parent_owner": "",
  "parent_database_name": "",
  "network_root_owner": "dolthub",
  "network_root_database_name": "museum-collections",
  "fork_network_count": 3
}
FieldTypeDescription
statusstringStatus of the request.
database_ownerstringOwner of the database.
database_namestringName of the database.
forksarray<object>List of forks within the fork network of this database.
parent_ownerstringOwner of the parent database, empty if this is the root.
parent_database_namestringName of the parent database, empty if this is the root.
network_root_ownerstringOwner of the root database in the fork network.
network_root_database_namestringName of the root database in the fork network.
fork_network_countintegerNumber of forks in the fork network (excluding the root).
400 Bad request. The request was invalid or could not be processed.

Body — application/json

{
  "status": "Error",
  "message": "Error getting the forks list.",
  "database_owner": "dolthub",
  "database_name": "with-archives"
}
FieldTypeDescription
statusstring
messagestring
database_ownerstringOwner of the database.
database_namestringName of the database.