sei-agent-kit
Version:
A package for building AI agents on the SEI blockchain
38 lines • 1.47 kB
JavaScript
import { TwitterApi } from "twitter-api-v2";
import dotenv from "dotenv";
dotenv.config();
export async function getAccountDetails() {
const config = {
apiKey: process.env.TWITTER_API_KEY,
apiSecret: process.env.TWITTER_API_SECRET,
accessToken: process.env.TWITTER_ACCESS_TOKEN,
accessTokenSecret: process.env.TWITTER_ACCESS_TOKEN_SECRET,
};
try {
if (!config.apiKey) {
throw new Error("TWITTER_API_KEY is not configured.");
}
if (!config.apiSecret) {
throw new Error("TWITTER_API_SECRET is not configured.");
}
if (!config.accessToken) {
throw new Error("TWITTER_ACCESS_TOKEN is not configured.");
}
if (!config.accessTokenSecret) {
throw new Error("TWITTER_ACCESS_TOKEN_SECRET is not configured.");
}
const Client = new TwitterApi({
appKey: config.apiKey,
appSecret: config.apiSecret,
accessToken: config.accessToken,
accessSecret: config.accessTokenSecret,
});
const response = await Client.v2.me();
response.data.url = `https://x.com/${response.data.username}`;
return `Successfully retrieved authenticated user account details:\n${JSON.stringify(response)}`;
}
catch (error) {
return `Error retrieving authenticated user account details: ${error}`;
}
}
//# sourceMappingURL=getAccountDetails.js.map