InfoGrab DocsInfoGrab Docs

Snippets API

요약

이 API를 사용하여 스니펫을 관리합니다. 현재 사용자의 스니펫 목록을 가져옵니다. 성공하면 200 OK와 다음 응답 속성을 반환합니다. 단일 스니펫의 원본 콘텐츠를 가져옵니다. 성공하면 200 OK와 스니펫의 원본 콘텐츠를 반환합니다.

이 API를 사용하여 스니펫을 관리합니다. 관련 API로 프로젝트 스니펫과 스토리지 간 스니펫 이동이 있습니다.

현재 사용자의 모든 스니펫 목록 조회#

현재 사용자의 스니펫 목록을 가져옵니다.

GET /snippets

지원되는 속성:

속성 유형 필수 설명
created_after datetime 아니요 지정한 시간 이후에 생성된 스니펫을 반환합니다. ISO 8601 형식(2019-03-15T08:00:00Z)이어야 합니다.
created_before datetime 아니요 지정한 시간 이전에 생성된 스니펫을 반환합니다. ISO 8601 형식(2019-03-15T08:00:00Z)이어야 합니다.
page integer 아니요 조회할 페이지입니다.
per_page integer 아니요 페이지당 반환할 스니펫 수입니다.

성공하면 200 OK와 다음 응답 속성을 반환합니다.

속성 유형 설명
author object 스니펫 작성자를 나타내는 사용자 객체입니다.
created_at string 스니펫이 생성된 날짜와 시간입니다.
description string 스니펫의 설명입니다.
file_name string 스니펫 파일의 이름입니다.
http_url_to_repo string 스니펫 리포지터리의 HTTP URL 입니다. 스니펫 리포지터리가 존재하는 경우에만 반환됩니다.
id integer 스니펫의 ID 입니다.
imported boolean true 이면 스니펫이 가져오기된 것입니다.
imported_from string 가져오기 원본입니다.
project_id integer 연결된 프로젝트의 ID 입니다. 개인 스니펫의 경우 null 입니다.
raw_url string 원본 스니펫 콘텐츠의 URL 입니다.
ssh_url_to_repo string 스니펫 리포지터리의 SSH URL 입니다. 스니펫 리포지터리가 존재하는 경우에만 반환됩니다.
title string 스니펫의 제목입니다.
updated_at string 스니펫이 마지막으로 업데이트된 날짜와 시간입니다.
visibility string 스니펫의 공개 수준입니다.
web_url string GitLab UI 에서의 스니펫 URL 입니다.

요청 예시:

curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/snippets"

응답 예시:

[
    {
        "id": 42,
        "title": "Voluptatem iure ut qui aut et consequatur quaerat.",
        "file_name": "mclaughlin.rb",
        "description": null,
        "visibility": "internal",
        "imported": false,
        "imported_from": "none",
        "author": {
            "id": 22,
            "name": "User 0",
            "username": "user0",
            "state": "active",
            "avatar_url": "https://www.gravatar.com/avatar/52e4ce24a915fb7e51e1ad3b57f4b00a?s=80&d=identicon",
            "web_url": "http://example.com/user0"
        },
        "updated_at": "2018-09-18T01:12:26.383Z",
        "created_at": "2018-09-18T01:12:26.383Z",
        "project_id": null,
        "web_url": "http://example.com/snippets/42",
        "raw_url": "http://example.com/snippets/42/raw",
        "ssh_url_to_repo": "ssh://git@example.com:snippets/42.git",
        "http_url_to_repo": "http://example.com/snippets/42.git"
    },
    {
        "id": 41,
        "title": "Ut praesentium non et atque.",
        "file_name": "ondrickaemard.rb",
        "description": null,
        "visibility": "internal",
        "imported": false,
        "imported_from": "none",
        "author": {
            "id": 22,
            "name": "User 0",
            "username": "user0",
            "state": "active",
            "avatar_url": "https://www.gravatar.com/avatar/52e4ce24a915fb7e51e1ad3b57f4b00a?s=80&d=identicon",
            "web_url": "http://example.com/user0"
        },
        "updated_at": "2018-09-18T01:12:26.360Z",
        "created_at": "2018-09-18T01:12:26.360Z",
        "project_id": 1,
        "web_url": "http://example.com/gitlab-org/gitlab-test/snippets/41",
        "raw_url": "http://example.com/gitlab-org/gitlab-test/snippets/41/raw",
        "ssh_url_to_repo": "ssh://git@example.com:gitlab-org/gitlab-test/snippets/41.git",
        "http_url_to_repo": "http://example.com/gitlab-org/gitlab-test/snippets/41.git"
    }
]

스니펫 조회#

지정한 스니펫을 조회합니다.

GET /snippets/:id

지원되는 속성:

속성 유형 필수 설명
id integer 예 조회할 스니펫의 ID 입니다.

성공하면 200 OK와 다음 응답 속성을 반환합니다.

속성 유형 설명
author object 스니펫 작성자를 나타내는 사용자 객체입니다.
created_at string 스니펫이 생성된 날짜와 시간입니다.
description string 스니펫의 설명입니다.
expires_at string 스니펫이 만료되는 날짜와 시간입니다.
file_name string 스니펫 파일의 이름입니다.
http_url_to_repo string 스니펫 리포지터리의 HTTP URL 입니다. 스니펫 리포지터리가 존재하는 경우에만 반환됩니다.
id integer 스니펫의 ID 입니다.
imported boolean true 이면 스니펫이 가져오기된 것입니다.
imported_from string 가져오기 원본입니다.
project_id integer 연결된 프로젝트의 ID 입니다. 개인 스니펫의 경우 null 입니다.
raw_url string 원본 스니펫 콘텐츠의 URL 입니다.
ssh_url_to_repo string 스니펫 리포지터리의 SSH URL 입니다. 스니펫 리포지터리가 존재하는 경우에만 반환됩니다.
title string 스니펫의 제목입니다.
updated_at string 스니펫이 마지막으로 업데이트된 날짜와 시간입니다.
visibility string 스니펫의 공개 수준입니다.
web_url string GitLab UI 에서의 스니펫 URL 입니다.

요청 예시:

curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/snippets/1"

응답 예시:

{
  "id": 1,
  "title": "test",
  "file_name": "add.rb",
  "description": "Ruby test snippet",
  "visibility": "private",
  "imported": false,
  "imported_from": "none",
  "author": {
    "id": 1,
    "username": "john_smith",
    "email": "john@example.com",
    "name": "John Smith",
    "state": "active",
    "created_at": "2012-05-23T08:00:58Z"
  },
  "expires_at": null,
  "updated_at": "2012-06-28T10:52:04Z",
  "created_at": "2012-06-28T10:52:04Z",
  "project_id": null,
  "web_url": "http://example.com/snippets/1",
  "raw_url": "http://example.com/snippets/1/raw",
  "ssh_url_to_repo": "ssh://git@example.com:snippets/1.git",
  "http_url_to_repo": "http://example.com/snippets/1.git"
}

단일 스니펫 콘텐츠#

단일 스니펫의 원본 콘텐츠를 가져옵니다.

GET /snippets/:id/raw

지원되는 속성:

속성 유형 필수 설명
id integer 예 조회할 스니펫의 ID 입니다.

성공하면 200 OK와 스니펫의 원본 콘텐츠를 반환합니다.

요청 예시:

curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/snippets/1/raw"

응답 예시:

Hello World snippet

스니펫 리포지터리 파일 콘텐츠#

원본 파일 콘텐츠를 일반 텍스트로 반환합니다.

GET /snippets/:id/files/:ref/:file_path/raw

지원되는 속성:

속성 유형 필수 설명
file_path string 예 URL 인코딩된 파일 경로입니다.
id integer 예 조회할 스니펫의 ID 입니다.
ref string 예 태그, 브랜치 또는 커밋에 대한 참조입니다.

성공하면 200 OK와 원본 파일 콘텐츠를 반환합니다.

요청 예시:

curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/snippets/1/files/main/snippet%2Erb/raw"

응답 예시:

Hello World snippet

스니펫 생성#

새 스니펫을 생성합니다.

Note

사용자에게 새 스니펫을 생성할 권한이 있어야 합니다.

스니펫 생성은 인증된 사용자별로 시간당 300 회 요청으로 속도가 제한됩니다. 이 제한은 이 엔드포인트, 프로젝트 스니펫 생성, 그리고 GitLab UI가 사용하는 createSnippet GraphQL 뮤테이션이 함께 사용합니다. 자세한 내용은 구성 불가능한 속도 제한을 참고합니다.

POST /snippets

지원되는 속성:

속성 유형 필수 설명
files:content string 예 스니펫 파일의 콘텐츠입니다.
files:file_path string 예 스니펫 파일의 파일 경로입니다.
title string 예 스니펫의 제목입니다.
content string 아니요 더 이상 사용되지 않습니다. 대신 files를 사용합니다. 스니펫의 콘텐츠입니다.
description string 아니요 스니펫의 설명입니다.
file_name string 아니요 더 이상 사용되지 않습니다. 대신 files를 사용합니다. 스니펫 파일의 이름입니다.
files array of hashes 아니요 스니펫 파일의 배열입니다.
visibility string 아니요 스니펫의 공개 수준입니다. 가능한 값은 public, private, internal 입니다. GitLab.com에서는 internal 값을 사용할 수 없습니다.

성공하면 201 Created와 다음 응답 속성을 반환합니다.

속성 유형 설명
author object 스니펫 작성자를 나타내는 사용자 객체입니다.
created_at string 스니펫이 생성된 날짜와 시간입니다.
description string 스니펫의 설명입니다.
expires_at string 스니펫이 만료되는 날짜와 시간입니다.
file_name string 스니펫 파일의 이름입니다.
files array 스니펫 파일의 배열입니다.
http_url_to_repo string 스니펫 리포지터리의 HTTP URL 입니다. 스니펫 리포지터리가 존재하는 경우에만 반환됩니다.
id integer 스니펫의 ID 입니다.
imported boolean true 이면 스니펫이 가져오기된 것입니다.
imported_from string 가져오기 원본입니다.
project_id integer 연결된 프로젝트의 ID 입니다. 개인 스니펫의 경우 null 입니다.
raw_url string 원본 스니펫 콘텐츠의 URL 입니다.
ssh_url_to_repo string 스니펫 리포지터리의 SSH URL 입니다. 스니펫 리포지터리가 존재하는 경우에만 반환됩니다.
title string 스니펫의 제목입니다.
updated_at string 스니펫이 마지막으로 업데이트된 날짜와 시간입니다.
visibility string 스니펫의 공개 수준입니다.
web_url string GitLab UI 에서의 스니펫 URL 입니다.

요청 예시:

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --data @snippet.json \
  --url "https://gitlab.example.com/api/v4/snippets"

앞의 요청 예시에 사용된 snippet.json:

{
  "title": "This is a snippet",
  "description": "Hello World snippet",
  "visibility": "internal",
  "files": [
    {
      "content": "Hello world",
      "file_path": "test.txt"
    }
  ]
}

응답 예시:

{
  "id": 1,
  "title": "This is a snippet",
  "description": "Hello World snippet",
  "visibility": "internal",
  "imported": false,
  "imported_from": "none",
  "author": {
    "id": 1,
    "username": "john_smith",
    "email": "john@example.com",
    "name": "John Smith",
    "state": "active",
    "created_at": "2012-05-23T08:00:58Z"
  },
  "expires_at": null,
  "updated_at": "2012-06-28T10:52:04Z",
  "created_at": "2012-06-28T10:52:04Z",
  "project_id": null,
  "web_url": "http://example.com/snippets/1",
  "raw_url": "http://example.com/snippets/1/raw",
  "ssh_url_to_repo": "ssh://git@example.com:snippets/1.git",
  "http_url_to_repo": "http://example.com/snippets/1.git",
  "file_name": "test.txt",
  "files": [
    {
      "path": "text.txt",
      "raw_url": "https://gitlab.example.com/-/snippets/1/raw/main/renamed.md"
    }
  ]
}

스니펫 업데이트#

기존 스니펫을 업데이트합니다.

Note

사용자에게 기존 스니펫을 변경할 권한이 있어야 합니다.

PUT /snippets/:id

지원되는 속성:

속성 유형 필수 설명
id integer 예 업데이트할 스니펫의 ID 입니다.
files:action string 예 파일에 수행할 작업의 유형이며 create, update, delete, move 중 하나입니다.
content string 아니요 더 이상 사용되지 않습니다. 대신 files를 사용합니다. 스니펫의 콘텐츠입니다.
description string 아니요 스니펫의 설명입니다.
file_name string 아니요 더 이상 사용되지 않습니다. 대신 files를 사용합니다. 스니펫 파일의 이름입니다.
files array of hashes Conditionally 스니펫 파일의 배열입니다. 파일이 여러 개인 스니펫을 업데이트할 때 필요합니다.
files:content string 아니요 스니펫 파일의 콘텐츠입니다.
files:file_path string 아니요 스니펫 파일의 파일 경로입니다.
files:previous_path string 아니요 스니펫 파일의 이전 경로입니다.
title string 아니요 스니펫의 제목입니다.
visibility string 아니요 스니펫의 공개 수준입니다. 가능한 값은 public, private, internal 입니다. GitLab.com에서는 internal 값을 사용할 수 없습니다.

성공하면 200 OK와 다음 응답 속성을 반환합니다.

속성 유형 설명
author object 스니펫 작성자를 나타내는 사용자 객체입니다.
created_at string 스니펫이 생성된 날짜와 시간입니다.
description string 스니펫의 설명입니다.
expires_at string 스니펫이 만료되는 날짜와 시간입니다.
file_name string 스니펫 파일의 이름입니다.
files array 스니펫 파일의 배열입니다.
http_url_to_repo string 스니펫 리포지터리의 HTTP URL 입니다. 스니펫 리포지터리가 존재하는 경우에만 반환됩니다.
id integer 스니펫의 ID 입니다.
imported boolean true 이면 스니펫이 가져오기된 것입니다.
imported_from string 가져오기 원본입니다.
project_id integer 연결된 프로젝트의 ID 입니다. 개인 스니펫의 경우 null 입니다.
raw_url string 원본 스니펫 콘텐츠의 URL 입니다.
ssh_url_to_repo string 스니펫 리포지터리의 SSH URL 입니다. 스니펫 리포지터리가 존재하는 경우에만 반환됩니다.
title string 스니펫의 제목입니다.
updated_at string 스니펫이 마지막으로 업데이트된 날짜와 시간입니다.
visibility string 스니펫의 공개 수준입니다.
web_url string GitLab UI 에서의 스니펫 URL 입니다.

요청 예시:

curl --request PUT \
  --header 'Content-Type: application/json' \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --data @snippet.json \
  --url "https://gitlab.example.com/api/v4/snippets/1"

앞의 요청 예시에 사용된 snippet.json:

{
  "title": "foo",
  "files": [
    {
      "action": "move",
      "previous_path": "test.txt",
      "file_path": "renamed.md"
    }
  ]
}

응답 예시:

{
  "id": 1,
  "title": "test",
  "description": "description of snippet",
  "visibility": "internal",
  "imported": false,
  "imported_from": "none",
  "author": {
    "id": 1,
    "username": "john_smith",
    "email": "john@example.com",
    "name": "John Smith",
    "state": "active",
    "created_at": "2012-05-23T08:00:58Z"
  },
  "expires_at": null,
  "updated_at": "2012-06-28T10:52:04Z",
  "created_at": "2012-06-28T10:52:04Z",
  "project_id": null,
  "web_url": "http://example.com/snippets/1",
  "raw_url": "http://example.com/snippets/1/raw",
  "ssh_url_to_repo": "ssh://git@example.com:snippets/1.git",
  "http_url_to_repo": "http://example.com/snippets/1.git",
  "file_name": "renamed.md",
  "files": [
    {
      "path": "renamed.md",
      "raw_url": "https://gitlab.example.com/-/snippets/1/raw/main/renamed.md"
    }
  ]
}

스니펫 삭제#

기존 스니펫을 삭제합니다.

DELETE /snippets/:id

지원되는 속성:

속성 유형 필수 설명
id integer 예 삭제할 스니펫의 ID 입니다.

요청 예시:

curl --request DELETE \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/snippets/1"

반환될 수 있는 코드는 다음과 같습니다.

Code Description
204 삭제에 성공했습니다. 반환되는 데이터는 없습니다.
404 스니펫을 찾지 못했습니다.

모든 공개 스니펫 목록 조회#

모든 공개 스니펫을 나열합니다.

GET /snippets/public

지원되는 속성:

속성 유형 필수 설명
created_after datetime 아니요 지정한 시간 이후에 생성된 스니펫을 반환합니다. ISO 8601 형식(2019-03-15T08:00:00Z)이어야 합니다.
created_before datetime 아니요 지정한 시간 이전에 생성된 스니펫을 반환합니다. ISO 8601 형식(2019-03-15T08:00:00Z)이어야 합니다.
page integer 아니요 조회할 페이지입니다.
per_page integer 아니요 페이지당 반환할 스니펫 수입니다.

성공하면 200 OK와 다음 응답 속성을 반환합니다.

속성 유형 설명
author object 스니펫 작성자를 나타내는 사용자 객체입니다.
created_at string 스니펫이 생성된 날짜와 시간입니다.
description string 스니펫의 설명입니다.
file_name string 스니펫 파일의 이름입니다.
http_url_to_repo string 스니펫 리포지터리의 HTTP URL 입니다. 스니펫 리포지터리가 존재하는 경우에만 반환됩니다.
id integer 스니펫의 ID 입니다.
imported boolean true 이면 스니펫이 가져오기된 것입니다.
imported_from string 가져오기 원본입니다.
project_id integer 연결된 프로젝트의 ID 입니다. 개인 스니펫의 경우 null 입니다.
raw_url string 원본 스니펫 콘텐츠의 URL 입니다.
ssh_url_to_repo string 스니펫 리포지터리의 SSH URL 입니다. 스니펫 리포지터리가 존재하는 경우에만 반환됩니다.
title string 스니펫의 제목입니다.
updated_at string 스니펫이 마지막으로 업데이트된 날짜와 시간입니다.
visibility string 스니펫의 공개 수준입니다.
web_url string GitLab UI 에서의 스니펫 URL 입니다.

요청 예시:

curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/snippets/public?per_page=2&page=1"

응답 예시:

[
    {
        "author": {
            "avatar_url": "http://www.gravatar.com/avatar/edaf55a9e363ea263e3b981d09e0f7f7?s=80&d=identicon",
            "id": 12,
            "name": "Libby Rolfson",
            "state": "active",
            "username": "elton_wehner",
            "web_url": "http://example.com/elton_wehner"
        },
        "created_at": "2016-11-25T16:53:34.504Z",
        "file_name": "oconnerrice.rb",
        "id": 49,
        "title": "Ratione cupiditate et laborum temporibus.",
        "updated_at": "2016-11-25T16:53:34.504Z",
        "project_id": null,
        "web_url": "http://example.com/snippets/49",
        "raw_url": "http://example.com/snippets/49/raw",
        "ssh_url_to_repo": "ssh://git@example.com:snippets/49.git",
        "http_url_to_repo": "http://example.com/snippets/49.git",
        "imported": false,
        "imported_from": "none"
    },
    {
        "author": {
            "avatar_url": "http://www.gravatar.com/avatar/36583b28626de71061e6e5a77972c3bd?s=80&d=identicon",
            "id": 16,
            "name": "Llewellyn Flatley",
            "state": "active",
            "username": "adaline",
            "web_url": "http://example.com/adaline"
        },
        "created_at": "2016-11-25T16:53:34.479Z",
        "file_name": "muellershields.rb",
        "id": 48,
        "title": "Minus similique nesciunt vel fugiat qui ullam sunt.",
        "updated_at": "2016-11-25T16:53:34.479Z",
        "project_id": null,
        "web_url": "http://example.com/snippets/48",
        "raw_url": "http://example.com/snippets/48/raw",
        "ssh_url_to_repo": "ssh://git@example.com:snippets/48.git",
        "http_url_to_repo": "http://example.com/snippets/48.git",
        "imported": false,
        "imported_from": "none",
        "visibility": "public"
    }
]

모든 스니펫 목록 조회#

현재 사용자가 접근할 수 있는 모든 스니펫을 나열합니다. Administrator 또는 Auditor 액세스 수준을 가진 사용자는 개인 스니펫과 프로젝트 스니펫을 포함한 모든 스니펫을 볼 수 있습니다.

GET /snippets/all

지원되는 속성:

속성 유형 필수 설명
created_after datetime 아니요 지정한 시간 이후에 생성된 스니펫을 반환합니다. ISO 8601 형식(2019-03-15T08:00:00Z)이어야 합니다.
created_before datetime 아니요 지정한 시간 이전에 생성된 스니펫을 반환합니다. ISO 8601 형식(2019-03-15T08:00:00Z)이어야 합니다.
page integer 아니요 조회할 페이지입니다.
per_page integer 아니요 페이지당 반환할 스니펫 수입니다.
repository_storage string 아니요 스니펫이 사용하는 리포지터리 스토리지로 필터링합니다 (관리자 전용).

성공하면 200 OK와 다음 응답 속성을 반환합니다.

속성 유형 설명
author object 스니펫 작성자를 나타내는 사용자 객체입니다.
created_at string 스니펫이 생성된 날짜와 시간입니다.
description string 스니펫의 설명입니다.
file_name string 스니펫 파일의 이름입니다.
files array 스니펫 파일의 배열입니다.
http_url_to_repo string 스니펫 리포지터리의 HTTP URL 입니다. 스니펫 리포지터리가 존재하는 경우에만 반환됩니다.
id integer 스니펫의 ID 입니다.
imported boolean true 이면 스니펫이 가져오기된 것입니다.
imported_from string 가져오기 원본입니다.
project_id integer 연결된 프로젝트의 ID 입니다. 개인 스니펫의 경우 null 입니다.
raw_url string 원본 스니펫 콘텐츠의 URL 입니다.
repository_storage string 스니펫이 사용하는 리포지터리 스토리지입니다.
ssh_url_to_repo string 스니펫 리포지터리의 SSH URL 입니다. 스니펫 리포지터리가 존재하는 경우에만 반환됩니다.
title string 스니펫의 제목입니다.
updated_at string 스니펫이 마지막으로 업데이트된 날짜와 시간입니다.
visibility string 스니펫의 공개 수준입니다.
web_url string GitLab UI 에서의 스니펫 URL 입니다.

요청 예시:

curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/snippets/all?per_page=2&page=1"

응답 예시:

[
  {
    "id": 113,
    "title": "Internal Project Snippet",
    "description": null,
    "visibility": "internal",
    "imported": false,
    "imported_from": "none",
    "author": {
      "id": 17,
      "username": "tim_kreiger",
      "name": "Tim Kreiger",
      "state": "active",
      "avatar_url": "http://www.gravatar.com/avatar/edaf55a9e363ea263e3b981d09e0f7f7?s=80&d=identicon",
      "web_url": "http://example.com/tim_kreiger"
    },
    "created_at": "2023-08-03T10:21:02.480Z",
    "updated_at": "2023-08-03T10:21:02.480Z",
    "project_id": 35,
    "web_url": "http://example.com/tim_kreiger/internal_project/-/snippets/113",
    "raw_url": "http://example.com/tim_kreiger/internal_project/-/snippets/113/raw",
    "file_name": "",
    "files": [],
    "repository_storage": "default"
  },
  {
    "id": 112,
    "title": "Private Personal Snippet",
    "description": null,
    "visibility": "private",
    "imported": false,
    "imported_from": "none",
    "author": {
      "id": 1,
      "username": "root",
      "name": "Administrator",
      "state": "active",
      "avatar_url": "http://www.gravatar.com/avatar/edaf55a9e363ea263e3b981d09e0f7f7?s=80&d=identicon",
      "web_url": "http://example.com/root"
    },
    "created_at": "2023-08-03T10:20:59.994Z",
    "updated_at": "2023-08-03T10:20:59.994Z",
    "project_id": null,
    "web_url": "http://example.com/-/snippets/112",
    "raw_url": "http://example.com/-/snippets/112/raw",
    "file_name": "",
    "files": [],
    "repository_storage": "default"
  },
  {
    "id": 111,
    "title": "Public Personal Snippet",
    "description": null,
    "visibility": "public",
    "imported": false,
    "imported_from": "none",
    "author": {
      "id": 17,
      "username": "tim_kreiger",
      "name": "Tim Kreiger",
      "state": "active",
      "avatar_url": "http://www.gravatar.com/avatar/edaf55a9e363ea263e3b981d09e0f7f7?s=80&d=identicon",
      "web_url": "http://example.com/tim_kreiger"
    },
    "created_at": "2023-08-03T10:21:01.312Z",
    "updated_at": "2023-08-03T10:21:01.312Z",
    "project_id": null,
    "web_url": "http://example.com/-/snippets/111",
    "raw_url": "http://example.com/-/snippets/111/raw",
    "file_name": "",
    "files": [],
    "repository_storage": "default"
  }
]

사용자 에이전트 상세 조회#

Note

관리자만 사용할 수 있습니다.

GET /snippets/:id/user_agent_detail

지원되는 속성:

속성 유형 필수 설명
id integer 예 스니펫의 ID 입니다.

성공하면 200 OK와 다음 응답 속성을 반환합니다.

속성 유형 설명
akismet_submitted boolean true 이면 상세 정보가 Akismet에 제출된 것입니다.
ip_address string 스니펫을 생성하는 데 사용된 IP 주소입니다.
user_agent string 스니펫을 생성하는 데 사용된 사용자 에이전트 문자열입니다.

요청 예시:

curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/snippets/1/user_agent_detail"

응답 예시:

{
  "user_agent": "AppleWebKit/537.36",
  "ip_address": "127.0.0.1",
  "akismet_submitted": false
}

Snippets API

GitLab v19.5
Tier: Free, Premium, Ultimate
Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated
원문 보기

요약

이 API를 사용하여 스니펫을 관리합니다. 현재 사용자의 스니펫 목록을 가져옵니다. 성공하면 200 OK와 다음 응답 속성을 반환합니다. 단일 스니펫의 원본 콘텐츠를 가져옵니다. 성공하면 200 OK와 스니펫의 원본 콘텐츠를 반환합니다.

이 API를 사용하여 스니펫을 관리합니다. 관련 API로 프로젝트 스니펫과 스토리지 간 스니펫 이동이 있습니다.

현재 사용자의 모든 스니펫 목록 조회#

현재 사용자의 스니펫 목록을 가져옵니다.

GET /snippets

지원되는 속성:

속성 유형 필수 설명
created_after datetime 아니요 지정한 시간 이후에 생성된 스니펫을 반환합니다. ISO 8601 형식(2019-03-15T08:00:00Z)이어야 합니다.
created_before datetime 아니요 지정한 시간 이전에 생성된 스니펫을 반환합니다. ISO 8601 형식(2019-03-15T08:00:00Z)이어야 합니다.
page integer 아니요 조회할 페이지입니다.
per_page integer 아니요 페이지당 반환할 스니펫 수입니다.

성공하면 200 OK와 다음 응답 속성을 반환합니다.

속성 유형 설명
author object 스니펫 작성자를 나타내는 사용자 객체입니다.
created_at string 스니펫이 생성된 날짜와 시간입니다.
description string 스니펫의 설명입니다.
file_name string 스니펫 파일의 이름입니다.
http_url_to_repo string 스니펫 리포지터리의 HTTP URL 입니다. 스니펫 리포지터리가 존재하는 경우에만 반환됩니다.
id integer 스니펫의 ID 입니다.
imported boolean true 이면 스니펫이 가져오기된 것입니다.
imported_from string 가져오기 원본입니다.
project_id integer 연결된 프로젝트의 ID 입니다. 개인 스니펫의 경우 null 입니다.
raw_url string 원본 스니펫 콘텐츠의 URL 입니다.
ssh_url_to_repo string 스니펫 리포지터리의 SSH URL 입니다. 스니펫 리포지터리가 존재하는 경우에만 반환됩니다.
title string 스니펫의 제목입니다.
updated_at string 스니펫이 마지막으로 업데이트된 날짜와 시간입니다.
visibility string 스니펫의 공개 수준입니다.
web_url string GitLab UI 에서의 스니펫 URL 입니다.

요청 예시:

curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/snippets"

응답 예시:

[
    {
        "id": 42,
        "title": "Voluptatem iure ut qui aut et consequatur quaerat.",
        "file_name": "mclaughlin.rb",
        "description": null,
        "visibility": "internal",
        "imported": false,
        "imported_from": "none",
        "author": {
            "id": 22,
            "name": "User 0",
            "username": "user0",
            "state": "active",
            "avatar_url": "https://www.gravatar.com/avatar/52e4ce24a915fb7e51e1ad3b57f4b00a?s=80&d=identicon",
            "web_url": "http://example.com/user0"
        },
        "updated_at": "2018-09-18T01:12:26.383Z",
        "created_at": "2018-09-18T01:12:26.383Z",
        "project_id": null,
        "web_url": "http://example.com/snippets/42",
        "raw_url": "http://example.com/snippets/42/raw",
        "ssh_url_to_repo": "ssh://git@example.com:snippets/42.git",
        "http_url_to_repo": "http://example.com/snippets/42.git"
    },
    {
        "id": 41,
        "title": "Ut praesentium non et atque.",
        "file_name": "ondrickaemard.rb",
        "description": null,
        "visibility": "internal",
        "imported": false,
        "imported_from": "none",
        "author": {
            "id": 22,
            "name": "User 0",
            "username": "user0",
            "state": "active",
            "avatar_url": "https://www.gravatar.com/avatar/52e4ce24a915fb7e51e1ad3b57f4b00a?s=80&d=identicon",
            "web_url": "http://example.com/user0"
        },
        "updated_at": "2018-09-18T01:12:26.360Z",
        "created_at": "2018-09-18T01:12:26.360Z",
        "project_id": 1,
        "web_url": "http://example.com/gitlab-org/gitlab-test/snippets/41",
        "raw_url": "http://example.com/gitlab-org/gitlab-test/snippets/41/raw",
        "ssh_url_to_repo": "ssh://git@example.com:gitlab-org/gitlab-test/snippets/41.git",
        "http_url_to_repo": "http://example.com/gitlab-org/gitlab-test/snippets/41.git"
    }
]

스니펫 조회#

지정한 스니펫을 조회합니다.

GET /snippets/:id

지원되는 속성:

속성 유형 필수 설명
id integer 예 조회할 스니펫의 ID 입니다.

성공하면 200 OK와 다음 응답 속성을 반환합니다.

속성 유형 설명
author object 스니펫 작성자를 나타내는 사용자 객체입니다.
created_at string 스니펫이 생성된 날짜와 시간입니다.
description string 스니펫의 설명입니다.
expires_at string 스니펫이 만료되는 날짜와 시간입니다.
file_name string 스니펫 파일의 이름입니다.
http_url_to_repo string 스니펫 리포지터리의 HTTP URL 입니다. 스니펫 리포지터리가 존재하는 경우에만 반환됩니다.
id integer 스니펫의 ID 입니다.
imported boolean true 이면 스니펫이 가져오기된 것입니다.
imported_from string 가져오기 원본입니다.
project_id integer 연결된 프로젝트의 ID 입니다. 개인 스니펫의 경우 null 입니다.
raw_url string 원본 스니펫 콘텐츠의 URL 입니다.
ssh_url_to_repo string 스니펫 리포지터리의 SSH URL 입니다. 스니펫 리포지터리가 존재하는 경우에만 반환됩니다.
title string 스니펫의 제목입니다.
updated_at string 스니펫이 마지막으로 업데이트된 날짜와 시간입니다.
visibility string 스니펫의 공개 수준입니다.
web_url string GitLab UI 에서의 스니펫 URL 입니다.

요청 예시:

curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/snippets/1"

응답 예시:

{
  "id": 1,
  "title": "test",
  "file_name": "add.rb",
  "description": "Ruby test snippet",
  "visibility": "private",
  "imported": false,
  "imported_from": "none",
  "author": {
    "id": 1,
    "username": "john_smith",
    "email": "john@example.com",
    "name": "John Smith",
    "state": "active",
    "created_at": "2012-05-23T08:00:58Z"
  },
  "expires_at": null,
  "updated_at": "2012-06-28T10:52:04Z",
  "created_at": "2012-06-28T10:52:04Z",
  "project_id": null,
  "web_url": "http://example.com/snippets/1",
  "raw_url": "http://example.com/snippets/1/raw",
  "ssh_url_to_repo": "ssh://git@example.com:snippets/1.git",
  "http_url_to_repo": "http://example.com/snippets/1.git"
}

단일 스니펫 콘텐츠#

단일 스니펫의 원본 콘텐츠를 가져옵니다.

GET /snippets/:id/raw

지원되는 속성:

속성 유형 필수 설명
id integer 예 조회할 스니펫의 ID 입니다.

성공하면 200 OK와 스니펫의 원본 콘텐츠를 반환합니다.

요청 예시:

curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/snippets/1/raw"

응답 예시:

Hello World snippet

스니펫 리포지터리 파일 콘텐츠#

원본 파일 콘텐츠를 일반 텍스트로 반환합니다.

GET /snippets/:id/files/:ref/:file_path/raw

지원되는 속성:

속성 유형 필수 설명
file_path string 예 URL 인코딩된 파일 경로입니다.
id integer 예 조회할 스니펫의 ID 입니다.
ref string 예 태그, 브랜치 또는 커밋에 대한 참조입니다.

성공하면 200 OK와 원본 파일 콘텐츠를 반환합니다.

요청 예시:

curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/snippets/1/files/main/snippet%2Erb/raw"

응답 예시:

Hello World snippet

스니펫 생성#

새 스니펫을 생성합니다.

Note

사용자에게 새 스니펫을 생성할 권한이 있어야 합니다.

스니펫 생성은 인증된 사용자별로 시간당 300 회 요청으로 속도가 제한됩니다. 이 제한은 이 엔드포인트, 프로젝트 스니펫 생성, 그리고 GitLab UI가 사용하는 createSnippet GraphQL 뮤테이션이 함께 사용합니다. 자세한 내용은 구성 불가능한 속도 제한을 참고합니다.

POST /snippets

지원되는 속성:

속성 유형 필수 설명
files:content string 예 스니펫 파일의 콘텐츠입니다.
files:file_path string 예 스니펫 파일의 파일 경로입니다.
title string 예 스니펫의 제목입니다.
content string 아니요 더 이상 사용되지 않습니다. 대신 files를 사용합니다. 스니펫의 콘텐츠입니다.
description string 아니요 스니펫의 설명입니다.
file_name string 아니요 더 이상 사용되지 않습니다. 대신 files를 사용합니다. 스니펫 파일의 이름입니다.
files array of hashes 아니요 스니펫 파일의 배열입니다.
visibility string 아니요 스니펫의 공개 수준입니다. 가능한 값은 public, private, internal 입니다. GitLab.com에서는 internal 값을 사용할 수 없습니다.

성공하면 201 Created와 다음 응답 속성을 반환합니다.

속성 유형 설명
author object 스니펫 작성자를 나타내는 사용자 객체입니다.
created_at string 스니펫이 생성된 날짜와 시간입니다.
description string 스니펫의 설명입니다.
expires_at string 스니펫이 만료되는 날짜와 시간입니다.
file_name string 스니펫 파일의 이름입니다.
files array 스니펫 파일의 배열입니다.
http_url_to_repo string 스니펫 리포지터리의 HTTP URL 입니다. 스니펫 리포지터리가 존재하는 경우에만 반환됩니다.
id integer 스니펫의 ID 입니다.
imported boolean true 이면 스니펫이 가져오기된 것입니다.
imported_from string 가져오기 원본입니다.
project_id integer 연결된 프로젝트의 ID 입니다. 개인 스니펫의 경우 null 입니다.
raw_url string 원본 스니펫 콘텐츠의 URL 입니다.
ssh_url_to_repo string 스니펫 리포지터리의 SSH URL 입니다. 스니펫 리포지터리가 존재하는 경우에만 반환됩니다.
title string 스니펫의 제목입니다.
updated_at string 스니펫이 마지막으로 업데이트된 날짜와 시간입니다.
visibility string 스니펫의 공개 수준입니다.
web_url string GitLab UI 에서의 스니펫 URL 입니다.

요청 예시:

curl --request POST \
  --header 'Content-Type: application/json' \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --data @snippet.json \
  --url "https://gitlab.example.com/api/v4/snippets"

앞의 요청 예시에 사용된 snippet.json:

{
  "title": "This is a snippet",
  "description": "Hello World snippet",
  "visibility": "internal",
  "files": [
    {
      "content": "Hello world",
      "file_path": "test.txt"
    }
  ]
}

응답 예시:

{
  "id": 1,
  "title": "This is a snippet",
  "description": "Hello World snippet",
  "visibility": "internal",
  "imported": false,
  "imported_from": "none",
  "author": {
    "id": 1,
    "username": "john_smith",
    "email": "john@example.com",
    "name": "John Smith",
    "state": "active",
    "created_at": "2012-05-23T08:00:58Z"
  },
  "expires_at": null,
  "updated_at": "2012-06-28T10:52:04Z",
  "created_at": "2012-06-28T10:52:04Z",
  "project_id": null,
  "web_url": "http://example.com/snippets/1",
  "raw_url": "http://example.com/snippets/1/raw",
  "ssh_url_to_repo": "ssh://git@example.com:snippets/1.git",
  "http_url_to_repo": "http://example.com/snippets/1.git",
  "file_name": "test.txt",
  "files": [
    {
      "path": "text.txt",
      "raw_url": "https://gitlab.example.com/-/snippets/1/raw/main/renamed.md"
    }
  ]
}

스니펫 업데이트#

기존 스니펫을 업데이트합니다.

Note

사용자에게 기존 스니펫을 변경할 권한이 있어야 합니다.

PUT /snippets/:id

지원되는 속성:

속성 유형 필수 설명
id integer 예 업데이트할 스니펫의 ID 입니다.
files:action string 예 파일에 수행할 작업의 유형이며 create, update, delete, move 중 하나입니다.
content string 아니요 더 이상 사용되지 않습니다. 대신 files를 사용합니다. 스니펫의 콘텐츠입니다.
description string 아니요 스니펫의 설명입니다.
file_name string 아니요 더 이상 사용되지 않습니다. 대신 files를 사용합니다. 스니펫 파일의 이름입니다.
files array of hashes Conditionally 스니펫 파일의 배열입니다. 파일이 여러 개인 스니펫을 업데이트할 때 필요합니다.
files:content string 아니요 스니펫 파일의 콘텐츠입니다.
files:file_path string 아니요 스니펫 파일의 파일 경로입니다.
files:previous_path string 아니요 스니펫 파일의 이전 경로입니다.
title string 아니요 스니펫의 제목입니다.
visibility string 아니요 스니펫의 공개 수준입니다. 가능한 값은 public, private, internal 입니다. GitLab.com에서는 internal 값을 사용할 수 없습니다.

성공하면 200 OK와 다음 응답 속성을 반환합니다.

속성 유형 설명
author object 스니펫 작성자를 나타내는 사용자 객체입니다.
created_at string 스니펫이 생성된 날짜와 시간입니다.
description string 스니펫의 설명입니다.
expires_at string 스니펫이 만료되는 날짜와 시간입니다.
file_name string 스니펫 파일의 이름입니다.
files array 스니펫 파일의 배열입니다.
http_url_to_repo string 스니펫 리포지터리의 HTTP URL 입니다. 스니펫 리포지터리가 존재하는 경우에만 반환됩니다.
id integer 스니펫의 ID 입니다.
imported boolean true 이면 스니펫이 가져오기된 것입니다.
imported_from string 가져오기 원본입니다.
project_id integer 연결된 프로젝트의 ID 입니다. 개인 스니펫의 경우 null 입니다.
raw_url string 원본 스니펫 콘텐츠의 URL 입니다.
ssh_url_to_repo string 스니펫 리포지터리의 SSH URL 입니다. 스니펫 리포지터리가 존재하는 경우에만 반환됩니다.
title string 스니펫의 제목입니다.
updated_at string 스니펫이 마지막으로 업데이트된 날짜와 시간입니다.
visibility string 스니펫의 공개 수준입니다.
web_url string GitLab UI 에서의 스니펫 URL 입니다.

요청 예시:

curl --request PUT \
  --header 'Content-Type: application/json' \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --data @snippet.json \
  --url "https://gitlab.example.com/api/v4/snippets/1"

앞의 요청 예시에 사용된 snippet.json:

{
  "title": "foo",
  "files": [
    {
      "action": "move",
      "previous_path": "test.txt",
      "file_path": "renamed.md"
    }
  ]
}

응답 예시:

{
  "id": 1,
  "title": "test",
  "description": "description of snippet",
  "visibility": "internal",
  "imported": false,
  "imported_from": "none",
  "author": {
    "id": 1,
    "username": "john_smith",
    "email": "john@example.com",
    "name": "John Smith",
    "state": "active",
    "created_at": "2012-05-23T08:00:58Z"
  },
  "expires_at": null,
  "updated_at": "2012-06-28T10:52:04Z",
  "created_at": "2012-06-28T10:52:04Z",
  "project_id": null,
  "web_url": "http://example.com/snippets/1",
  "raw_url": "http://example.com/snippets/1/raw",
  "ssh_url_to_repo": "ssh://git@example.com:snippets/1.git",
  "http_url_to_repo": "http://example.com/snippets/1.git",
  "file_name": "renamed.md",
  "files": [
    {
      "path": "renamed.md",
      "raw_url": "https://gitlab.example.com/-/snippets/1/raw/main/renamed.md"
    }
  ]
}

스니펫 삭제#

기존 스니펫을 삭제합니다.

DELETE /snippets/:id

지원되는 속성:

속성 유형 필수 설명
id integer 예 삭제할 스니펫의 ID 입니다.

요청 예시:

curl --request DELETE \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/snippets/1"

반환될 수 있는 코드는 다음과 같습니다.

Code Description
204 삭제에 성공했습니다. 반환되는 데이터는 없습니다.
404 스니펫을 찾지 못했습니다.

모든 공개 스니펫 목록 조회#

모든 공개 스니펫을 나열합니다.

GET /snippets/public

지원되는 속성:

속성 유형 필수 설명
created_after datetime 아니요 지정한 시간 이후에 생성된 스니펫을 반환합니다. ISO 8601 형식(2019-03-15T08:00:00Z)이어야 합니다.
created_before datetime 아니요 지정한 시간 이전에 생성된 스니펫을 반환합니다. ISO 8601 형식(2019-03-15T08:00:00Z)이어야 합니다.
page integer 아니요 조회할 페이지입니다.
per_page integer 아니요 페이지당 반환할 스니펫 수입니다.

성공하면 200 OK와 다음 응답 속성을 반환합니다.

속성 유형 설명
author object 스니펫 작성자를 나타내는 사용자 객체입니다.
created_at string 스니펫이 생성된 날짜와 시간입니다.
description string 스니펫의 설명입니다.
file_name string 스니펫 파일의 이름입니다.
http_url_to_repo string 스니펫 리포지터리의 HTTP URL 입니다. 스니펫 리포지터리가 존재하는 경우에만 반환됩니다.
id integer 스니펫의 ID 입니다.
imported boolean true 이면 스니펫이 가져오기된 것입니다.
imported_from string 가져오기 원본입니다.
project_id integer 연결된 프로젝트의 ID 입니다. 개인 스니펫의 경우 null 입니다.
raw_url string 원본 스니펫 콘텐츠의 URL 입니다.
ssh_url_to_repo string 스니펫 리포지터리의 SSH URL 입니다. 스니펫 리포지터리가 존재하는 경우에만 반환됩니다.
title string 스니펫의 제목입니다.
updated_at string 스니펫이 마지막으로 업데이트된 날짜와 시간입니다.
visibility string 스니펫의 공개 수준입니다.
web_url string GitLab UI 에서의 스니펫 URL 입니다.

요청 예시:

curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/snippets/public?per_page=2&page=1"

응답 예시:

[
    {
        "author": {
            "avatar_url": "http://www.gravatar.com/avatar/edaf55a9e363ea263e3b981d09e0f7f7?s=80&d=identicon",
            "id": 12,
            "name": "Libby Rolfson",
            "state": "active",
            "username": "elton_wehner",
            "web_url": "http://example.com/elton_wehner"
        },
        "created_at": "2016-11-25T16:53:34.504Z",
        "file_name": "oconnerrice.rb",
        "id": 49,
        "title": "Ratione cupiditate et laborum temporibus.",
        "updated_at": "2016-11-25T16:53:34.504Z",
        "project_id": null,
        "web_url": "http://example.com/snippets/49",
        "raw_url": "http://example.com/snippets/49/raw",
        "ssh_url_to_repo": "ssh://git@example.com:snippets/49.git",
        "http_url_to_repo": "http://example.com/snippets/49.git",
        "imported": false,
        "imported_from": "none"
    },
    {
        "author": {
            "avatar_url": "http://www.gravatar.com/avatar/36583b28626de71061e6e5a77972c3bd?s=80&d=identicon",
            "id": 16,
            "name": "Llewellyn Flatley",
            "state": "active",
            "username": "adaline",
            "web_url": "http://example.com/adaline"
        },
        "created_at": "2016-11-25T16:53:34.479Z",
        "file_name": "muellershields.rb",
        "id": 48,
        "title": "Minus similique nesciunt vel fugiat qui ullam sunt.",
        "updated_at": "2016-11-25T16:53:34.479Z",
        "project_id": null,
        "web_url": "http://example.com/snippets/48",
        "raw_url": "http://example.com/snippets/48/raw",
        "ssh_url_to_repo": "ssh://git@example.com:snippets/48.git",
        "http_url_to_repo": "http://example.com/snippets/48.git",
        "imported": false,
        "imported_from": "none",
        "visibility": "public"
    }
]

모든 스니펫 목록 조회#

현재 사용자가 접근할 수 있는 모든 스니펫을 나열합니다. Administrator 또는 Auditor 액세스 수준을 가진 사용자는 개인 스니펫과 프로젝트 스니펫을 포함한 모든 스니펫을 볼 수 있습니다.

GET /snippets/all

지원되는 속성:

속성 유형 필수 설명
created_after datetime 아니요 지정한 시간 이후에 생성된 스니펫을 반환합니다. ISO 8601 형식(2019-03-15T08:00:00Z)이어야 합니다.
created_before datetime 아니요 지정한 시간 이전에 생성된 스니펫을 반환합니다. ISO 8601 형식(2019-03-15T08:00:00Z)이어야 합니다.
page integer 아니요 조회할 페이지입니다.
per_page integer 아니요 페이지당 반환할 스니펫 수입니다.
repository_storage string 아니요 스니펫이 사용하는 리포지터리 스토리지로 필터링합니다 (관리자 전용).

성공하면 200 OK와 다음 응답 속성을 반환합니다.

속성 유형 설명
author object 스니펫 작성자를 나타내는 사용자 객체입니다.
created_at string 스니펫이 생성된 날짜와 시간입니다.
description string 스니펫의 설명입니다.
file_name string 스니펫 파일의 이름입니다.
files array 스니펫 파일의 배열입니다.
http_url_to_repo string 스니펫 리포지터리의 HTTP URL 입니다. 스니펫 리포지터리가 존재하는 경우에만 반환됩니다.
id integer 스니펫의 ID 입니다.
imported boolean true 이면 스니펫이 가져오기된 것입니다.
imported_from string 가져오기 원본입니다.
project_id integer 연결된 프로젝트의 ID 입니다. 개인 스니펫의 경우 null 입니다.
raw_url string 원본 스니펫 콘텐츠의 URL 입니다.
repository_storage string 스니펫이 사용하는 리포지터리 스토리지입니다.
ssh_url_to_repo string 스니펫 리포지터리의 SSH URL 입니다. 스니펫 리포지터리가 존재하는 경우에만 반환됩니다.
title string 스니펫의 제목입니다.
updated_at string 스니펫이 마지막으로 업데이트된 날짜와 시간입니다.
visibility string 스니펫의 공개 수준입니다.
web_url string GitLab UI 에서의 스니펫 URL 입니다.

요청 예시:

curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/snippets/all?per_page=2&page=1"

응답 예시:

[
  {
    "id": 113,
    "title": "Internal Project Snippet",
    "description": null,
    "visibility": "internal",
    "imported": false,
    "imported_from": "none",
    "author": {
      "id": 17,
      "username": "tim_kreiger",
      "name": "Tim Kreiger",
      "state": "active",
      "avatar_url": "http://www.gravatar.com/avatar/edaf55a9e363ea263e3b981d09e0f7f7?s=80&d=identicon",
      "web_url": "http://example.com/tim_kreiger"
    },
    "created_at": "2023-08-03T10:21:02.480Z",
    "updated_at": "2023-08-03T10:21:02.480Z",
    "project_id": 35,
    "web_url": "http://example.com/tim_kreiger/internal_project/-/snippets/113",
    "raw_url": "http://example.com/tim_kreiger/internal_project/-/snippets/113/raw",
    "file_name": "",
    "files": [],
    "repository_storage": "default"
  },
  {
    "id": 112,
    "title": "Private Personal Snippet",
    "description": null,
    "visibility": "private",
    "imported": false,
    "imported_from": "none",
    "author": {
      "id": 1,
      "username": "root",
      "name": "Administrator",
      "state": "active",
      "avatar_url": "http://www.gravatar.com/avatar/edaf55a9e363ea263e3b981d09e0f7f7?s=80&d=identicon",
      "web_url": "http://example.com/root"
    },
    "created_at": "2023-08-03T10:20:59.994Z",
    "updated_at": "2023-08-03T10:20:59.994Z",
    "project_id": null,
    "web_url": "http://example.com/-/snippets/112",
    "raw_url": "http://example.com/-/snippets/112/raw",
    "file_name": "",
    "files": [],
    "repository_storage": "default"
  },
  {
    "id": 111,
    "title": "Public Personal Snippet",
    "description": null,
    "visibility": "public",
    "imported": false,
    "imported_from": "none",
    "author": {
      "id": 17,
      "username": "tim_kreiger",
      "name": "Tim Kreiger",
      "state": "active",
      "avatar_url": "http://www.gravatar.com/avatar/edaf55a9e363ea263e3b981d09e0f7f7?s=80&d=identicon",
      "web_url": "http://example.com/tim_kreiger"
    },
    "created_at": "2023-08-03T10:21:01.312Z",
    "updated_at": "2023-08-03T10:21:01.312Z",
    "project_id": null,
    "web_url": "http://example.com/-/snippets/111",
    "raw_url": "http://example.com/-/snippets/111/raw",
    "file_name": "",
    "files": [],
    "repository_storage": "default"
  }
]

사용자 에이전트 상세 조회#

Note

관리자만 사용할 수 있습니다.

GET /snippets/:id/user_agent_detail

지원되는 속성:

속성 유형 필수 설명
id integer 예 스니펫의 ID 입니다.

성공하면 200 OK와 다음 응답 속성을 반환합니다.

속성 유형 설명
akismet_submitted boolean true 이면 상세 정보가 Akismet에 제출된 것입니다.
ip_address string 스니펫을 생성하는 데 사용된 IP 주소입니다.
user_agent string 스니펫을 생성하는 데 사용된 사용자 에이전트 문자열입니다.

요청 예시:

curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/snippets/1/user_agent_detail"

응답 예시:

{
  "user_agent": "AppleWebKit/537.36",
  "ip_address": "127.0.0.1",
  "akismet_submitted": false
}