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

# Démarrage rapide

> Récupérer les détails d’un Space par id ou par créateur

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

Ce guide vous explique comment récupérer des informations sur un Space à l'aide des endpoints de recherche Spaces.

<Note>
  **Prérequis**

  Avant de commencer, vous aurez besoin des éléments suivants :

  * D'un [compte développeur](https://developer.x.com/en/portal/petition/essential/basic-info) avec une App approuvée
  * Du jeton Bearer de votre App
</Note>

***

<div id="get-a-space-by-id">
  ## Récupérer un Space par id
</div>

Récupérez les détails d’un Space spécifique :

<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")

  # Récupérer un Space par id
  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"État : {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" });

  // Récupérer un Space par id
  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(`État : ${response.data?.state}`);
  console.log(`Participants : ${response.data?.participant_count}`);
  ```
</CodeGroup>

<div id="response">
  ### Réponse
</div>

```json theme={null}
{
  "data": {
    "id": "1DXxyRYNejbKM",
    "state": "live",
    "title": "Discussing AI and the Future",
    "host_ids": ["2244994945"],
    "participant_count": 245,
    "created_at": "2024-01-15T09:00:00.000Z"
  }
}
```

***

<div id="get-multiple-spaces">
  ## Récupérer plusieurs Spaces
</div>

Récupérez plusieurs Spaces en une seule fois :

<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")

  # Récupérer plusieurs Spaces
  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" });

  // Récupérer plusieurs Spaces
  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">
  ## Récupérer des Spaces par créateur
</div>

Récupérez les Spaces hébergés par des utilisateurs spécifiques :

<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")

  # Récupérer des Spaces par créateur
  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" });

  // Récupérer des Spaces par créateur
  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">
  ## Inclure les informations de l’hôte
</div>

Étendre les données de l’utilisateur hôte :

<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")

  # Récupérer un Space avec les informations de l’hôte
  response = client.spaces.get(
      "1DXxyRYNejbKM",
      space_fields=["title", "host_ids", "state"],
      expansions=["host_ids"],
      user_fields=["username", "verified"]
  )

  print(f"Space: {response.data.title}")
  # Les informations de l’hôte se trouvent dans response.includes.users
  ```

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

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

  // Récupérer un Space avec les informations de l’hôte
  const response = await client.spaces.get("1DXxyRYNejbKM", {
    spaceFields: ["title", "host_ids", "state"],
    expansions: ["host_ids"],
    userFields: ["username", "verified"],
  });

  console.log(`Space: ${response.data?.title}`);
  // Les informations de l’hôte se trouvent dans response.includes?.users
  ```
</CodeGroup>

<div id="response-with-expansion">
  ### Réponse avec 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">
  ## États des Spaces
</div>

| État        | Description                       |
| :---------- | :-------------------------------- |
| `live`      | Actuellement en direct            |
| `scheduled` | Planifié pour une date ultérieure |
| `ended`     | A pris fin                        |

***

<div id="available-fields">
  ## Champs disponibles
</div>

| Champ               | Description                                |
| :------------------ | :----------------------------------------- |
| `title`             | Titre du Space                             |
| `host_ids`          | id des utilisateurs hôtes                  |
| `speaker_ids`       | id des utilisateurs intervenants           |
| `participant_count` | Nombre actuel de participants              |
| `scheduled_start`   | Heure de début planifiée                   |
| `started_at`        | Heure de début effective                   |
| `ended_at`          | Heure de fin effective                     |
| `is_ticketed`       | Indique si le Space est payant (à tickets) |
| `state`             | État actuel                                |

***

<div id="next-steps">
  ## Prochaines étapes
</div>

<CardGroup cols={2}>
  <Card title="Rechercher des Spaces" icon="magnifying-glass" href="/fr/x-api/spaces/search/quickstart">
    Trouvez des Spaces par mot-clé
  </Card>

  <Card title="Référence de l’API" icon="code" href="/fr/x-api/spaces/space-lookup-by-space-id">
    Documentation complète de l’endpoint
  </Card>
</CardGroup>
