Documentation for https://api.an.si

AWS


Subscribe on AWS Marketplace
  • 1  Go to our listings page on AWS Marketplace.
  • 2  Subscribe to our Product.
  • 3  On the registration page, enter your valid email address and click on 'Continue'.
  • 4  Save your displayed API key somewhere secure.


  • Code samples

    The following code sample creates a short URL with a random key. The redirection page will display the an.si logo for 3 seconds before it redirects to the destination 'longUrl'


    const https = require("https")
    
    var data = JSON.stringify({
        "longUrl": "https://selenium.cloud/doc/aws/graphical-ubuntu.html#execute",
        "expireDays": 30,
        "redirectTimeout": 3,
        "redirectImage": "https://s3.amazonaws.com/an.si/logo-trans.png",
    });
    var options = {
        host: "api.an.si",
        path: "/shorten",
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
            'x-api-key': '<YourApiKey>'
        },
    };
    
    var req = https.request(options, (res) => {
      console.log('statusCode:', res.statusCode);
      console.log('headers:', res.headers);
    
      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",
      "expireDays": 30,
      "redirectTimeout": 3,
      "redirectImage": "https://s3.amazonaws.com/an.si/logo-trans.png",
    })
    response = requests.post('https://api.an.si/shorten', headers=headers, data=body)
    response = response.json()
    print(response)


    API endpoint: Shorten
    URL endpoint: https://api.an.si/shorten
    
    Method: POST
    "header": {   "x-api-key": STRING,   "Content-Type": "application/json" }
    "body": {   "longUrl": STRING,   "customKey": STRING,   "expireDays": NUMBER,   "redirectTimeout": NUMBER,   "redirectImage": STRING,   "customHtml": STRING, }
  • Required  "longUrl": The destination URL you want to redirect. Protocol (http, https) needs to be included.
  •  "customKey": Define a custom key ("an.si/customKey"). Passing no customKey will generate a random string as key.
  •  "expireDays": Define how many days the shortened URL until it will expire. Needs to be between 1 and 365. Default is 0, which means non-expiring link. Pro Feature
  •  "redirectTimeout": Define how long to stay on redirection page before longUrl gets opened. Needs to be between 1 and 10. Default is 0.
  •  "redirectImage": Define an image to display on redirection page. Needs to be an URL to a publicly available image. Image wont get stored, user is responsible to provide availability.
  •  "customHtml": Pass HTML code to be displayed on redirection page. We replace your '<body>' tag with our redirection code. When passing customHtml, redirectImage wont have any effect. Pro Feature
  • Response:
    
    "body": {   "shortUrl": STRING,   "parameters": {     "longUrl": STRING,     "key": STRING,     "expireDays": NUMBER,     "expireDate": DATE,     "redirectTimeout": NUMBER,     "redirectImage": STRING,     "customHtml": STRING   } }


    API endpoint: Update
    URL endpoint: https://api.an.si/update
    
    Method: POST
    "header": {   "x-api-key": STRING,   "Content-Type": "application/json" }
    "body": {   "key": STRING,   "newDestUrl": STRING,   "expireDays": NUMBER,   "redirectTimeout": NUMBER,   "redirectImage": STRING,   "customHtml": STRING, }
  • Required  "key": The key of the short URL you want to update. 'myKey' for an.si/myKey e.g.
  •  "newDestUrl": The updated destination URL you want to redirect. Protocol (http, https) needs to be included.
  •  "expireDays": Define how many days the shortened URL until it will expire from the current date of update request. Needs to be between 1 and 365. Default is 0, which means non-expiring link. Pro Feature
  •  "redirectTimeout": Define how long to stay on redirection page before longUrl gets opened. Needs to be between 1 and 10. Default is 0.
  •  "redirectImage": Define an image to display on redirection page. Needs to be an URL to a publicly available image. Image wont get stored, user is responsible to provide availability.
  •  "customHtml": Pass HTML code to be displayed on redirection page. We replace your '<body>' tag with our redirection code. When passing customHtml, redirectImage wont have any effect. Pro Feature
  • Response:
    
    "body": {   "shortUrl": STRING,   "parameters": {     "longUrl": STRING,     "key": STRING,     "expireDays": NUMBER,     "expireDate": DATE,     "redirectTimeout": NUMBER,     "redirectImage": STRING,     "customHtml": STRING   } }


    API endpoint: Remove
    URL endpoint: https://api.an.si/remove
    
    Method: POST
    "header": {   "x-api-key": STRING,   "Content-Type": "application/json" }
    "body": {   "key": STRING }
  • Required  "key": The key of the short URL you want to delete. 'myKey' for an.si/myKey e.g.


  • Copyright © by Noricum Cloud Solutions