REST API
API allows you to work with the service without entering captcha.
In order to start working with API you need to get an authorization token.
To receive it, write an e-mail to or
you can get demo-token through API.
Attention! The demo-token only works for 7 days, after which it will be automatically deleted. But you can get a productive token and reassign demo links to it.
Table of contents
Working with URL's
All requests are made on URL https://api.ssh.cx/v1/url.
The answer always comes in JSON and has the following form:
- code — zero in success and non-zero in case of error.
- err — text of error. Empty when request was success.
- *any* — optional field which depends on the request.
Create short link
In order to create new short link, you need to make a POST request with params:
- token — your personal authorization token.
- url — URL which will be shorted.
curl -X POST https://api.ssh.cx/v1/url -d "token=SECRET&url=http://google.com"Response:
{ "code":0, "err":"", "url":"https:\/\/ssh.cx\/Vb87" }
Get your links
In order to get your short link and redirect urls, you need to make a GET request with params:
- token — your personal authorization token.
- id — option field. Allowing your to get a specific url by ID.
- short — option field. Allowing your to get a specific url by short code.
curl -X GET "https://api.ssh.cx/v1/url?token=SECRET"Response:
{ "code":0, "err":"", "urls":[ { "id":43, "url":"https:\/\/ssh.cx\/BkJe", "redirect":"http:\/\/goo.com" }, { "id":44, "url":"https:\/\/ssh.cx\/Vb87", "redirect":"http:\/\/google.com" } ] }Example 2:
curl -X GET "https://api.ssh.cx/v1/url?token=SECRET&id=44"Response 2:
{ "code":0, "err":"", "urls":[ { "id":44, "url":"https:\/\/ssh.cx\/Vb87", "redirect":"http:\/\/google.com" } ] }Example 3:
curl -X GET "https://api.ssh.cx/v1/url?token=SECRET&short=Vb87"Response 3:
{ "code":0, "err":"", "urls":[ { "id":44, "url":"https:\/\/ssh.cx\/Vb87", "redirect":"http:\/\/google.com" } ] }
Delete your links
In order to delete your short links, you need to make a DELETE request with params:
- token — your personal authorization token.
- id — specific ID to delete.
- short — specific short code to delete.
- all — delete all your short links.
You can select only one of the listed options.
Example:curl -X DELETE -d "token=SECRET&id=41" "https://api.ssh.cx/v1/url"Response:
{ "code":0, "err":"" }Example 2:
curl -X DELETE -d "token=SECRET&all=1" "https://api.ssh.cx/v1/url"Response 2:
{ "code":0, "err":"" }Example 3:
curl -X DELETE -d "token=SECRET&short=Vb87" "https://api.ssh.cx/v1/url"Response 3:
{ "code":0, "err":"" }
Working with Files
All requests are made on URL https://api.ssh.cx/v1/file.
The answer always comes in JSON and has the following form:
- code — zero in success and non-zero in case of error.
- err — text of error. Empty when request was success.
- *any* — optional field which depends on the request.
Upload file
In order to upload file and get short link, you need to make a POST request with params:
- token — your personal authorization token.
- sfile — file which will be upload.
curl -X POST -F "sfile=@mydata.txt" "https://api.ssh.cx/v1/file?token=SECRET"Response:
{ "code":0, "err":"", "url":"https:\/\/ssh.cx\/K1xG" }
Get file links
In order to get your short link and file names, you need to make a GET request with params:
- token — your personal authorization token.
- id — option field. Allowing your to get a specific file by ID.
- short — option field. Allowing your to get a specific url by short code.
curl -X GET "https://api.ssh.cx/v1/file?token=SECRET"Response:
{ "code":0, "err":"", "urls":[ { "id":58, "url":"https:\/\/ssh.cx\/psIG", "redirect":"psIG\/README.md" }, { "id":59, "url":"https:\/\/ssh.cx\/h21G", "redirect":"h21G\/someFIle.txt" }, { "id":60, "url":"https:\/\/ssh.cx\/K1xG", "redirect":"K1xG\/php.ini" } ] }Other examples as in URL.
Delete file links
In order to delete your file and short links, you need to make a DELETE request with params:
- token — your personal authorization token.
- id — specific ID to delete.
- short — specific short code to delete.
- all — delete all your short links and files.
You can select only one of the listed options.
Example:curl -X DELETE -d "token=SECRET&id=60" "https://api.ssh.cx/v1/file"Response:
{ "code":0, "err":"" }Other examples as in URL.
Demo mode
The answer always comes in JSON and has the following form:
- code — zero in success and non-zero in case of error.
- err — text of error. Empty when request was success.
- *any* — optional field which depends on the request.
Get demo token
Requests are made on URL https://api.ssh.cx/v1/demo/new
You need to make a POST request with params:
- url — your website url.
curl -X POST -d "url=http://my-super-website.ru" https://api.ssh.cx/v1/demo/newResponse:
{ "code":0, "err":"", "token":"demo_7da33822296a41c3802fed6cd2877ece" }
Assign production token
Requests are made on URL https://api.ssh.cx/v1/demo/reassign
You need to make a POST request with params:
- token — your production authorization token.
- demo_token — your demo authorization token.
curl -X POST -d "token=SECRET&demo_token=demo_7da33822296a41c3802fed6cd2877ece" https://api.ssh.cx/v1/demo/reassignResponse:
{ "code":0, "err":"", }