修改用户名
修改 cookie 对应账号的 @用户名(screen name)。TwexAPI 会先向 X 确认新用户名是否可用:已被占用返回 409;X 不接受的用户名(太短、保留字、不允许等)返回 400 并附 X 给出的原因,这两种情况都不会做任何修改。成功时返回 X 实际保存的用户名。修改显示名称请使用 POST /twitter/profile。必须同时提供 TwexAPI Bearer API Key 和该账号的有效 X Cookie 或 auth_token。
返回 API 接口列表
/Twitter Profile Actions Endpoints
POST
/twitter/profile/usernameAPI 鉴权
AuthorizationBearer token · header必填TwexAPI 平台的全局身份凭据 (Bearer Token)。所有接口调用均需在 Header 中携带:Authorization: Bearer <YOUR_TWEXAPI_KEY>。可在 TwexAPI 用户控制台获取。
请求体
必填application/jsoncookiestring必填用户自有授权的 Twitter 会话凭据或 auth_token(BYOC 自带 Cookie 模式)。无状态受托代理执行,凭据绝不持久化存储。详见 [鉴权与安全说明](/zh/authentication#写操作鉴权与-byoc自带授权-cookie--token) 与 [获取 Cookie 指南](https://youtube-promotion.pages.dev/how-to-get-twitter-cookie)。
usernamestring必填新用户名:最多 15 个字母、数字或下划线。开头的 @ 会被忽略。
matches ^\s*@?[A-Za-z0-9_]{1,15}\s*$
proxystring | any用于执行请求的代理 IP 地址(必填)。请使用高质量住宅静态代理,避免使用免费公共代理。格式示例:http://username:password@ip:port
展开属性折叠属性
Any of:
string
stringany
any响应结果
200Username changed
codeinteger必填msgstring必填dataobject必填展开属性折叠属性
usernamestring必填The username X saved.
400Invalid username, or X will not accept it
codeinteger必填msgstring必填dataany[] | any必填展开属性折叠属性
Any of:
any[]
Array of
anyanyany
any401X could not authenticate the account
codeinteger必填msgstring必填dataany[] | any必填展开属性折叠属性
Any of:
any[]
Array of
anyanyany
any403The account is suspended or locked, or authentication or quota was denied
codeinteger必填msgstring必填dataany[] | any必填展开属性折叠属性
Any of:
any[]
Array of
anyanyany
any409The username is already taken
codeinteger必填msgstring必填dataany[] | any必填展开属性折叠属性
Any of:
any[]
Array of
anyanyany
any429Rate limit exceeded
codeinteger必填msgstring必填dataany[] | any必填展开属性折叠属性
Any of:
any[]
Array of
anyanyany
any500X did not confirm the change, or a server error occurred
codeinteger必填msgstring必填dataany[] | any必填展开属性折叠属性
Any of:
any[]
Array of
anyanyany
any⚡交互式测试POST
⚡交互式测试 / Try APIPOSTLive Console
🌐目标服务器:
https://api.twexapi.io● 生产环境就绪
✍️
写入接口凭证指引(TwexAPI 密钥 + 目标推特 Cookie)
1. TwexAPI 平台密钥 (Bearer Token):在下方「API 鉴权」中填入,用于 TwexAPI 计费与接口调用鉴权。
2. 推特账号 Cookie:本接口为代发/点赞/关注等写操作,需在下方请求体 (Request Body) 的 cookie 字段中填入目标 Twitter 账号的 Cookie 凭据(如 auth_token=...; ct0=...)。
🔑API 鉴权
📝请求体application/json
📡
暂无响应数据
请在「请求配置」中确认参数后,点击底部的「发送请求」按钮。
请求示例
curl -X POST "https://api.twexapi.io/twitter/profile/username" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"cookie": "YOUR_X_COOKIE_OR_AUTH_TOKEN",
"username": "new_handle"
}'const response = await fetch("https://api.twexapi.io/twitter/profile/username", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
},
body: JSON.stringify({
"cookie": "YOUR_X_COOKIE_OR_AUTH_TOKEN",
"username": "new_handle"
})
});import requests
response = requests.post(
"https://api.twexapi.io/twitter/profile/username",
headers={
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
},
json={
"cookie": "YOUR_X_COOKIE_OR_AUTH_TOKEN",
"username": "new_handle"
},
)响应示例
{
"code": 200,
"msg": "success",
"data": {
"username": "new_handle"
}
}{
"code": 400,
"msg": "Your username must be longer than 4 characters.",
"data": null
}{
"code": 401,
"msg": "X could not authenticate the account. (32)",
"data": null
}{
"code": 0,
"msg": "string",
"data": [
null
]
}{
"code": 409,
"msg": "That username has been taken. Please choose another.",
"data": null
}{
"code": 0,
"msg": "string",
"data": [
null
]
}{
"code": 0,
"msg": "string",
"data": [
null
]
}