API documentation and resources

Contents

Capsulink API 1.0

Request and Response data format is JSON.

Get an API Key

Create a new API key (or get one from your Settings).

Request
curl https://www.capsulink.com/api/login \
-d '{"username":"<Username or email>","password":"<Password>"}'
Response
{
    "status":"success",
    "data":{
        "api_key":"<Some API key>"
    }
}

Capsulate a link

Optional parametrs:

  • "domain":"<Your domain>" - Create with a branded domain. Default: "".
  • "short_url":"<Your short URL>" - Create with a custom short URL. Default: "".
Request
curl https://www.capsulink.com/api/capsulate \
-H 'Api-Key: <Some API key>' \
-d '{"url":"<Some URL>"}'
Response
{
    "status":"success",
    "data":{
        "id":"<Capsule ID>",
        "short_url":"<Short URL>",
        "redirect_url":"http:\/\/cli.re\/<Short URL>",
        "stats_url":"http:\/\/cli.re\/<Short URL>+",
        "url":"<Some URL>",
        "folder":"None"
    }
}

Get capsule details

Request
curl https://www.capsulink.com/api/details \
-H 'Api-Key: <Some API key>' \
-d '{"id":"<Capsule ID>"}'
Response
{
    "status":"success",
    "data":{
        "id":"<Capsule ID>",
        "short_url":"<Short URL>",
        "redirect_url":"http:\/\/cli.re\/<Short URL>",
        "stats_url":"http:\/\/cli.re\/<Short URL>+",
        "url":"<Some URL>",
        "folder":"<Folder Name>|None"
    }
}

Change capsulated URL

Request
curl https://www.capsulink.com/api/set_url \
-H 'Api-Key: <Some API key>' \
-d '{"id":"<Capsule ID>","url":"<New URL>"}'
Response
{
    "status":"success",
    "data":{
        "id":"<Capsule ID>",
        "short_url":"<Short URL>",
        "redirect_url":"http:\/\/cli.re\/<Short URL>",
        "stats_url":"http:\/\/cli.re\/<Short URL>+",
        "url":"<New URL>",
        "folder":"<Folder Name>|None"
    }
}

Change capsule branded domain

Pass empty domain to reset default.

Request
curl https://www.capsulink.com/api/set_domain \
-H 'Api-Key: <Some API key>' \
-d '{"id":"<Capsule ID>","domain":"<Your domain>"}'
Response
{
    "status":"success",
    "data":{
        "id":"<Capsule ID>",
        "short_url":"<Short URL>",
        "redirect_url":"http:\/\/<Your domain>\/<Short URL>",
        "stats_url":"http:\/\/<Your domain>\/<Short URL>+",
        "url":"<Some URL>",
        "folder":"<Folder Name>|None"
    }
}

Change capsule short URL

Pass empty short URL to reset default.

Request
curl https://www.capsulink.com/api/set_short_url \
-H 'Api-Key: <Some API key>' \
-d '{"id":"<Capsule ID>","short_url":"<Your short URL>"}'
Response
{
    "status":"success",
    "data":{
        "id":"<Capsule ID>",
        "short_url":"<Your short URL>",
        "redirect_url":"http:\/\/cli.re\/<Your short URL>",
        "stats_url":"http:\/\/cli.re\/<Your short URL>+",
        "url":"<Some URL>",
        "folder":"<Folder Name>|None"
    }
}

Get capsule stats

Request
curl https://www.capsulink.com/api/stats \
-H 'Api-Key: <Some API key>' \
-d '{"id":"<Capsule ID>"}'
Response
{
    "status":"success",
    "data":{
        "click_stats":{
            "all":39,
            "current":39,
            "other":0
        },
        "graph":{
            "labels":["2016-05-30","2016-05-31"],
            "clicks":[39,0],
            "recapsulations":[39,null]
        },
        "referrer_stats":{
            "Twitter":{"clicks":20},
            "Email, IM and direct":{"clicks":18},
            "Capsulink":{"clicks":1}
        },
        "country_stats":{
            "LVA":{"clicks":24,"name":"Latvia"},
            "DEU":{"clicks":3,"name":"Germany"},
            "NLD":{"clicks":3,"name":"Netherlands"},
            "USA":{"clicks":3,"name":"United States"},
            "THA":{"clicks":1,"name":"Thailand"},
            "SWE":{"clicks":1,"name":"Sweden"},
            "Unknown":{"clicks":1,"name":"Unknown"},
            "IRL":{"clicks":1,"name":"Ireland"},
            "FRA":{"clicks":1,"name":"France"},
            "GBR":{"clicks":1,"name":"United Kingdom"}
        }
    }
}

Get capsule daily stats

Request
curl https://www.capsulink.com/api/stats_daily \
-H 'Api-Key: <Some API key>' \
-d '{"id":"<Capsule ID>","date":"2019-11-15"}'
Response
{
    "status":"success",
    "data":{
        "clicks":{
            "total":176
        },
    }
}

Delete capsule

Request
curl https://www.capsulink.com/api/delete \
-H 'Api-Key: <Some API key>' \
-d '{"id":"<Capsule ID>"}'
Response
{
    "status":"success",
    "data":"Capsule deleted"
}

Change capsule folder

Pass empty folder name to reset default.

Request
curl https://www.capsulink.com/api/set_folder \
-H 'Api-Key: <Some API key>' \
-d '{"id":"<Capsule ID>","folder":"<Folder Name>"}'
Response
{
    "status":"success",
    "data":{
        "id":"<Capsule ID>",
        "short_url":"<Your short URL>",
        "redirect_url":"http:\/\/cli.re\/<Your short URL>",
        "stats_url":"http:\/\/cli.re\/<Your short URL>+",
        "url":"<Some URL>",
        "folder":"<Folder Name>|None"
    }
}

Create a new folder

Optional parametrs:

  • "description":"<Description>" - Default: "".
Request
curl https://www.capsulink.com/api/create_folder \
-H 'Api-Key: <Some API key>' \
-d '{"title":"<Folder Name>"}'
Response
{
    "status":"success",
    "data":{
        "title":"<Folder Name>",
        "description":"<Folder Description>|null",
        "capsules":"<Count>"
    }
}

Delete a folder

Request
curl https://www.capsulink.com/api/delete_folder \
-H 'Api-Key: <Some API key>' \
-d '{"title":"<Folder Name>"}'
Response
{
    "status":"success",
    "data":"Folder deleted"
}

List all capsules. 1000 capsules per request.

Optional parametrs:

  • "page":<number> - Request particular page. Default: "1".
  • "order":<"asc"|"desc"> - Sort by creation time. Default: "asc".
  • "folder":<name> - List only in that particular folder. Default: "".
  • "created_from":<datetime> - Created after the given date. Time format: "YYYY-MM-DD". Default: "".
  • "created_to":<datetime> - Created before the given date. Time format: "YYYY-MM-DD". Default: "".
Request
curl https://www.capsulink.com/api/list \
-H 'Api-Key: <Some API key>' \
-d '{}'
Response
{
    "status":"success",
    "data":[
        {
            "id":"<Capsule ID>",
            "short_url":"<Your short URL>",
            "redirect_url":"http:\/\/cli.re\/<Your short URL>",
            "stats_url":"http:\/\/cli.re\/<Your short URL>+",
            "url":"<Some URL>",
            "folder":"<Folder Name>|None"
        },
        ...
    ]
}

List all folders

Request
curl https://www.capsulink.com/api/folders \
-H 'Api-Key: <Some API key>' \
-d '{}'
Response
{
    "status":"success",
    "data":[
        {
            "title":"<Folder Name>",
            "description":"<Folder Description>|null",
            "capsules":"<Count>"
        },
        ...
    ]
}