API

Request and Response data format is JSON.

Business plan: Limited to 3000 capsules per month, 150 capsules per day.

Ultimate plan: Limited to 30000 capsules per month, 1500 capsules per day.


API Calls

Get API key

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

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"}
        }
    }
}
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 parameter "description" is available)

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 (pass an optional paramater "folder" to list only in that particular folder)

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>"
        },
        ...
    ]
}