Pull Requests#

API version: v1alpha1

DoltHub provides API endpoints for creating, getting, updating, listing, commenting on, and merging pull requests on a database.

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

Create pull request#

Here is an example of opening a pull request on the museum-collections database with data from the Los Angeles County Museum of Art. This data was added to the lacma branch on a fork database, whose owner is liuliu, we would like to eventually merge lacma branch into the main branch using an authorization token.

Include this header in your request.

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

Create a new pull request

This API allows you to create a new pull request.

URL https://www.dolthub.com/api/v1alpha1/{owner}/{database}/pulls
Parameters
NameInTypeRequiredDescription
ownerpathstringYesThe name of the owner of the database. Example: dolthub
databasepathstringYesThe name of the database. Example: museum-collections
Request Body

Content-Type: application/json

FieldTypeRequiredDescription
titlestringNoThe title of the pull request.
descriptionstringNoThe description of the pull request.
fromBranchOwnerNamestringNoThe name of the owner of the source branch.
fromBranchRepoNamestringNoThe name of the database containing the source branch.
fromBranchNamestringNoThe name of the source branch.
toBranchOwnerNamestringNoThe name of the owner of the destination branch.
toBranchRepoNamestringNoThe name of the database containing the destination branch.
toBranchNamestringNoThe name of the destination branch.
Responses
200 Pull request created successfully.

Body — application/json

{
  "status": "Success",
  "title": "LACMA data",
  "description": "Records from the Los Angeles County of Museum.",
  "from_owner_name": "liuliu",
  "from_repository_name": "museum-collections",
  "from_branch_name": "lacma",
  "to_owner_name": "dolthub",
  "to_repository_name": "museum-collections",
  "to_branch_name": "main",
  "pull_id": "66"
}
FieldTypeDescription
statusstring
titlestringThe title of the pull request.
descriptionstringThe description of the pull request.
from_owner_namestringThe name of the owner of the source branch.
from_repository_namestringThe name of the database containing the source branch.
from_branch_namestringThe name of the source branch.
to_owner_namestringThe name of the owner of the destination branch.
to_repository_namestringThe name of the database containing the destination branch.
to_branch_namestringThe name of the destination branch.
pull_idstringThe id of the created pull request.
400 Bad request. The request was invalid or could not be processed.

Body — application/json

{
  "status": "Error",
  "message": "Error creating a pull request.",
  "title": "LACMA data",
  "description": "Records from the Los Angeles County of Museum.",
  "from_owner_name": "liuliu",
  "from_repository_name": "museum-collections",
  "from_branch_name": "lacma",
  "to_owner_name": "dolthub",
  "to_repository_name": "museum-collections",
  "to_branch_name": "main"
}
FieldTypeDescription
statusstring
messagestring
titlestringThe title of the pull request.
descriptionstringThe description of the pull request.
from_owner_namestringThe name of the owner of the source branch.
from_repository_namestringThe name of the database containing the source branch.
from_branch_namestringThe name of the source branch.
to_owner_namestringThe name of the owner of the destination branch.
to_repository_namestringThe name of the database containing the destination branch.
to_branch_namestringThe name of the destination branch.

Get pull request details#

This API allows you to retrieve the details of a specific pull request in the museum-collections database. In this example, we will retrieve the details of pull request #1.

Include this header in your request.

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

Get pull request by ID

Get information about a specific pull request.

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

Body — application/json

{
  "status": "Success",
  "database_owner": "dolthub",
  "database_name": "museum-collections",
  "pull_id": "1",
  "title:": "Added new data",
  "description:": "Added missing museums, sourced from museums.com",
  "state": "merged",
  "from_branch_owner": "liuliu",
  "from_branch_database": "museum-collections",
  "from_branch": "feature",
  "to_branch_owner": "dolthub",
  "to_branch_database": "museum-collections",
  "to_branch": "main",
  "created_at": "2023-07-01T18:00:00Z",
  "author": "liuliu"
}
FieldTypeDescription
statusstringStatus of the request
database_ownerstringOwner of the database
database_namestringDatabase name
pull_idstringPull request ID
title:stringTitle of the pull request
description:stringDescription of the pull request
statestringState of the pull request
from_branch_ownerstringOwner of database of the source branch.
from_branch_databasestringDatabase name of source branch.
from_branchstringName of the source branch.
to_branch_ownerstringOwner of database of the destination branch.
to_branch_databasestringDatabase name of destination branch.
to_branchstringName of the destination branch.
created_atstringTime at which the pull request was created
authorstringAuthor of the pull request
400 Bad request. The request was invalid or could not be processed.

Body — application/json

{
  "status": "Error",
  "message": "Error getting a pull request.",
  "database_owner": "dolthub",
  "database_name": "museum-collections",
  "pull_id": "1"
}
FieldTypeDescription
statusstring
messagestring
database_ownerstring
database_namestring
pull_idstring

Update a pull request#

This API allows you to update a pull request by providing the fields you want to update in the request body. You can update the title, description, and state (only closing a pull request is supported).

Here’s an example of how to update pull request #1 on the museum-collections database. In this example, we will set a new title, description, and close the pull request.

headers = {
    'authorization': 'token [api token you created]'
}
PATCH /{owner}/{database}/pulls/{pull_id}

Update Pull Request

Updates a pull request by ID, including its title, description, and sets its state to be 'closed'.

URL https://www.dolthub.com/api/v1alpha1/{owner}/{database}/pulls/{pull_id}
Parameters
NameInTypeRequiredDescription
ownerpathstringYesThe name of the database owner. Example: dolthub
databasepathstringYesThe name of the database. Example: museum-collections
pull_idpathstringYesID of the pull request to update. Example: 1
Request Body

Content-Type: application/json

FieldTypeRequiredDescription
titlestringNoThe updated title of the pull request.
descriptionstringNoThe updated description of the pull request.
statestringNoThe updated state of the pull request (can only update to 'closed')
Responses
200 Success

Body — application/json

{
  "status": "Success",
  "database_owner": "dolthub",
  "database_name": "museum-collections",
  "pull_id": "1",
  "title": "Added new data",
  "description": "Added new data from LACMA museum.",
  "state": "closed"
}
FieldTypeDescription
statusstringStatus of the request
database_ownerstringOwner of the database
database_namestringDatabase name
pull_idstringUpdated pull request ID
titlestringTitle of the pull request after update
descriptionstringDescription of the pull request after update
statestringState of the pull request after update
400 Bad request. The request was invalid or could not be processed.

Body — application/json

{
  "status": "Error",
  "message": "Error updating the pull request.",
  "database_owner": "dolthub",
  "database_name": "museum-collections",
  "pull_id": "1"
}
FieldTypeDescription
statusstring
messagestring
database_ownerstring
database_namestring
pull_idstring

List pull requests#

Here is an example of listing pull requests for the museum-collections database using an authorization token. The response of pull request list is paginated, so you need to use the next page token included in the response to retrieve the following pages of pull requests.

Include this header in your request.

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

List pull requests of a database

List pull requests

URL https://www.dolthub.com/api/v1alpha1/{owner}/{database}/pulls
Parameters
NameInTypeRequiredDescription
ownerpathstringYesThe name of the database owner. Example: dolthub
databasepathstringYesThe name of the database. Example: museum-collections
pageTokenquerystringNoThe pageToken to get the next page of results Example: AWE2Nm9uMWQ23FSQ7oRTbCXYTLLvNDhNs5hIFebQFI66FW-SYXGSlh3XcUQ8zmtLQ00QgD0X5FZr5ZTAhvT2FfRrGog7OuUno9wdTIXFQpkkX0opYoJL6Vrn2emlXkMBTiZYMqChyhR92_Yxd58B0w5nMrfXFf8v7xfAkN46hw
Responses
200 Success

Body — application/json

{
  "status": "Success",
  "database_owner": "dolthub",
  "database_name": "museum-collections",
  "pulls": [
    {
      "pull_id": "1",
      "title:": "Added new data",
      "description:": "Added missing museums, sourced from museums.com",
      "state": "merged",
      "created_at": "2023-07-01T18:00:00Z",
      "creator": "liuliu"
    }
  ],
  "next_page_token": "AWE2Nm9uMWQ23FSQ7oRTbCXYTLLvNDhNs5hIFebQFI66FW-SYXGSlh3XcUQ8zmtLQ00QgD0X5FZr5ZTAhvT2FfRrGog7OuUno9wdTIXFQpkkX0opYoJL6Vrn2emlXkMBTiZYMqChyhR92_Yxd58B0w5nMrfXFf8v7xfAkN46hw"
}
FieldTypeDescription
statusstringStatus of the request
database_ownerstringOwner of the database
database_namestringDatabase name
pullsarray<object>List of pull requests
next_page_tokenstringpage token for the next page of results
400 Bad request. The request was invalid or could not be processed.

Body — application/json

{
  "status": "Error",
  "message": "Error getting pull request list.",
  "database_owner": "dolthub",
  "database_name": "museum-collections"
}
FieldTypeDescription
statusstring
messagestring
database_ownerstring
database_namestring

Create a pull request comment#

Here is an example of adding a pull request comment using an authorization token.

Include this header in your request.

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

Add comment to pull request

URL https://www.dolthub.com/api/v1alpha1/{owner}/{database}/pulls/{pull_id}/comments
Parameters
NameInTypeRequiredDescription
ownerpathstringYesOwner of the database Example: dolthub
databasepathstringYesdatabase name Example: museum-collections
pull_idpathstringYesPull request ID Example: 66
Request Body

Content-Type: application/json

FieldTypeRequiredDescription
commentstringYesComment to be added to the pull request
Responses
200 Success

Body — application/json

{
  "status": "Success",
  "repository_owner": "dolthub",
  "repository_name": "museum-collections",
  "pull_id": "66",
  "comment": "The pull request looks good!"
}
FieldTypeDescription
statusstringStatus of the request
repository_ownerstringOwner of the database
repository_namestringDatabase name
pull_idstringPull request ID
commentstringComment added to the pull request
400 Bad request. The request was invalid or could not be processed.

Body — application/json

{
  "status": "Error",
  "message": "Error merging a pull request.",
  "repository_owner": "dolthub",
  "repository_name": "museum-collections",
  "pull_id": "66",
  "comment": "The pull request looks good!"
}
FieldTypeDescription
statusstring
messagestring
repository_ownerstringOwner of the database
repository_namestringDatabase name
pull_idstringPull request ID
commentstringComment added to the pull request

Merge pull request#

Here is an example of merging a pull request #66 on a database museum-collections using an authorization token. Note that the merge 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 merge request to query the API. Once the operation is complete, the response will contain a job_id field indicating the job that’s running the merge, as well as other information such as the database_owner, database_name, and pull_id.

Keep in mind that the time it takes for the merge operation to complete can vary depending on the size of the pull request and the complexity of the changes being merged.

Include this header in your request with the API token you created.

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

Merge a pull request

This endpoint merges a pull request into the destination branch.

URL https://www.dolthub.com/api/v1alpha1/{owner}/{database}/pulls/{pull_id}/merge
Parameters
NameInTypeRequiredDescription
ownerpathstringYesThe name of the database owner. Example: dolthub
databasepathstringYesThe name of the database. Example: museum-collections
pull_idpathstringYesThe ID of the pull request to merge. Example: 66
Responses
200 The pull request was merged successfully.

Body — application/json

{
  "status": "Success",
  "database_owner": "dolthub",
  "database_name": "museum-collections",
  "pull_id": "66",
  "operation_name": "repositoryOwners/dolthub/repositories/museum-collections/jobs/b09a9221-9dcb-4a15-9ca8-a64656946f12",
  "user_operation_name": "users/liuliu/userOperations/5e4834c9-375d-4bbd-bdaf-09eb0734127c"
}
FieldTypeDescription
statusstring
database_ownerstring
database_namestring
pull_idstring
operation_namestringThe job id that is performing the merge.
user_operation_namestringThe operation id that is associated to the merge job. It corresponds to the 'operation_name' field returned in the response of the list operations API.
400 Bad request. The request was invalid or could not be processed.

Body — application/json

{
  "status": "Error",
  "message": "Error merging a pull request.",
  "database_owner": "dolthub",
  "database_name": "museum-collections",
  "pull_id": "66"
}
FieldTypeDescription
statusstring
messagestring
database_ownerstring
database_namestring
pull_idstring

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

GET /{owner}/{database}/pulls/{pull_id}/merge

Check merge operation status

Poll the operation to check if the merge operation is done

URL https://www.dolthub.com/api/v1alpha1/{owner}/{database}/pulls/{pull_id}/merge
Parameters
NameInTypeRequiredDescription
ownerpathstringYesThe owner of the database Example: dolthub
databasepathstringYesThe database name Example: museum-collections
pull_idpathstringYesThe ID of the pull request Example: 66
operationNamequerystringYesThe operation name to check Example: repositoryOwners/dolthub/repositories/museum-collections/jobs/b09a9221-9dcb-4a15-9ca8-a64656946f12
Responses
200 The status of the merge operation

Body — application/json

{
  "status": "Success",
  "operation_name": "repositoryOwners/dolthub/repositories/museum-collections/jobs/b09a9221-9dcb-4a15-9ca8-a64656946f12",
  "job_created": true,
  "database_owner": "dolthub",
  "database_name": "museum-collections",
  "pull_id": "66",
  "job_status": "In Progress"
}
FieldTypeDescription
statusstringThe status of the operation, Success if the merge was successful
operation_namestringThe operation name
job_createdbooleanTrue if the job is created, False otherwise
database_ownerstringThe owner of the database
database_namestringThe name of the database
pull_idstringThe ID of the pull request
job_statusstringThe status of the job, In Progress if the job is still running, Completed if the job is done, Pending if the job is waiting to be run
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": "repositoryOwners/dolthub/repositories/museum-collections/jobs/b09a9221-9dcb-4a15-9ca8-a64656946f12"
}
FieldTypeDescription
statusstring
messagestring
operation_namestring