Discourse API Wrapper

discourse-cli

A generic CLI for documented Discourse APIs. It syncs the official OpenAPI spec, executes operations by operationId, and still lets you drop down to raw path calls when you need full coverage.

Discourse 공식 OpenAPI를 기준으로 동작하는 범용 CLI다. operationId 기반 실행과 raw path 호출을 함께 지원해서, 문서화된 흐름과 예외 케이스를 한 도구에서 처리할 수 있다.

Quickstart

npm install
npm run build
npm link

export DISCOURSE_BASE_URL=https://community.example.com
export DISCOURSE_API_KEY=your_api_key
export DISCOURSE_API_USERNAME=your_username

discourse-cli spec sync
discourse-cli api list --search topic
discourse-cli api run getUser --path username=jwheo

What It Does

Coverage

  • Syncs Discourse OpenAPI into a local cache
  • Lists and describes documented API operations
  • Runs APIs by operationId
  • Calls raw endpoints by method and path
  • Creates and updates posts from Markdown files
  • Downloads authenticated attachments

Why This Shape

  • Broader API coverage than hand-written commands
  • Follows current Discourse docs with less drift
  • Keeps low-level escape hatches for edge cases

Posting Examples

Use a Markdown file for long drafts, or pass inline text for short posts.

Markdown File

# post.md
# Long Post Draft

Body text here.

![diagram](./images/diagram.png)

[report](./files/report.xlsx)

discourse-cli posts create \
  --title 'Long Post Draft' \
  --category 4 \
  --raw-file ./post.md

Inline Raw Body

discourse-cli posts create \
  --title 'Quick Note' \
  --category 4 \
  --raw 'hello from discourse-cli'

Current Notes

This project does not handcraft every Discourse command yet. Instead, it exposes the documented API surface generically and keeps a direct fallback for endpoints that do not map cleanly into curated commands.

빠른 시작

npm install
npm run build
npm link

export DISCOURSE_BASE_URL=https://community.example.com
export DISCOURSE_API_KEY=your_api_key
export DISCOURSE_API_USERNAME=your_username

discourse-cli spec sync
discourse-cli api list --search topic
discourse-cli api run getUser --path username=jwheo

무엇을 하나

지원 범위

  • Discourse OpenAPI를 로컬 캐시에 동기화
  • 문서화된 API 목록과 상세 설명 조회
  • operationId 기준 API 실행
  • HTTP method와 path로 raw API 직접 호출
  • 마크다운 파일로 포스트 생성 및 수정
  • 인증이 필요한 첨부파일 다운로드

왜 이렇게 만들었나

  • 사람이 직접 만든 명령보다 더 넓은 API 범위 커버
  • 공식 문서 변경을 더 쉽게 따라감
  • 예외 케이스에서 raw call로 바로 내려갈 수 있음

포스트 예제

긴 글은 마크다운 파일로 올리고, 짧은 글은 인라인 본문으로 바로 올리면 된다.

마크다운 파일로 올리기

# post.md
# 긴 글 테스트

본문입니다.

![diagram](./images/diagram.png)

[report](./files/report.xlsx)

discourse-cli posts create \
  --title '긴 글 테스트' \
  --category 4 \
  --raw-file ./post.md

그냥 바로 올리기

discourse-cli posts create \
  --title '짧은 글 테스트' \
  --category 4 \
  --raw 'hello from discourse-cli'

현재 참고사항

현재는 사람이 읽기 쉬운 전용 명령 세트보다 범용 API 실행에 초점이 있습니다. 그래도 카테고리 조회, 토픽 읽기, 댓글 작성, 파일 업로드, 첨부 다운로드 같은 실제 운영 흐름은 이미 검증 가능한 수준까지 붙어 있습니다.