본문으로 건너뛰기

Reddit 게시물 댓글 API (V1) ​

GET
API 상태
정상 사용 가능 일부 사용 가능 대부분 사용 불가 데이터 없음
API 상태를 불러오는 중…

Reddit 게시물의 댓글을 조회하며 페이지네이션 토큰을 지원합니다. 스레드의 토론을 검토하거나 특정 게시물의 추가 댓글을 이어서 조회할 수 있습니다.

요청 파라미터 ​

이름 위치 유형 필수 기본값 설명
token query string 예 - 이 API 서비스의 액세스 토큰입니다.
postId query string 예 - Reddit 게시물의 고유 식별자입니다.
cursor query string 아니요 다음 결과 페이지의 페이지네이션 토큰입니다.

코드 예제 ​

bash
curl --max-time 120 -X GET 'https://api.justoneapi.com/api/reddit/get-post-comments/v1?token=YOUR_API_KEY&postId=VALUE'
text
JustOneAPI의 "게시물 댓글 (V1)" API를 사용하고 싶습니다.
기본 URL: https://api.justoneapi.com.
API 경로: /api/reddit/get-post-comments/v1?token=YOUR_API_KEY&postId=VALUE
API 주소: BASE_URL + /api/reddit/get-post-comments/v1?token=YOUR_API_KEY&postId=VALUE
HTTP 메서드: GET
인증: URL에 "token" 쿼리 파라미터를 추가하세요.
OpenAPI 정의: https://docs.justoneapi.com/openapi/reddit/post-comments-v1-ko.json

요청 파라미터:
- token (query): 이 API 서비스의 액세스 토큰입니다. (필수)
- postId (query): Reddit 게시물의 고유 식별자입니다. (필수)
- cursor (query): 다음 결과 페이지의 페이지네이션 토큰입니다.

응답 형식: 실제 Content-Type에 따라 JSON 또는 텍스트를 안전하게 처리하세요.

응답 처리 및 오류 코드
1. 응답 본문의 "code" 필드에서 처리 결과를 확인하세요. 0은 성공을 뜻합니다.
2. 권장 요청 제한 시간은 120초입니다. 120초가 너무 길다면 최소 60초로 설정하세요. 일부 요청은 응답을 받기 전에 시간 초과될 수 있습니다.
3. API 결과 코드
   - 0: 성공
   - 100: 유효하지 않거나 비활성화된 토큰
   - 301: 데이터 수집에 실패했습니다. 다시 시도해 주세요.
   - 302: 호출 빈도 제한 초과
   - 303: 일일 호출 한도 초과
   - 400: 잘못된 파라미터
   - 500: 서버 내부 오류
   - 600: 호출 권한 없음
   - 601: 계정 잔액 부족
   - 602: API 토큰의 누적 예산 한도 초과
4. 601은 공유 계정 잔액이 부족하다는 뜻입니다. 602는 현재 API 토큰의 누적 예산 한도에 도달했다는 뜻입니다. 토큰 예산을 설정해도 공유 계정 잔액은 별도로 배정되지 않습니다.

제가 사용하는 프로그래밍 언어로 이 API를 호출하고 응답을 처리하는 스크립트를 작성해 주세요.
python
import requests

BASE_URL = "https://api.justoneapi.com"  # OpenAPI 서버 설정에서 제공

url = BASE_URL + "/api/reddit/get-post-comments/v1?token=YOUR_API_KEY&postId=VALUE"
response = requests.get(url, timeout=120)
print(response.status_code)
if response.content:
    content_type = response.headers.get("content-type", "").lower()
    if "json" in content_type:
        try:
            print(response.json())
        except ValueError:
            print(response.text)
    elif content_type.startswith("text/") or "xml" in content_type or content_type.split(";", 1)[0].strip() in {"application/javascript", "application/x-www-form-urlencoded", "application/graphql"}:
        print(response.text)
    else:
        with open("response.bin", "wb") as output:
            output.write(response.content)
        print(f"Saved {len(response.content)} bytes to response.bin")
js
const BASE_URL = "https://api.justoneapi.com"; // OpenAPI 서버 설정에서 제공
const url = BASE_URL + "/api/reddit/get-post-comments/v1?token=YOUR_API_KEY&postId=VALUE";

const response = await fetch(url, {
  method: "GET",
  signal: AbortSignal.timeout(120000)
});
console.log(response.status);
const responseBytes = await response.arrayBuffer();
if (responseBytes.byteLength) {
  const contentType = (response.headers.get("content-type") || "").toLowerCase();
  const mediaType = contentType.split(";", 1)[0].trim();
  const textual = contentType.startsWith("text/") || contentType.includes("json") || contentType.includes("xml") || ["application/javascript", "application/x-www-form-urlencoded", "application/graphql"].includes(mediaType);
  if (textual) {
    const responseText = new TextDecoder().decode(responseBytes);
    let data = responseText;
    if (contentType.includes("json")) {
      try { data = JSON.parse(responseText); } catch { /* Keep the raw body. */ }
    }
    console.log(data);
  } else {
    console.log(`Received ${responseBytes.byteLength} binary bytes`);
  }
}
java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;

public class Main {
    public static void main(String[] args) throws Exception {
        final String BASE_URL = "https://api.justoneapi.com"; // OpenAPI 서버 설정에서 제공
        final String url = BASE_URL + "/api/reddit/get-post-comments/v1?token=YOUR_API_KEY&postId=VALUE";

        HttpClient client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(120)).build();
        HttpRequest.Builder builder = HttpRequest.newBuilder()
            .uri(URI.create(url))
            .timeout(Duration.ofSeconds(120))
            .method("GET", HttpRequest.BodyPublishers.noBody());

        HttpRequest request = builder.build();

        HttpResponse<byte[]> response = client.send(request, HttpResponse.BodyHandlers.ofByteArray());
        System.out.println(response.statusCode());
        String contentType = response.headers().firstValue("content-type").orElse("").toLowerCase();
        String mediaType = contentType.split(";", 2)[0].trim();
        if (contentType.startsWith("text/") || contentType.contains("json") || contentType.contains("xml") || mediaType.equals("application/javascript") || mediaType.equals("application/x-www-form-urlencoded") || mediaType.equals("application/graphql")) {
            System.out.println(new String(response.body(), StandardCharsets.UTF_8));
        } else {
            Files.write(Path.of("response.bin"), response.body());
            System.out.println("Saved " + response.body().length + " bytes to response.bin");
        }
    }
}
go
package main

import (
	"fmt"
	"io"
	"os"
	"strings"
	"net/http"
	"time"
)

const BASE_URL = "https://api.justoneapi.com" // OpenAPI 서버 설정에서 제공

func main() {
	client := &http.Client{Timeout: 120 * time.Second}
	url := BASE_URL + "/api/reddit/get-post-comments/v1?token=YOUR_API_KEY&postId=VALUE"
	req, _ := http.NewRequest("GET", url, nil)
	resp, _ := client.Do(req)
	defer resp.Body.Close()
	fmt.Println(resp.StatusCode)
	bodyBytes, _ := io.ReadAll(resp.Body)
	contentType := strings.ToLower(resp.Header.Get("Content-Type"))
	mediaType := strings.TrimSpace(strings.SplitN(contentType, ";", 2)[0])
	if strings.HasPrefix(contentType, "text/") || strings.Contains(contentType, "json") || strings.Contains(contentType, "xml") || mediaType == "application/javascript" || mediaType == "application/x-www-form-urlencoded" || mediaType == "application/graphql" {
		fmt.Println(string(bodyBytes))
	} else {
		os.WriteFile("response.bin", bodyBytes, 0600)
		fmt.Printf("Saved %d bytes to response.bin\n", len(bodyBytes))
	}
}
php
<?php
$BASE_URL = 'https://api.justoneapi.com'; // OpenAPI 서버 설정에서 제공
$url = $BASE_URL . '/api/reddit/get-post-comments/v1?token=YOUR_API_KEY&postId=VALUE';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
$contentType = strtolower((string) curl_getinfo($ch, CURLINFO_CONTENT_TYPE));
curl_close($ch);
echo $status . PHP_EOL;
$mediaType = trim(explode(';', $contentType, 2)[0]);
if (str_starts_with($contentType, 'text/') || str_contains($contentType, 'json') || str_contains($contentType, 'xml') || in_array($mediaType, ['application/javascript', 'application/x-www-form-urlencoded', 'application/graphql'], true)) {
    echo $response;
} else {
    file_put_contents('response.bin', $response);
    echo 'Saved ' . strlen($response) . ' bytes to response.bin' . PHP_EOL;
}

응답 필드 ​

성공 응답(code = 0)의 주요 필드입니다.

게시물 및 페이지 번호필드 9개

data

스레드 메타데이터와 브랜치 연속 정보가 포함된 Reddit 게시물 댓글.

필드 유형 설명
postInfoById object 요청된 post 식별자에 대한 게시물 및 댓글 숲 데이터가 반환됩니다.
postInfoById.id string Reddit 게시물 식별자.
postInfoById.title string Reddit 게시물의 제목.
postInfoById.commentCount integer 게시물에 대한 총 댓글 수 보고.
postInfoById.commentForest object 상위 항목 식별자로 연결된 댓글과 이어서 불러오기 항목을 하나의 목록으로 반환합니다.
postInfoById.commentForest.pageInfo object 댓글 숲과 함께 페이징 정보가 반환됩니다.
postInfoById.commentForest.pageInfo.commentCount integer | null 숲에 대한 댓글 수 보고, 사용할 수 없을 경우 null.
postInfoById.commentForest.pageInfo.hasNextPage boolean 댓글 숲에 추가 결과가 보고되는지 여부.
postInfoById.commentForest.trees array 댓글 숲의 순서가 정해진 항목. 각 항목은 댓글 노드 또는 연속 마커를 가질 수 있습니다.
댓글 트리 및 계속되는 분기필드 8개

data.postInfoById.commentForest.trees[]

댓글 트리의 댓글 또는 이어서 불러오기 항목 하나입니다.

필드 유형 설명
childCount integer 이 트리 항목에 대한 보고된 자식 개수.
depth integer 댓글 스레드 내의 깊이입니다. 최상위 항목의 깊이는 0입니다.
parentId string | null 부모 댓글 식별자. 최상위 항목은 null을 반환할 수 있습니다.
node object | null 이 댓글 트리 항목의 댓글 내용과 공개 메타데이터입니다. 다음 항목을 불러오기 위한 표시인 경우 null을 반환합니다.
more object | null 이 분기의 다음 댓글을 불러오기 위한 메타데이터입니다. 정보가 없으면 null을 반환합니다.
more.count integer 이 연속 항목으로 표현된 댓글의 보고된 개수.
more.cursor string 이 브랜치에 대한 불투명 연속 커서. 동일한 postId로 커서 쿼리 매개변수로 그대로 전달합니다.
more.isTooDeepForCount boolean 분기가 너무 깊어서 카운트를 제공할 수 없다고 보고되는지 여부.
댓글 내용필드 14개

data.postInfoById.commentForest.trees[].node

필드 유형 설명
id string Reddit 댓글 식별자.
createdAt string ISO 날짜-시간 텍스트 형식의 댓글 생성 시간.
editedAt - 가장 최근 댓글 편집에 대한 시간 정보. 검증된 샘플은 null을 반환.
permalink string 댓글에 대한 Reddit 페이지 링크 경로.
content object 이 댓글에 제공된 콘텐츠 형식.
content.markdown string Markdown 형식으로 반환된 댓글 텍스트.
content.preview string 댓글에 대한 미리보기 텍스트가 반환됩니다.
content.richtext string JSON 문자열로 시리얼라이즈된 풍부한 텍스트 문서.
content.richtextMedia array 리치 텍스트에 의해 참조된 미디어 항목. 검증된 샘플은 빈 목록을 반환합니다.
content.typeHint string 댓글 텍스트에 보고된 콘텐츠 유형 힌트.
content.translationInfo object 댓글 내용에 대한 번역 상태 정보.
content.translationInfo.isTranslated boolean 반환된 댓글 내용이 번역된 것으로 표시되는지 여부.
content.translationInfo.translatedLanguage - 번역된 댓글 내용에 대한 언어 정보. 검증된 샘플은 null을 반환합니다.
languageCode string | null 댓글에 대한 언어 코드 보고, 사용할 수 없으면 null.
댓글 상태 및 점수필드 11개

data.postInfoById.commentForest.trees[].node

필드 유형 설명
score integer Reddit에서 보고된 댓글 점수.
isScoreHidden boolean 댓글 점수가 숨겨진 것으로 표시되는지 여부.
isAdminTakedown boolean 댓글이 Reddit 관리자에 의해 삭제된 것으로 표시되는지 여부.
isArchived boolean 댓글이 보관된 것으로 표시되는지 여부.
isCommercialCommunication boolean 댓글이 상업적 통신으로 표시되는지 여부.
isLocked boolean 댓글이 잠긴 것으로 표시되는지 여부.
isRemoved boolean 댓글이 삭제된 것으로 표시되는지 여부.
isStickied boolean 댓글이 고정된 것으로 표시되는지 여부.
isTranslatable boolean 댓글이 번역 가능한 상태로 표시되는지 여부.
removedByCategory - 댓글에 대한 삭제 카테고리 정보가 반환됩니다. 검증된 샘플은 null을 반환합니다.
distinguishedAs - 댓글에 대한 역할 구분 정보 반환. 검증된 샘플은 null을 반환.
공개 작가 세부 정보 및 배지필드 29개

data.postInfoById.commentForest.trees[].node

필드 유형 설명
authorInfo object 댓글 작성자의 공개 Reddit 계정 정보가 반환됩니다.
authorInfo.id string 댓글 작성자의 Reddit 계정 식별자.
authorInfo.name string 댓글 작성자의 공개 계정 이름이 표시됩니다.
authorInfo.accountType string 댓글 작성자의 계정 유형 반환.
authorInfo.iconSmall object 작성자의 작은 아바타 이미지 반환.
authorInfo.iconSmall.dimensions object 이미지의 픽셀 단위 크기.
authorInfo.iconSmall.dimensions.height integer 이미지 높이(픽셀).
authorInfo.iconSmall.dimensions.width integer 이미지 너비(픽셀).
authorInfo.iconSmall.url string 아바타에 대한 Reddit 이미지 URL이 반환됩니다.
authorInfo.newIcon object 새로운 아이콘 필드에 반환된 아바타 이미지.
authorInfo.newIcon.dimensions object 이미지의 픽셀 단위 크기.
authorInfo.newIcon.dimensions.height integer 이미지 높이(픽셀).
authorInfo.newIcon.dimensions.width integer 이미지 너비(픽셀).
authorInfo.newIcon.url string 아바타에 대한 Reddit 이미지 URL이 반환됩니다.
authorInfo.snoovatarIcon object | null 작성자의 Snoovatar 이미지 반환, 사용할 수 없으면 null.
authorInfo.snoovatarIcon.dimensions object 이미지의 픽셀 단위 크기.
authorInfo.snoovatarIcon.dimensions.height integer 이미지 높이(픽셀).
authorInfo.snoovatarIcon.dimensions.width integer 이미지 너비(픽셀).
authorInfo.snoovatarIcon.url string 아바타에 대한 Reddit 이미지 URL이 반환됩니다.
authorInfo.isCakeDayNow boolean 작성자 계정이 Reddit 기념일을 축하한다고 표시되는지 여부.
authorInfo.profile object 댓글 작성자의 공개 프로필 속성이 반환됩니다.
authorInfo.profile.isNsfw boolean 작성자 프로필이 NSFW로 표시되는지 여부.
authorCommunityBadge object | null 댓글 작성자의 공개 커뮤니티 배지 데이터, 사용할 수 없을 경우 null입니다.
authorCommunityBadge.accessibilityLabel string 커뮤니티 배지에 대한 접근성 레이블.
authorCommunityBadge.label string 커뮤니티 배지에 대한 표시 텍스트.
authorCommunityBadge.image object 커뮤니티 배지에 대한 이미지 정보.
authorCommunityBadge.image.url string 커뮤니티 배지의 공개 이미지 URL.
authorFlair object | null 댓글 작성자의 공개 플레어가 반환되거나, 사용할 수 없을 경우 null입니다.
authorFlair.text string 작성자의 플레어 필드에 대한 표시 텍스트.
커뮤니티 정보필드 6개

data.postInfoById.subreddit

게시물의 공개 커뮤니티 정보.

필드 유형 설명
id string Reddit 커뮤니티 식별자.
name string Reddit 커뮤니티의 이름.
prefixedName string Reddit 접두사가 포함된 커뮤니티 이름.
isQuarantined boolean 커뮤니티가 격리된 것으로 표시되는지 여부.
allowedMediaInComments array 커뮤니티에서 댓글에 허용된 미디어 유형 보고.
allowedMediaInComments[] string 댓글에서 허용되는 미디어 유형이 하나 보고되었습니다.

응답 예시 ​

응답 예시를 불러오는 중…