Sourcebin
Fast and simple package to get and create bins from sourcebin
Requirements
Node >=22.13
Getting
get(options)
import { get } from 'sourcebin';
const bin = await get({ key: 'qXO2NVhRc6' });Options
| Option | Description | Default | Required |
|---|---|---|---|
key |
The key to get | n/a | |
fetchContent |
Should the bin content be fetched | true |
Creating
create(options)
import { create } from 'sourcebin';
const bin = await create({
title: 'bin name',
description: 'test bin',
files: [
{
content: 'Hello World',
language: 'text',
},
],
});Options
| Option | Description | Required |
|---|---|---|
title |
Title of the bin | |
description |
Description of the bin | |
files |
Bin files - see below |
File Options
| Option | Description | Default | Required |
|---|---|---|---|
content |
Contents of the file | n/a | |
language |
What language should the file be | text |
URL Helper
Constructs the long and short Sourcebin URL for a key.
const urlData = url('iQznILdZRP');
// or
const urlData = url('https://sourceb.in/iQznILdZRP');This returns an object that looks like:
{
key: 'iQznILdZRP',
url: 'https://sourceb.in/iQznILdZRP',
short: 'http://srcb.in/iQznILdZRP'
}FAQ
Multiple files in one bin
Only Sourcebin Pro users are able to have multiple files per bin, and since there is no non-hacky way to authenticate this library doesn't currently support multiple files. We can add support in the future if they add a way to authenticate with the API.
Migrate from v5 to v6
This was just a maintenance release and the API hasn't actually changed. You will need to use Node
>=22.13or above, as we removed the dependency on axios in favour of nativefetch. Additionally, this package is now esm only which shouldn't cause any problems thanks torequire(esm), but if you experience any issues please open one.Migrate from v4 to v5