> ## 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.

# クイックスタート

> ID または作成者で Space の詳細を取得する

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>;
};

このガイドでは、Spaces lookup エンドポイントを使用して Space に関する情報を取得する方法を説明します。

<Note>
  **前提条件**

  開始する前に、次のものが必要です。

  * 承認済みの App を持つ [開発者アカウント](https://developer.x.com/en/portal/petition/essential/basic-info)
  * App のベアラートークン
</Note>

***

<div id="get-a-space-by-id">
  ## ID で Space を取得する
</div>

特定の Space の詳細を取得します:

<CodeGroup dropdown>
  ```bash cURL theme={null}
  curl "https://api.x.com/2/spaces/1DXxyRYNejbKM?\
  space.fields=title,host_ids,participant_count,scheduled_start,state,created_at" \
    -H "Authorization: Bearer $BEARER_TOKEN"
  ```

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

  client = Client(bearer_token="YOUR_BEARER_TOKEN")

  # ID で Space を取得する
  response = client.spaces.get(
      "1DXxyRYNejbKM",
      space_fields=["title", "host_ids", "participant_count", "scheduled_start", "state", "created_at"]
  )

  print(f"Space: {response.data.title}")
  print(f"State: {response.data.state}")
  print(f"Participants: {response.data.participant_count}")
  ```

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

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

  // ID で Space を取得する
  const response = await client.spaces.get("1DXxyRYNejbKM", {
    spaceFields: ["title", "host_ids", "participant_count", "scheduled_start", "state", "created_at"],
  });

  console.log(`Space: ${response.data?.title}`);
  console.log(`State: ${response.data?.state}`);
  console.log(`Participants: ${response.data?.participant_count}`);
  ```
</CodeGroup>

<div id="response">
  ### レスポンス
</div>

```json theme={null}
{
  "data": {
    "id": "1DXxyRYNejbKM",
    "state": "live",
    "title": "AIと未来について議論する",
    "host_ids": ["2244994945"],
    "participant_count": 245,
    "created_at": "2024-01-15T09:00:00.000Z"
  }
}
```

***

<div id="get-multiple-spaces">
  ## 複数のSpaceを取得する
</div>

複数のSpaceをまとめて取得します。

<CodeGroup dropdown>
  ```bash cURL theme={null}
  curl "https://api.x.com/2/spaces?\
  ids=1DXxyRYNejbKM,1YqJDqWYNQDGW&\
  space.fields=title,state,participant_count" \
    -H "Authorization: Bearer $BEARER_TOKEN"
  ```

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

  client = Client(bearer_token="YOUR_BEARER_TOKEN")

  # 複数のSpaceを取得する
  response = client.spaces.get_spaces(
      ids=["1DXxyRYNejbKM", "1YqJDqWYNQDGW"],
      space_fields=["title", "state", "participant_count"]
  )

  for space in response.data:
      print(f"{space.title} - {space.state}")
  ```

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

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

  // 複数のSpaceを取得する
  const response = await client.spaces.getSpaces({
    ids: ["1DXxyRYNejbKM", "1YqJDqWYNQDGW"],
    spaceFields: ["title", "state", "participant_count"],
  });

  response.data?.forEach((space) => {
    console.log(`${space.title} - ${space.state}`);
  });
  ```
</CodeGroup>

***

<div id="get-spaces-by-creator">
  ## クリエイター ID で Spaces を取得する
</div>

特定のユーザーがホストしている Spaces を取得します。

<CodeGroup dropdown>
  ```bash cURL theme={null}
  curl "https://api.x.com/2/spaces/by/creator_ids?\
  user_ids=2244994945,783214&\
  space.fields=title,state,scheduled_start" \
    -H "Authorization: Bearer $BEARER_TOKEN"
  ```

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

  client = Client(bearer_token="YOUR_BEARER_TOKEN")

  # クリエイター ID で Spaces を取得
  response = client.spaces.get_by_creator_ids(
      user_ids=["2244994945", "783214"],
      space_fields=["title", "state", "scheduled_start"]
  )

  for space in response.data:
      print(f"{space.title} - {space.state}")
  ```

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

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

  // クリエイター ID で Spaces を取得
  const response = await client.spaces.getByCreatorIds({
    userIds: ["2244994945", "783214"],
    spaceFields: ["title", "state", "scheduled_start"],
  });

  response.data?.forEach((space) => {
    console.log(`${space.title} - ${space.state}`);
  });
  ```
</CodeGroup>

***

<div id="include-host-information">
  ## ホスト情報を含める
</div>

ホストユーザーのデータを展開します:

<CodeGroup dropdown>
  ```bash cURL theme={null}
  curl "https://api.x.com/2/spaces/1DXxyRYNejbKM?\
  space.fields=title,host_ids,state&\
  expansions=host_ids&\
  user.fields=username,verified" \
    -H "Authorization: Bearer $BEARER_TOKEN"
  ```

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

  client = Client(bearer_token="YOUR_BEARER_TOKEN")

  # ホスト情報を含む Space を取得
  response = client.spaces.get(
      "1DXxyRYNejbKM",
      space_fields=["title", "host_ids", "state"],
      expansions=["host_ids"],
      user_fields=["username", "verified"]
  )

  print(f"Space: {response.data.title}")
  # ホスト情報は response.includes.users に含まれています
  ```

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

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

  // ホスト情報を含む Space を取得
  const response = await client.spaces.get("1DXxyRYNejbKM", {
    spaceFields: ["title", "host_ids", "state"],
    expansions: ["host_ids"],
    userFields: ["username", "verified"],
  });

  console.log(`Space: ${response.data?.title}`);
  // ホスト情報は response.includes?.users に含まれています
  ```
</CodeGroup>

<div id="response-with-expansion">
  ### 拡張を含むレスポンス
</div>

```json theme={null}
{
  "data": {
    "id": "1DXxyRYNejbKM",
    "state": "live",
    "title": "Discussing AI and the Future",
    "host_ids": ["2244994945"]
  },
  "includes": {
    "users": [
      {
        "id": "2244994945",
        "username": "XDevelopers",
        "verified": true
      }
    ]
  }
}
```

***

<div id="space-states">
  ## Space の状態
</div>

| State       | 説明     |
| :---------- | :----- |
| `live`      | 現在ライブ中 |
| `scheduled` | 開始予定   |
| `ended`     | 終了済み   |

***

<div id="available-fields">
  ## 利用可能なフィールド
</div>

| Field               | Description      |
| :------------------ | :--------------- |
| `title`             | Space のタイトル      |
| `host_ids`          | ホストユーザーの ID      |
| `speaker_ids`       | スピーカーユーザーの ID    |
| `participant_count` | 現在の参加者数          |
| `scheduled_start`   | 予定開始時刻           |
| `started_at`        | 実際の開始時刻          |
| `ended_at`          | 終了時刻             |
| `is_ticketed`       | Space がチケット制かどうか |
| `state`             | 現在の状態            |

***

<div id="next-steps">
  ## 次のステップ
</div>

<CardGroup cols={2}>
  <Card title="Spaces を検索" icon="magnifying-glass" href="/ja/x-api/spaces/search/quickstart">
    キーワードで Spaces を検索
  </Card>

  <Card title="APIリファレンス" icon="code" href="/ja/x-api/spaces/space-lookup-by-space-id">
    エンドポイントの完全なドキュメント
  </Card>
</CardGroup>
