ข้ามไปยังเนื้อหา

Reddit คำแสดงความคิดเห็นเกี่ยวกับโพสต์ API (V1) ​

GET
สถานะสุขภาพของ 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
ฉันต้องการใช้ API "คำแสดงความคิดเห็นเกี่ยวกับโพสต์ (V1)" จาก JustOneAPI.
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
การยืนยันตัวตน: เพิ่มพารามิเตอร์ "token" เข้าไปใน URL.
คำนิยาม OpenAPI: https://docs.justoneapi.com/openapi/reddit/post-comments-v1-th.json

พารามิเตอร์:
- token (query): โทเค็นการเข้าถึงสำหรับบริการ API นี้ (จำเป็น)
- postId (query): ตัวระบุเฉพาะของโพสต์ Reddit. (จำเป็น)
- cursor (query): โทเค็นการแบ่งหน้าสำหรับผลลัพธ์หน้าถัดไป

รูปแบบที่ส่งกลับ: จัดการ JSON หรือข้อความอย่างปลอดภัยตามค่า Content-Type ที่ได้รับจริง

การจัดการผลตอบกลับและรหัสข้อผิดพลาด:
1. ตรวจสอบผลการทำงานจากฟิลด์ "code" ในผลตอบกลับ (รหัส 0 หมายถึงสำเร็จ)
2. แนะนำให้ตั้งระยะเวลารอ 120 วินาที หาก 120 วินาทีนานเกินไป ให้ตั้งอย่างน้อย 60 วินาที แต่คำขอบางรายการอาจหมดเวลาก่อนได้รับผลลัพธ์
3. รหัสผลลัพธ์:
   - 0: สำเร็จ
   - 100: โทเคนไม่ถูกต้องหรือถูกปิดใช้งาน
   - 301: ดึงข้อมูลไม่สำเร็จ โปรดลองอีกครั้ง
   - 302: เกินขีดจำกัดอัตราการเรียก
   - 303: ใช้โควตารายวันครบแล้ว
   - 400: พารามิเตอร์ไม่ถูกต้อง
   - 500: ข้อผิดพลาดภายในเซิร์ฟเวอร์
   - 600: ไม่มีสิทธิ์เข้าถึง
   - 601: ยอดเงินคงเหลือไม่เพียงพอ
   - 602: ถึงวงเงินของโทเคนแล้ว
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 ข้อมูลของโพสต์และคอมเมนต์ที่ส่งกลับมาสำหรับตัวระบุโพสต์ที่ต้องการ.
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 ความลึกในเธรดความคิดเห็น รายการระดับบนสุดมีความลึกเท่ากับศูนย์
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 เอกสารรูปแบบพัฒนา (Rich-text) ที่ถูกสืบเนื่องในรูปแบบสตริง 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 ภาพ avatar ขนาดเล็กที่ส่งกลับมาสำหรับผู้เขียน
authorInfo.iconSmall.dimensions object ขนาดของภาพในพิกเซล
authorInfo.iconSmall.dimensions.height integer ความสูงของภาพในพิกเซล
authorInfo.iconSmall.dimensions.width integer ความกว้างของภาพในพิกเซล
authorInfo.iconSmall.url string URL ของภาพ avatar ที่เป็นสาธารณะสำหรับผู้เขียน
authorInfo.newIcon object ภาพ avatar ที่ส่งกลับมาในฟิลด์ “new-icon”
authorInfo.newIcon.dimensions object ขนาดของภาพในพิกเซล
authorInfo.newIcon.dimensions.height integer ความสูงของภาพในพิกเซล
authorInfo.newIcon.dimensions.width integer ความกว้างของภาพในพิกเซล
authorInfo.newIcon.url string URL ของภาพ avatar ที่เป็นสาธารณะสำหรับผู้เขียน
authorInfo.snoovatarIcon object | null ภาพ Snoovatar ที่ส่งกลับมาสำหรับผู้เขียน หรือ null หากไม่มี
authorInfo.snoovatarIcon.dimensions object ขนาดของภาพในพิกเซล
authorInfo.snoovatarIcon.dimensions.height integer ความสูงของภาพในพิกเซล
authorInfo.snoovatarIcon.dimensions.width integer ความกว้างของภาพในพิกเซล
authorInfo.snoovatarIcon.url string URL ของภาพ avatar ที่เป็นสาธารณะสำหรับผู้เขียน
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 ประเภทของสื่อหนึ่งที่ได้รับการรายงานว่าได้รับอนุญาตในความคิดเห็น

ตัวอย่างผลการตอบกลับ ​

กำลังโหลดตัวอย่างการตอบกลับ...