프로젝트 위키 API

Tier: Free, Premium, Ultimate Offering: GitLab.com, Self-managed, GitLab Dedicated

프로젝트 위키 API는 APIv4에서만 사용할 수 있습니다. 그룹 위키용 API도 사용할 수 있습니다.

위키 페이지 디렉터리

특정 프로젝트에 있는 모든 위키 페이지를 가져옵니다.

GET /projects/:id/wikis
속성 타입 필수 설명
id integer/string Yes 프로젝트의 ID 또는 URL 인코딩된 경로.
with_content boolean No 페이지 콘텐츠 포함 여부.
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/wikis?with_content=1"

응답 예시:

[
  {
    "content" : "이 프로젝트를 배포하는 방법에 대한 안내입니다.",
    "format" : "markdown",
    "slug" : "deploy",
    "title" : "deploy",
    "encoding": "UTF-8"
  },
  {
    "content" : "저희 개발 프로세스가 여기에 설명되어 있습니다.",
    "format" : "markdown",
    "slug" : "development",
    "title" : "development",
    "encoding": "UTF-8"
  },{
    "content" : "*  [배포](deploy)\n*  [개발](development)",
    "format" : "markdown",
    "slug" : "home",
    "title" : "home",
    "encoding": "UTF-8"
  }
]

위키 페이지 가져오기

특정 프로젝트의 위키 페이지를 가져옵니다.

GET /projects/:id/wikis/:slug
속성 타입 필수 설명
id integer/string Yes 프로젝트의 ID 또는 URL 인코딩된 경로.
slug string Yes 위키 페이지의 URL 인코딩된 슬러그(고유 문자열), 예: dir%2Fpage_name.
render_html boolean No 렌더링된 HTML 반환 여부.
version string No 위키 페이지 버전 SHA.
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/wikis/home"

응답 예시:

{
  "content" : "홈 페이지",
  "format" : "markdown",
  "slug" : "home",
  "title" : "home",
  "encoding": "UTF-8"
}

새로운 위키 페이지 생성

지정된 리포지터리에 주어진 제목, 슬러그, 콘텐츠로 새로운 위키 페이지를 생성합니다.

POST /projects/:id/wikis
속성 타입 필수 설명
id integer/string Yes 프로젝트의 ID 또는 URL 인코딩된 경로.
content string Yes 위키 페이지의 콘텐츠.
title string Yes 위키 페이지의 제목.
format string No 위키 페이지의 형식. 가능한 형식은: markdown (기본값), rdoc, asciidoc, 그리고 org.
curl --data "format=rdoc&title=Hello&content=Hello world" \
     --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/wikis"

응답 예시:

{
  "content" : "Hello world",
  "format" : "markdown",
  "slug" : "Hello",
  "title" : "Hello",
  "encoding": "UTF-8"
}

기존 위키 페이지 편집

기존 위키 페이지를 업데이트합니다. 위키 페이지를 업데이트하려면 최소한 하나의 매개변수가 필요합니다.

PUT /projects/:id/wikis/:slug
속성 타입 필수 설명
id integer/string Yes 프로젝트의 ID 또는 URL 인코딩된 경로.
content string 제공되지 않는 경우 title이 필요 위키 페이지의 콘텐츠.
title string 제공되지 않는 경우 content가 필요 위키 페이지의 제목.
format string No 위키 페이지의 형식. 가능한 형식은: markdown (기본값), rdoc, asciidoc, 그리고 org.
slug string Yes 위키 페이지의 URL 인코딩된 슬러그(고유 문자열), 예: dir%2Fpage_name.
curl --request PUT --data "format=rdoc&content=documentation&title=Docs" \
     --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/wikis/foo"

응답 예시:

{
  "content" : "documentation",
  "format" : "markdown",
  "slug" : "Docs",
  "title" : "Docs",
  "encoding": "UTF-8"
}

위키 페이지 삭제

주어진 슬러그로 위키 페이지를 삭제합니다.

DELETE /projects/:id/wikis/:slug
속성 타입 필수 설명
id integer/string Yes 프로젝트의 ID 또는 URL-encoded path.
slug string Yes 위키 페이지의 URL-encoded 슬러그(고유한 문자열), 예: dir%2Fpage_name.
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/wikis/foo"

성공할 경우, 빈 본문을 가진 204 No Content HTTP 응답이 예상됩니다.

위키 리포지터리에 첨부 파일 업로드

위키 리포지터리의 첨부 폴더에 파일을 업로드합니다. 첨부 폴더는 uploads 폴더입니다.

POST /projects/:id/wikis/attachments
속성 타입 필수 설명
id integer/string Yes 프로젝트의 ID 또는 URL-encoded path.
file string Yes 업로드할 첨부 파일.
branch string No 브랜치의 이름. 위키 리포지터리의 기본 브랜치로 기본 설정됩니다.

파일을 파일 시스템에서 업로드하려면 --form 인수를 사용하십시오. 이렇게 함으로써 cURL은 Content-Type: multipart/form-data 헤더를 사용하여 데이터를 게시합니다. file= 매개변수는 파일 시스템의 파일을 가리켜야 하며, @로 시작해야 합니다. 예시:

curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \
     --form "file=@dk.png" "https://gitlab.example.com/api/v4/projects/1/wikis/attachments"

예시 응답:

{
  "file_name" : "dk.png",
  "file_path" : "uploads/6a061c4cf9f1c28cb22c384b4b8d4e3c/dk.png",
  "branch" : "main",
  "link" : {
    "url" : "uploads/6a061c4cf9f1c28cb22c384b4b8d4e3c/dk.png",
    "markdown" : "![dk](uploads/6a061c4cf9f1c28cb22c384b4b8d4e3c/dk.png)"
  }
}