Fast and simple package to get and create bins from sourcebin
Node >=22.13
get(options)
import { get } from 'sourcebin';
const bin = await get({ key: 'qXO2NVhRc6' });| Option | Description | Default | Required |
|---|---|---|---|
key |
The key to get | n/a | ✅ |
fetchContent |
Should the bin content be fetched | true |
❌ |
create(options)
import { create } from 'sourcebin';
const bin = await create({
title: 'bin name',
description: 'test bin',
files: [
{
content: 'Hello World',
language: 'text',
},
],
});| Option | Description | Required |
|---|---|---|
title |
Title of the bin | ❌ |
description |
Description of the bin | ❌ |
files |
Bin files - see below | ✅ |
| Option | Description | Default | Required |
|---|---|---|---|
content |
Contents of the file | n/a | ✅ |
language |
What language should the file be | text |
❌ |
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'
}-
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.
-
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.