Skip to main content

1. Install and construct the client

npm install bridgly
pnpm add bridgly
import { Bridgly } from 'bridgly';

const client = new Bridgly({ apiKey: process.env.BRIDGLY_API_KEY });

2. Make a call

Every scraping method takes a typed request object and returns a typed result. Here we fetch a Reddit user profile:
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
  console.log(res.timeMs); // how long it took
} else {
  console.error(res.status, res.message); // typed error
}

3. Branch on the result

Methods never throw for API or network errors. Instead they return a discriminated union you narrow with res.type:
type ApiResult<T> =
  | { type: 'success'; data: T; timeMs: number; creditsCost: number }
  | { type: 'error'; status: number; message: string };
Once you check res.type === 'success', TypeScript knows res.data is present and fully typed for that endpoint. In the error branch you get the HTTP status and a human-readable message.
Branch on res.status (the numeric HTTP code) rather than matching on message — messages are meant for humans and may change. See Errors & types.

Try other platforms

The same shape works across every platform. Swap the namespace and method:
const res = await client.linkedin.getProfileFromUrl({
  memberIdentity: 'williamhgates',
});
if (res.type === 'success') console.log(res.data);
const res = await client.x.search({ query: 'openai lang:en' });
if (res.type === 'success') console.log(res.data);
const res = await client.reddit.listSubredditPosts({
  subreddit: 'programming',
  sort: 'top',
});
if (res.type === 'success') console.log(res.data);

Next steps

Functions

The full list of functions for X, Reddit, and LinkedIn.

Errors

Robust, typed error handling.