There isn't restrictions to use this API.
Create a new link with a simple POST request:
$ curl -X POST https://api.sh4re.be/ \
-d url="https://goo.gl/"
url
parameter is required.
Sample success:
{"success":true,"url":"https://sh4re.be/48"}
Sample failure:
{"success":false,"message":"Exceeded quota for this link."}
You may also use it in your project in JavaScript. The only requirement is url
.
For example, to create a shorten link using default settings:
var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { console.log(this.responseText); } }; xhr.open('POST', 'https://api.sh4re.be/', true); xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); xhr.send('url=' + url);
You can also supply a duration (valid choices are day
, month
, or year
)
var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { console.log(this.responseText); } }; xhr.open('POST', 'https://api.sh4re.be/', true); xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); xhr.send('url=' + url + '&duration=day');
Attribute | Value | Description |
---|---|---|
url | string | Specifies the url |
duration | day month year | Specifies the duration of the link |
once | 0 1 | Specifies if you want to delete the link after the first use |
Create a new link with a simple POST request:
$ curl -F 'file=@/home/petehouston/hello.txt' https://api.sh4re.be/
file
parameter is required.
For example, to create a link using custom settings:
var formData = new FormData(); formData.append('file', document.forms.f.file.files[0]); formData.append('duration', 'year'); formData.append('once', '1'); var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { console.log(this.responseText); } }; xhr.open('POST', 'https://api.sh4re.be/', true); xhr.send(formData);