The instruction below shows how to add a domain to your Short.io account
1) Get your secret API key here: https://app.short.io/settings/integrations/api-key


2) Install prerequisites for requests.
pip install requests
npm install --save axios
Now everything is ready to run the following snippet. It will add a domain.
3) Create a file: filename.py/ .js/ .rb. Use the code snippet below.
Please, replace API_KEY and hostname with appropriate values.
import requests
url = "https://api.short.cm/domains/"
import json
payload = json.dumps({"hideReferer":False,"httpsLinks":False,"hostname":"yourshortdomain.com","linkType":"random"})
headers = {
'accept': "application/json",
'content-type': "application/json",
'authorization': "API_KEY"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
const axios = require('axios');
const data = {
"hideReferer":false,
"httpsLinks":false,
"hostname":"yourshortdomain.com",
"linkType":"random"
};
const options = {
headers: {
accept: 'application/json',
'content-type': 'application/json',
authorization: 'API_KEY'
}
};
axios.post('https://api.short.cm/domains/', data, options)
.then(function (response) {
console.log(response.data);
})
.catch(function (response) {
console.log(response);
});
require 'uri'
require 'net/http'
require 'openssl'
require 'json'
url = URI("https://api.short.cm/domains/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["accept"] = 'application/json'
request["content-type"] = 'application/json'
request["authorization"] = 'API_KEY'
request.body = JSON.generate({"hideReferer":false,"httpsLinks":false,"hostname":"yourshortdomain.com","linkType":"random"})
response = http.request(request)
puts response.read_body
4) Launch the file.
python filename.py
node filename.js
ruby filename.rb
5) JSON Response (the domain will be added).
Once you run the code, you will see the response.
{
linkType: 'random',
state: 'configured',(or not_configured)
cloaking: false,
setupType: 'dns',
httpsLinks: false,
id: 91576,
hostname: 'myshortlink.club',
UserId: 9346,
updatedAt: '2020-04-23T10:22:47.010Z',
createdAt: '2020-04-23T10:22:46.649Z',
provider: null,
unicodeHostname: 'yourshortdomain.com',
clientStorage: null
}
Updated 9 months ago