Skip to content

List the authorized user's pull requests

GET /api/v5/user/pulls

Call this endpoint to list the authorized user's pull requests.

Supported access tokens

  • AtomGit user access token (AtomGit user access tokens)

Anonymous access

This endpoint does not allow anonymous access.

Request parameters

Parameter Location Type Required Description
access_token query string Yes User authorization code
state query string No Return open, closed, locked, merged, or all merge requests; enum: open / closed / locked / merged / all; defaults to all (all)
sort query string No Return merge requests sorted by the given field; enum: created (creation time) / updated (update time) / merged_at (merge time); defaults to sorting by creation time (created)
direction query string No Return merge requests sorted ascending or descending by the sort field; enum: desc (descending) / asc (ascending)
labels query string No Comma-separated label names
created_after query string No Return merge requests created after the given time; the time format is ISO 8601, for example 2024-11-20T13:00:21+08:00
created_before query string No Return merge requests created before the given time; the time format is ISO 8601, for example 2024-11-20T13:00:21+08:00
updated_after query string No Return merge requests updated after the given time; the time format is ISO 8601, for example 2024-11-20T13:00:21+08:00
updated_before query string No Return merge requests updated before the given time; the time format is ISO 8601, for example 2024-11-20T13:00:21+08:00
scope query string No Return merge requests in the given scope; enum: need_my_approve (needs my approval) / created_by_me (created by me) / assigned_to_me (assigned to me) / need_my_review (needs my review); defaults to those created by me (created_by_me)
source_branch query string No Return merge requests with the given source branch
target_branch query string No Return merge requests with the given target branch
per_page query string No Number of items per page; maximum 100, default 20
page query string No Current page number

Response parameters

The response body is an array of PullRequest objects; the table below lists the fields of each array element.

Field Type Always returned Nullable Description
number integer Yes — Serial number
html_url string Yes — Page URL
url string Yes — Resource URL
close_related_issue integer Yes — Whether to close the related issue after merging
draft boolean Yes — Whether the pull request is a draft
labels object[] Yes — List of labels
user object Yes — Author
assignees object[] Yes — List of reviewers
testers object[] Yes — List of testers
head object Yes — Source branch commit information
base object Yes — Target branch information
id integer Yes — Pull request ID
iid integer Yes — Pull request serial number
project_id integer Yes — ID of the owning project
title string Yes — Title
body string Yes — Description
state string Yes — State: open / closed / merged
assignees_number integer Yes — Number of reviewers
testers_number integer Yes — Number of testers
created_at string Yes — Creation time
updated_at string Yes — Update time
merged_at string Yes — Merge time
closed_at string Yes — Close time
target_branch string Yes — Target branch
source_branch string Yes — Source branch
source_project_id integer Yes — ID of the source project
web_url string Yes — Web page URL
merge_request_type string Yes — Merge request type
added_lines integer Yes — Number of added lines
removed_lines integer Yes — Number of removed lines
diff_refs object Yes — Diff references
notes integer Yes — Number of comments
source_git_url string Yes — Git URL of the source repository
mergeable boolean Yes — Whether it can be merged
locked boolean Yes — Whether it is locked
closed_by object Yes — Information about who closed it
visibility_reason string No — Visibility: public means publicly visible, other means visible only to project members
merged_by object No — Information about who merged it

labels object

Field Type Always returned Nullable Description
labels.id integer Yes — Label ID
labels.name string Yes — Label name
labels.color string Yes — Label color
labels.created_at string Yes — Time the label was added
labels.updated_at string Yes — Label update time

user object

Field Type Always returned Nullable Description
user.id string Yes — User ID
user.user_id string Yes — Unique user identifier
user.object_id string Yes — Object ID
user.login string Yes — Login name
user.name string Yes — Name
user.state string Yes — State
user.avatar_url string Yes — Avatar URL
user.email string Yes — Email
user.name_cn string Yes — Name in Chinese
user.html_url string Yes — Page URL

assignees object

Field Type Always returned Nullable Description
assignees.user_id string Yes — Unique user identifier
assignees.object_id string Yes — Object ID
assignees.id string Yes — User ID
assignees.login string Yes — Login name
assignees.name string Yes — Name
assignees.state string Yes — State
assignees.avatar_url string Yes — Avatar URL
assignees.email string Yes — Email
assignees.name_cn string Yes — Name in Chinese
assignees.html_url string Yes — Page URL
assignees.assignee boolean Yes — Whether the user is a reviewer
assignees.code_owner boolean Yes — Whether the user is a code owner
assignees.accept boolean Yes — Whether the user accepted the review

testers object

Field Type Always returned Nullable Description
testers.user_id string Yes — Unique user identifier
testers.object_id string Yes — Object ID
testers.id string Yes — User ID
testers.login string Yes — Login name
testers.name string Yes — Name
testers.state string Yes — State
testers.avatar_url string Yes — Avatar URL
testers.email string Yes — Email
testers.name_cn string Yes — Name in Chinese
testers.html_url string Yes — Page URL
testers.assignee boolean Yes — Whether the user is a reviewer
testers.accept boolean Yes — Whether the user accepted the review

head object

Field Type Always returned Nullable Description
head.label string Yes — Branch label
head.ref string Yes — Branch reference
head.user object Yes — Committing user
head.repo object Yes — Source repository information

head.user object

The structure is the same as the user object (fields include id, login, name, state, avatar_url, email, name_cn, html_url).

head.repo object

Field Type Always returned Nullable Description
head.repo.id integer Yes — Repository ID
head.repo.full_path string Yes — Full path
head.repo.full_name string Yes — Full name
head.repo.human_name string Yes — Display name
head.repo.name string Yes — Repository name
head.repo.path string Yes — Repository path
head.repo.description string Yes — Repository description
head.repo.owner object Yes — Repository owner
head.repo.assigner object Yes — Repository owner in charge
head.repo.internal boolean Yes — Whether the repository is internal
head.repo.html_url string Yes — Page URL

The head.repo.owner and head.repo.assigner objects have the same structure as head.user (fields include id, login, name, state, avatar_url, email, name_cn, html_url).

base object

Field Type Always returned Nullable Description
base.label string Yes — Branch label
base.ref string Yes — Branch reference
base.user object Yes — Committing user
base.repo object Yes — Target repository information

The base.user object has the same structure as head.user; the base.repo object has the same structure as head.repo.

diff_refs object

Field Type Always returned Nullable Description
diff_refs.base_sha string Yes — Base commit SHA
diff_refs.head_sha string Yes — Latest commit SHA
diff_refs.start_sha string Yes — Source commit SHA

closed_by object

Field Type Always returned Nullable Description
closed_by.id integer Yes — User ID
closed_by.name string Yes — Name
closed_by.username string Yes — Username
closed_by.iam_id string Yes — IAM user ID
closed_by.nick_name string Yes — Nickname
closed_by.state string Yes — State
closed_by.avatar_url string Yes — Avatar URL
closed_by.email string Yes — Email
closed_by.name_cn string Yes — Name in Chinese
closed_by.web_url string Yes — Page URL

merged_by object

Field Type Always returned Nullable Description
merged_by.id string Yes — User ID
merged_by.login string Yes — Login name
merged_by.name string Yes — Name
merged_by.avatar_url string Yes — Avatar URL
merged_by.html_url string Yes — Page URL

Error response

This endpoint requires a user access token; the following are common error responses. The field names and messages of error responses follow what the backend actually returns, and the examples here only show their shape.

401 Unauthenticated

{
  "message": "Missing or invalid access token"
}

400 Invalid parameters

{
  "message": "Parameter validation failed"
}

HTTP status codes

Status code Description
200 Success (OK)
400 Bad request
401 Requires authentication
403 Forbidden

Request example

Parameter notes

Replace <token> with your AtomGit user access token; replace <page> with the page number (default 1); replace <per_page> with the number of items per page (maximum 100; default 20).

cURL

curl -X GET 'https://api.atomgit.com/api/v5/user/pulls?access_token=<token>&page=1&per_page=20' \
  -H 'Accept: application/json'

JavaScript

// Native fetch (Node.js 18+ / browser)
const response = await fetch(
  "https://api.atomgit.com/api/v5/user/pulls?access_token=<token>&page=1&per_page=20",
  {
    headers: {
      "Accept": "application/json",
    },
  },
);

if (!response.ok) {
  throw new Error(`Request failed: ${response.status}`);
}

const data = await response.json();
console.log(data);

Python

import requests

resp = requests.get(
    "https://api.atomgit.com/api/v5/user/pulls",
    params={
        "access_token": "<token>",
        "page": 1,
        "per_page": 20,
    },
    headers={"Accept": "application/json"},
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

Response example

Status code: 200

[
  {
    "number": 1,
    "html_url": "https://api.atomgit.com/octocat/Hello-World/pulls/1",
    "url": "https://api.atomgit.com/api/v5/repos/octocat/Hello-World/pulls/1",
    "close_related_issue": 0,
    "draft": false,
    "labels": [
      {
        "id": 1,
        "name": "bug",
        "color": "#d73a4a",
        "created_at": "2024-11-20T13:00:21+08:00",
        "updated_at": "2024-11-20T13:00:21+08:00"
      }
    ],
    "user": {
      "id": "1",
      "user_id": "1",
      "object_id": "1",
      "login": "octocat",
      "name": "octocat",
      "state": "active",
      "avatar_url": "https://api.atomgit.com/assets/logo.png",
      "email": "octocat@atomgit.com",
      "name_cn": "octocat",
      "html_url": "https://api.atomgit.com/octocat"
    },
    "assignees": [
      {
        "user_id": "2",
        "object_id": "2",
        "id": "2",
        "login": "octopus",
        "name": "octopus",
        "state": "active",
        "avatar_url": "https://api.atomgit.com/assets/logo.png",
        "email": "octopus@atomgit.com",
        "name_cn": "octopus",
        "html_url": "https://api.atomgit.com/octopus",
        "assignee": true,
        "code_owner": false,
        "accept": true
      }
    ],
    "testers": [],
    "head": {
      "label": "octocat:feature",
      "ref": "feature",
      "user": {
        "id": "1",
        "login": "octocat",
        "name": "octocat",
        "state": "active",
        "avatar_url": "https://api.atomgit.com/assets/logo.png",
        "email": "octocat@atomgit.com",
        "name_cn": "octocat",
        "html_url": "https://api.atomgit.com/octocat"
      },
      "repo": {
        "id": 1,
        "full_path": "octocat/Hello-World",
        "full_name": "octocat/Hello-World",
        "human_name": "Hello World",
        "name": "Hello-World",
        "path": "Hello-World",
        "description": "My first repository",
        "owner": {
          "id": "1",
          "login": "octocat",
          "name": "octocat",
          "state": "active",
          "avatar_url": "https://api.atomgit.com/assets/logo.png",
          "email": "octocat@atomgit.com",
          "name_cn": "octocat",
          "html_url": "https://api.atomgit.com/octocat"
        },
        "assigner": {
          "id": "1",
          "login": "octocat",
          "name": "octocat",
          "state": "active",
          "avatar_url": "https://api.atomgit.com/assets/logo.png",
          "email": "octocat@atomgit.com",
          "name_cn": "octocat",
          "html_url": "https://api.atomgit.com/octocat"
        },
        "internal": false,
        "html_url": "https://api.atomgit.com/octocat/Hello-World"
      }
    },
    "base": {
      "label": "octocat:main",
      "ref": "main",
      "user": {
        "id": "1",
        "login": "octocat",
        "name": "octocat",
        "state": "active",
        "avatar_url": "https://api.atomgit.com/assets/logo.png",
        "email": "octocat@atomgit.com",
        "name_cn": "octocat",
        "html_url": "https://api.atomgit.com/octocat"
      },
      "repo": {
        "id": 1,
        "full_path": "octocat/Hello-World",
        "full_name": "octocat/Hello-World",
        "human_name": "Hello World",
        "name": "Hello-World",
        "path": "Hello-World",
        "description": "My first repository",
        "owner": {
          "id": "1",
          "login": "octocat",
          "name": "octocat",
          "state": "active",
          "avatar_url": "https://api.atomgit.com/assets/logo.png",
          "email": "octocat@atomgit.com",
          "name_cn": "octocat",
          "html_url": "https://api.atomgit.com/octocat"
        },
        "assigner": {
          "id": "1",
          "login": "octocat",
          "name": "octocat",
          "state": "active",
          "avatar_url": "https://api.atomgit.com/assets/logo.png",
          "email": "octocat@atomgit.com",
          "name_cn": "octocat",
          "html_url": "https://api.atomgit.com/octocat"
        },
        "internal": false,
        "html_url": "https://api.atomgit.com/octocat/Hello-World"
      }
    },
    "id": 1,
    "iid": 1,
    "project_id": 1,
    "title": "Fix a bug",
    "body": "This pull request fixes a bug.",
    "state": "merged",
    "assignees_number": 1,
    "testers_number": 0,
    "created_at": "2024-11-20T13:00:21+08:00",
    "updated_at": "2024-12-01T10:00:00+08:00",
    "merged_at": "2024-12-01T10:00:00+08:00",
    "closed_at": "2024-12-01T10:00:00+08:00",
    "target_branch": "main",
    "source_branch": "feature",
    "source_project_id": 1,
    "web_url": "https://api.atomgit.com/octocat/Hello-World/pulls/1",
    "merge_request_type": "normal",
    "added_lines": 10,
    "removed_lines": 2,
    "diff_refs": {
      "base_sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
      "head_sha": "c5f7f8e7f6f7f8e7f6f7f8e7f6f7f8e7f6f7f8e7",
      "start_sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e"
    },
    "notes": 3,
    "source_git_url": "https://api.atomgit.com/octocat/Hello-World.git",
    "mergeable": true,
    "locked": false,
    "closed_by": {
      "id": 1,
      "name": "octocat",
      "username": "octocat",
      "iam_id": "1",
      "nick_name": "octocat",
      "state": "active",
      "avatar_url": "https://api.atomgit.com/assets/logo.png",
      "email": "octocat@atomgit.com",
      "name_cn": "octocat",
      "web_url": "https://api.atomgit.com/octocat"
    },
    "visibility_reason": "public",
    "merged_by": {
      "id": "1",
      "login": "octocat",
      "name": "octocat",
      "avatar_url": "https://api.atomgit.com/assets/logo.png",
      "html_url": "https://api.atomgit.com/octocat"
    }
  }
]

Error codes

Error code Description
400 Invalid parameters or unparseable request
401 Unauthenticated or invalid credentials (missing or invalid access token)
403 Forbidden
404 Request path does not exist
429 Too many requests; rate limit triggered
500 Internal system error

Markdown source: View on AtomGit·Content from the open-source project gitcode-dev/atomgit-api-doc