Quick Start
Get up and running with the BWS X SDK in minutes.
Basic Setup
typescript
import { XTwitterClient } from '@blockchain-web-services/bws-x-sdk-node';
// Initialize with environment variables
const client = new XTwitterClient();Common Operations
Get a Tweet
typescript
const tweet = await client.getTweet('1234567890');
console.log(tweet.text);
console.log('Likes:', tweet.metrics.likeCount);Get User Profile
typescript
const profile = await client.getProfile('username');
console.log(profile.name);
console.log('Followers:', profile.metrics.followersCount);Search Tweets
typescript
const results = await client.searchTweets('nodejs', {
maxResults: 100
});
results.forEach(tweet => {
console.log(tweet.text);
});Post a Reply
typescript
await client.postReply({
tweetId: '1234567890',
text: 'Great post!'
});Write Operations
Post a Tweet
typescript
const result = await client.postTweet({
text: 'Hello from BWS X SDK! 🚀'
});
console.log('Tweet posted:', result.id);Post Tweet with Image
typescript
// Upload image first
const media = await client.uploadMedia({
filePath: './chart.png',
altText: 'Chart showing growth metrics'
});
// Post tweet with image
const result = await client.postTweet({
text: 'Check out our latest metrics! 📊',
mediaIds: [media.mediaId]
});
console.log('Tweet with image posted:', result.id);Like and Retweet
typescript
// Like a tweet
await client.likeTweet('1234567890');
// Retweet
await client.retweet('1234567890');Follow a User
typescript
await client.followUser('vitalikbuterin');Delete a Tweet
typescript
await client.deleteTweet('1234567890');Next Steps
- Write Operations - Complete write operations guide
- API Reference - Explore all available methods
- Configuration - Advanced configuration options
- Operating Modes - Understanding modes