> ## Documentation Index
> Fetch the complete documentation index at: https://generaltranslation.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 최근 게시물 개수

> 지난 7일 동안의 게시물 수 가져오기

export const Button = ({href, children}) => {
  return <div className="not-prose group">
    <a href={href}>
      <button className="flex items-center space-x-2.5 py-1 px-4 bg-primary-dark dark:bg-white text-white dark:text-gray-950 rounded-full group-hover:opacity-[0.9] font-medium">
        <span>
          {children}
        </span>
        <svg width="3" height="24" viewBox="0 -9 3 24" class="h-6 rotate-0 overflow-visible"><path d="M0 0L3 3L0 6" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></path></svg>
      </button>
    </a>
  </div>;
};

이 가이드는 지난 7일간의 게시물 수(볼륨)를 조회하는 방법을 안내합니다.

<Note>
  **사전 준비 사항**

  시작하기 전에 다음이 필요합니다.

  * 승인이 완료된 App이 있는 [개발자 계정](https://developer.x.com/en/portal/petition/essential/basic-info)
  * App의 Bearer 토큰
</Note>

***

<div id="get-recent-post-counts">
  ## 최근 포스트 개수 가져오기
</div>

<Steps>
  <Step title="쿼리 작성">
    최근 검색과 동일한 쿼리 구문을 사용합니다. 예를 들어 @XDevelopers 계정의 포스트 개수를 집계하려면 다음 쿼리를 사용할 수 있습니다:

    ```
    from:XDevelopers
    ```
  </Step>

  <Step title="요청 보내기">
    <CodeGroup dropdown>
      ```bash cURL theme={null}
      curl "https://api.x.com/2/tweets/counts/recent?\
      query=from%3AXDevelopers&\
      granularity=day" \
        -H "Authorization: Bearer $BEARER_TOKEN"
      ```

      ```python Python SDK theme={null}
      from xdk import Client

      client = Client(bearer_token="YOUR_BEARER_TOKEN")

      # 최근 포스트 개수 가져오기
      response = client.posts.count_recent(
          query="from:XDevelopers",
          granularity="day"
      )

      for bucket in response.data:
          print(f"{bucket.start}: {bucket.tweet_count} 포스트")

      print(f"Total: {response.meta.total_tweet_count} 포스트")
      ```

      ```javascript JavaScript SDK theme={null}
      import { Client } from "@xdevplatform/xdk";

      const client = new Client({ bearerToken: "YOUR_BEARER_TOKEN" });

      // 최근 포스트 개수 가져오기
      const response = await client.posts.countRecent({
        query: "from:XDevelopers",
        granularity: "day",
      });

      response.data?.forEach((bucket) => {
        console.log(`${bucket.start}: ${bucket.tweet_count} 포스트`);
      });

      console.log(`Total: ${response.meta?.total_tweet_count} 포스트`);
      ```
    </CodeGroup>
  </Step>

  <Step title="응답 검토">
    ```json theme={null}
    {
      "data": [
        {
          "end": "2024-01-16T00:00:00.000Z",
          "start": "2024-01-15T00:00:00.000Z",
          "tweet_count": 5
        },
        {
          "end": "2024-01-17T00:00:00.000Z",
          "start": "2024-01-16T00:00:00.000Z",
          "tweet_count": 3
        },
        {
          "end": "2024-01-18T00:00:00.000Z",
          "start": "2024-01-17T00:00:00.000Z",
          "tweet_count": 8
        }
      ],
      "meta": {
        "total_tweet_count": 16
      }
    }
    ```
  </Step>
</Steps>

***

<div id="granularity-options">
  ## 세분화 옵션
</div>

집계 단위를 제어합니다:

| Granularity | 설명            |
| :---------- | :------------ |
| `minute`    | 분 단위 집계       |
| `hour`      | 시간 단위 집계(기본값) |
| `day`       | 일 단위 집계       |

<CodeGroup dropdown>
  ```bash cURL theme={null}
  # 시간 단위 집계 가져오기
  curl "https://api.x.com/2/tweets/counts/recent?\
  query=python%20lang%3Aen&\
  granularity=hour" \
    -H "Authorization: Bearer $BEARER_TOKEN"
  ```

  ```python Python SDK theme={null}
  from xdk import Client

  client = Client(bearer_token="YOUR_BEARER_TOKEN")

  # 시간 단위 집계 가져오기
  response = client.posts.count_recent(
      query="python lang:en",
      granularity="hour"
  )

  for bucket in response.data:
      print(f"{bucket.start}: {bucket.tweet_count}")
  ```

  ```javascript JavaScript SDK theme={null}
  import { Client } from "@xdevplatform/xdk";

  const client = new Client({ bearerToken: "YOUR_BEARER_TOKEN" });

  // 시간 단위 집계 가져오기
  const response = await client.posts.countRecent({
    query: "python lang:en",
    granularity: "hour",
  });

  response.data?.forEach((bucket) => {
    console.log(`${bucket.start}: ${bucket.tweet_count}`);
  });
  ```
</CodeGroup>

***

<div id="filter-by-time-range">
  ## 시간 범위로 필터링
</div>

집계를 특정 기간으로 제한하려면:

<CodeGroup dropdown>
  ```bash cURL theme={null}
  curl "https://api.x.com/2/tweets/counts/recent?\
  query=from%3AXDevelopers&\
  start_time=2024-01-10T00%3A00%3A00Z&\
  end_time=2024-01-15T00%3A00%3A00Z&\
  granularity=day" \
    -H "Authorization: Bearer $BEARER_TOKEN"
  ```

  ```python Python SDK theme={null}
  from xdk import Client

  client = Client(bearer_token="YOUR_BEARER_TOKEN")

  # 특정 시간 범위에 대한 카운트 가져오기
  response = client.posts.count_recent(
      query="from:XDevelopers",
      start_time="2024-01-10T00:00:00Z",
      end_time="2024-01-15T00:00:00Z",
      granularity="day"
  )

  print(f"Total Posts: {response.meta.total_tweet_count}")
  ```

  ```javascript JavaScript SDK theme={null}
  import { Client } from "@xdevplatform/xdk";

  const client = new Client({ bearerToken: "YOUR_BEARER_TOKEN" });

  // 특정 시간 범위에 대한 카운트 가져오기
  const response = await client.posts.countRecent({
    query: "from:XDevelopers",
    startTime: "2024-01-10T00:00:00Z",
    endTime: "2024-01-15T00:00:00Z",
    granularity: "day",
  });

  console.log(`Total Posts: ${response.meta?.total_tweet_count}`);
  ```
</CodeGroup>

***

<div id="common-parameters">
  ## 공통 파라미터
</div>

| Parameter     | Description             | Default |
| :------------ | :---------------------- | :------ |
| `query`       | 검색 쿼리 (필수)              | —       |
| `granularity` | 시간 구간 단위(버킷 크기)         | `hour`  |
| `start_time`  | 가장 오래된 타임스탬프 (ISO 8601) | 7일 전    |
| `end_time`    | 가장 최신 타임스탬프 (ISO 8601)  | 현재      |

***

<div id="next-steps">
  ## 다음 단계
</div>

<CardGroup cols={2}>
  <Card title="전체 아카이브 개수" icon="vault" href="/ko/x-api/posts/counts/quickstart/full-archive-tweet-counts">
    과거 포스트 개수 가져오기
  </Card>

  <Card title="쿼리 만들기" icon="magnifying-glass" href="/ko/x-api/posts/counts/integrate/build-a-query">
    쿼리 구문 완벽히 익히기
  </Card>

  <Card title="API 참조 문서" icon="code" href="/ko/x-api/posts/recent-post-count">
    엔드포인트 전체 문서
  </Card>
</CardGroup>
