ID로 Space 조회하기
cURL
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"
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}")
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}`);
응답
{
"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"
}
}
여러 Space 조회하기
cURL
curl "https://api.x.com/2/spaces?\
ids=1DXxyRYNejbKM,1YqJDqWYNQDGW&\
space.fields=title,state,participant_count" \
-H "Authorization: Bearer $BEARER_TOKEN"
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}")
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}`);
});
생성자 기준으로 Spaces 조회
cURL
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"
from xdk import Client
client = Client(bearer_token="YOUR_BEARER_TOKEN")
# 생성자 기준으로 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}")
import { Client } from "@xdevplatform/xdk";
const client = new Client({ bearerToken: "YOUR_BEARER_TOKEN" });
// 생성자 기준으로 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}`);
});
호스트 정보 포함하기
cURL
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"
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에 있습니다
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에 있습니다
확장 필드가 포함된 응답
{
"data": {
"id": "1DXxyRYNejbKM",
"state": "live",
"title": "Discussing AI and the Future",
"host_ids": ["2244994945"]
},
"includes": {
"users": [
{
"id": "2244994945",
"username": "XDevelopers",
"verified": true
}
]
}
}
Space 상태
| State | Description |
|---|---|
live | 현재 진행 중 |
scheduled | 예약됨 |
ended | 종료됨 |
사용 가능한 필드
| Field | Description |
|---|---|
title | Space의 제목 |
host_ids | 호스트 사용자 ID |
speaker_ids | 스피커 사용자 ID |
participant_count | 현재 참여자 수 |
scheduled_start | 예정된 시작 시간 |
started_at | 실제 시작 시간 |
ended_at | 종료 시간 |
is_ticketed | 티켓이 제공되는 Space인지 여부 |
state | 현재 상태 |
다음 단계
Spaces 검색
키워드로 Spaces 찾기
API 참조 문서
전체 엔드포인트 문서 보기