이 가이드는 /me 엔드포인트를 사용해 현재 인증된 사용자의 프로필을 조회하는 방법을 설명합니다.
사전 준비 사항시작하기 전에 다음이 필요합니다.
- 승인이 완료된 App이 연결된 개발자 계정
- 사용자 액세스 토큰 (OAuth 1.0a 또는 OAuth 2.0 PKCE)
User Access Token을 사용해 /me 엔드포인트로 요청을 보냅니다:
curl "https://api.x.com/2/users/me?\
user.fields=created_at,description,verified,public_metrics,profile_image_url" \
-H "Authorization: Bearer $USER_ACCESS_TOKEN"
{
"data": {
"id": "2244994945",
"name": "X Developers",
"username": "XDevelopers",
"created_at": "2013-12-14T04:35:55.000Z",
"description": "The voice of the X developer community",
"verified": true,
"profile_image_url": "https://pbs.twimg.com/profile_images/...",
"public_metrics": {
"followers_count": 583423,
"following_count": 2048,
"tweet_count": 14052,
"listed_count": 1672
}
}
}
/me endpoint는 다음과 같은 경우에 필수적입니다:
- 인증 확인 — 사용자가 올바르게 인증되었는지 확인
- 사용자 ID 가져오기 — 다른 API 호출을 위해 인증된 사용자의 ID를 조회
- 경험 개인화 — 앱에서 사용자의 프로필을 표시
- 대리 요청 처리 — 어떤 사용자를 대신해 요청하는지 파악
사용자의 고정된 게시물을 요청합니다:
curl "https://api.x.com/2/users/me?\
user.fields=pinned_tweet_id&\
expansions=pinned_tweet_id&\
tweet.fields=created_at,text" \
-H "Authorization: Bearer $USER_ACCESS_TOKEN"
{
"data": {
"id": "2244994945",
"name": "X Developers",
"username": "XDevelopers",
"pinned_tweet_id": "1234567890"
},
"includes": {
"tweets": [
{
"id": "1234567890",
"text": "Welcome to my profile!",
"created_at": "2024-01-01T00:00:00.000Z"
}
]
}
}
| 필드 | 설명 |
|---|
created_at | 계정 생성일 |
description | 사용자 소개(바이오) |
profile_image_url | 프로필 이미지 URL |
verified | 인증 상태 |
public_metrics | 팔로워/팔로잉 수 |
location | 사용자가 지정한 위치 |
url | 사용자의 웹사이트 |
protected | 보호된 계정 상태 |
pinned_tweet_id | 고정된 게시물 ID |
/me 엔드포인트는 User Context 인증이 필요합니다. App-Only(Bearer 토큰) 인증은 지원되지 않습니다.
다음 중 하나를 사용하세요: