The following code sample creates a short URL with a random key. The link gets expired after 24 hours.
const https = require("https") var data = JSON.stringify({ "longUrl": "https://selenium.cloud/doc/aws/graphical-ubuntu.html#execute", "expireHours": 24, }); var options = { host: "api.aws3.link", path: "/shorten", method: 'POST', headers: { 'Content-Type': 'application/json', 'x-api-key': '<YourApiKey>' }, }; var req = https.request(options, (res) => { console.log('statusCode:', res.statusCode); res.on('data', (d) => { process.stdout.write(d); }); }); req.on('error', (e) => { console.error(e); }); req.write(data); req.end();
import requests import json headers = { 'x-api-key': '<YourApiKey>', 'Content-Type': 'application/json' } body = json.dumps({ "longUrl": "https://selenium.cloud/doc/aws/graphical-ubuntu.html#execute", "expireHours": 24, }) response = requests.post('https://api.aws3.link/shorten', headers=headers, data=body) response = response.json() print(response)
URL endpoint: https://api.aws3.link/shorten
Method: POST
"header": { "x-api-key": STRING, "Content-Type": "application/json" }
"body": { "longUrl": STRING, "customKey": STRING, "expireHours": NUMBER, }
Response:
"body": { "shortUrl": STRING, "metadata": { "longUrl": STRING, "key": STRING, "expiration": DATE, } }
URL endpoint: https://api.aws3.link/update
Method: POST
"header": { "x-api-key": STRING, "Content-Type": "application/json" }
"body": { "key": STRING, "newDestUrl": STRING, "expireHours": NUMBER, }
Response:
"body": { "shortUrl": STRING, "metadata": { "longUrl": STRING, "key": STRING, "expiration": DATE, } }
URL endpoint: https://api.aws3.link/remove
Method: POST
"header": { "x-api-key": STRING, "Content-Type": "application/json" }
"body": { "key": STRING }
Response:
"body": { "message": "Provided key has been removed", "metadata": { "longUrl": STRING, "key": STRING } }