@bridgly/sdk
v0.2.2
Published
Official TypeScript/JavaScript SDK for the Bridgly social scraping API
Maintainers
Readme
Bridgly SDK
Official TypeScript/JavaScript client for the Bridgly social scraping API. Fully typed requests and responses for every LinkedIn, X (Twitter), Reddit, GitHub, Instagram, and TikTok endpoint, plus API-key and billing management.
Install
npm install @bridgly/sdk
# or
pnpm add @bridgly/sdkQuick start
import { Bridgly } from '@bridgly/sdk';
const client = new Bridgly({ apiKey: 'bgly_...' });
const res = await client.reddit.getUser({ username: 'spez' });
if (res.type === 'success') {
console.log(res.data); // typed Reddit user profile
console.log(res.creditsCost); // credits this call consumed
} else {
console.error(res.status, res.message);
}API and network failures return a discriminated union. Invalid request inputs can throw a Zod validation error before a request is sent, and the constructor throws if the API key is missing or empty.
Scraping results use this union:
type ApiResult<T> =
| { type: 'success'; data: T; timeMs: number; creditsCost: number }
| { type: 'error'; status: number; message: string };Configuration
new Bridgly({
apiKey: 'bgly_...', // required
baseUrl: 'https://api.bridgly.app', // optional, defaults to the hosted API
});Namespaces
The client groups endpoints by platform. Inputs and outputs are typed from the shared API schemas, so your editor autocompletes every field.
client.x — X (Twitter)
getTweetDetail, search, searchUsers, getUser, getUserTweets, getUserReplies, getUserMedia, getFollowers, getFollowing, getTweetRetweeters, getTweetQuotes
const tweets = await client.x.getUserTweets({ userId: '44196397', count: 10 });client.reddit — Reddit
getPost, getComment, getSubreddit, getUser, listUserPosts, listUserComments, listUserOverview, listSubredditPosts, listSubredditComments, searchAll, searchCommunities, searchPosts, searchUsers, searchComments
const posts = await client.reddit.listSubredditPosts({
subreddit: 'programming',
sort: 'top',
count: 10,
});client.linkedin — LinkedIn
getCompanyFromUrl, getProfileFromUrl, getJob, getPostsFromCompany, getPostsFromProfile, getPostDetail, getActivityComments, getProfileComments, getProfileReactions, getPostReactions, and the search verticals searchAll, searchCompanies, searchCourses, searchEvents, searchGroups, searchJobs, searchPeople, searchPosts, searchProducts, searchSchools, searchServices
const jobs = await client.linkedin.searchJobs({
keyword: 'engineer',
location: 'Remote',
count: 10,
});client.github — GitHub
getProfile, getContributions, listRepositories, listStarred, listProjects, and the search functions searchRepositories, searchCode, searchCommits, searchIssues, searchPullRequests, searchDiscussions, searchUsers, searchTopics (each takes structured filters compiled into GitHub search qualifiers)
const profile = await client.github.getProfile({ username: 'torvalds' });
if (profile.type === 'success') {
console.log(profile.data.pinnedRepos);
}client.instagram — Instagram
getUser, getUserPosts, getFollowers, getFollowing, getPost, getPostComments, searchUsers
const followers = await client.instagram.getFollowers({
username: 'instagram',
count: 10,
});Use a username for profiles, posts, followers, and following. For individual posts and comments, use the shortcode from the post URL.
client.tiktok — TikTok
getUser
const profile = await client.tiktok.getUser({ uniqueId: 'tiktok' });
if (profile.type === 'success') console.log(profile.data);client.youtube — YouTube
getVideo
const video = await client.youtube.getVideo({
url: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ',
includeTranscript: true,
});Account management
client.apiKeys
const created = await client.apiKeys.create({ name: 'production' });
if (created.type === 'success') {
console.log(created.data.rawKey); // shown once — store it now
}
const keys = await client.apiKeys.list();
await client.apiKeys.revoke({ id: 'key_123' });client.billing
const info = await client.billing.getInfo();
if (info.type === 'success') console.log(info.data.credits);
const checkout = await client.billing.buyCredits({ amountUsd: 20 });
await client.billing.updateAutoTopUp({
enabled: true,
thresholdCredits: 500,
amountUsd: 20,
});Importing types
Every request and response type is re-exported:
import type {
GetXUserRequest,
XUserResponse,
RedditUserResponse,
GetTikTokUserRequest,
TikTokUserResponse,
TikTokUser,
} from '@bridgly/sdk';License
MIT
