bundle.social SDK
Node.js SDK for bundle.social API.
Installation
npm install bundlesocial
yarn add bundlesocial
pnpm add bundlesocial
!!! Make sure you have created a team on bundle.social and have an generated API key. !!!
Setup
import { BundleSocial } from 'bundlesocial';
const bundleSocial = new BundleSocial('YOUR_API_KEY');
Usage
Get the team information
const team = await bundlesocial.team.teamGetTeam();
Upload a file
const video = await fs.readFile('./video.mp4');
const createdUpload = await bundlesocial.upload.uploadCreate({
formData: {
file: new Blob([video], { type: 'video/mp4' }),
}
});
const jpgImage = await fs.readFile('./image.jpg');
const createdUpload = await bundlesocial.upload.uploadCreate({
formData: {
file: new Blob([jpgImage], { type: 'image/jpeg' }),
}
});
Create a post
const createdPost = await bundlesocial.post.postCreate({
requestBody: {
data: {
INSTAGRAM: {
text: 'Test Post',
type: 'REEL',
uploadIds: [
videoUpload?.id
]
},
YOUTUBE: {
text: 'Test Post',
type: 'SHORT',
madeForKids: false,
uploadIds: [
videoUpload?.id
],
privacyStatus: 'PUBLIC',
},
TIKTOK: {
text: 'Test Post',
uploadIds: [
videoUpload?.id
],
privacy: 'PUBLIC_TO_EVERYONE',
},
},
postDate: new Date().toISOString(),
socialAccountTypes: ['INSTAGRAM', 'YOUTUBE', 'TIKTOK'],
status: 'SCHEDULED',
title: 'Test Post',
}
});
Get the post information
const post = await bundlesocial.post.postGet({
id: createdPost.id,
});
Handling errors
try {
const team = await bundlesocial.team.teamGetTeam();
} catch (error) {
if (error instanceof ApiError) {
console.log(error?.status, error?.statusText, error?.body);
} else {
throw error;
}
}
License
MIT