API Key
All Xshot API requests require an API key. You can pass it in three ways:Query String
Header
Bearer Token
WebSocket Authentication
For WebSocket connections, pass the API key as a query parameter:4001.
How to authenticate with the Xshot API
curl "https://api.xshot.fun/twitter/user/info?username=elonmusk&api_key=YOUR_KEY"
curl -H "x-api-key: YOUR_KEY" "https://api.xshot.fun/twitter/user/info?username=elonmusk"
curl -H "Authorization: Bearer YOUR_KEY" "https://api.xshot.fun/twitter/user/info?username=elonmusk"
wss://api.xshot.fun/ws?api_key=YOUR_KEY
4001.
curl "https://api.xshot.fun/twitter/user/info?username=elonmusk"
{
"error": "Invalid or missing API key"
}
const API_KEY = "YOUR_KEY";
// Using query string
const res = await fetch(
`https://api.xshot.fun/twitter/user/info?username=elonmusk&api_key=${API_KEY}`
);
const user = await res.json();
console.log(user.followers_count); // 237614000
const ws = new WebSocket("wss://api.xshot.fun/ws?api_key=YOUR_KEY");
ws.onopen = () => {
console.log("Connected and authenticated");
};
ws.onclose = (event) => {
if (event.code === 4001) {
console.error("Authentication failed");
}
};