sourcebin_js
v0.0.3-ignore
Published
Sourcebin api
Downloads
2,444
Maintainers
Readme
Sourcebin
Install
$ npm i sourcebin_js
Setup
const sourcebin = require('sourcebin_js');
Create a sourcecode bin
sourcebin.create([
{
name: 'Name (optional)',
content: 'Here the sourcecode (Made by https://www.npmjs.com/package/sourcebin_js)',
languageId: 'the code language js & more'
}
])
.then(console.log)
.catch(console.error);
// Add title and description
sourcebin.create([
{
name: 'Name (optional)',
content: 'Here the sourcecode (Made by https://www.npmjs.com/package/sourcebin_js)',
languageId: 'the code language js & more'
}
], {
title: 'Sourcebin Name',
description: 'Sourcebin Description'
})
.then(console.log)
.catch(console.error);
Get a bin
Syntax
sourcebin.get("sourcebin key or url");
Example:
sourcebin.get("https://sourceb.in/a13c7a5dc6")
.then(console.log)
.catch(console.error);
Get & Create methods output examples
Get
sourcebin.get("https://sourceb.in/a13c7a5dc6")
.then(bin => console.log(`Name: ${bin.url} | Raw: ${bin.files[0].raw}`))
.catch(console.error);
Create
sourcebin.create([
{
name: 'Name (optional)',
content: 'Here the sourcecode (Made by https://www.npmjs.com/package/sourcebin_js)',
languageId: 'the code language js & more'
}
], {
title: 'Sourcebin Name',
description: 'Sourcebin Description'
})
.then(bin => console.log(`Name: ${bin.url} | Raw: ${bin.files[0].raw}`))
.catch(console.error);
Output
Name: https://sourceb.in/a13c7a5dc6 | Raw: https://sourceb.in/raw/a13c7a5dc6/0
Shorten
Syntax
sourcebin.shorten("sourcebin key or url")
Example:
let shortLink = sourcebin.shorten("https://sourceb.in/a13c7a5dc6");
Output
Output for the get & create methods:
{
key: "a13c7a5dc6",
url: "https://sourceb.in/a13c7a5dc6",
short: "http://srcb.in/a13c7a5dc6",
title: "Sourcebin Name",
description: "Sourcebin Description",
created: "2020-10-29T13:04:34.116Z",
files: [
{
raw: "https://sourceb.in/raw/a13c7a5dc6/0",
name: "Name (optional)",
content: "Here the sourcecode (Made by https://www.npmjs.com/package/sourcebin_js)",
languageId: "372",
language: "[Object]"
}
]
}
Output for the shorten method:
http://srcb.in/a13c7a5dc6