Sourcebin api
npm install sourcebin_jssh
$ npm i sourcebin_js
`
Setup
`js
const sourcebin = require('sourcebin_js');
`
Create a sourcecode bin
`js
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
`js
sourcebin.get("sourcebin key or url");
`
#### Example:
`js
sourcebin.get("https://sourceb.in/a13c7a5dc6")
.then(console.log)
.catch(console.error);
`
Get & Create methods output examples
#### Get
`js
sourcebin.get("https://sourceb.in/a13c7a5dc6")
.then(bin => console.log(Name: ${bin.url} | Raw: ${bin.files[0].raw}))
.catch(console.error);
`
#### Create
`js
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
`console
Name: https://sourceb.in/a13c7a5dc6 | Raw: https://sourceb.in/raw/a13c7a5dc6/0
`
Shorten
#### Syntax
`js
sourcebin.shorten("sourcebin key or url")
`
#### Example:
`js
let shortLink = sourcebin.shorten("https://sourceb.in/a13c7a5dc6");
`
Output
> Output for the get & create methods:
`json
{
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
``