API documentation and resources

Contents

Capsulink API 1.0

Request and Response data format is JSON.

  • Capsulink API is a Premium feature. Check your limits at our pricing page
  • Use with any programming language and environment: PHP, Python, Node.js, JavaScript, TypeScript, C/C++, C#, Java, Go, R, Swift, Ruby, Perl, Kotlin, Rust, Scala, Erlang, Haskell, Objective C and more.
  • If you're looking for some help contact our support
  • For more information about Capsulink, you can visit our features page.

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: "".
  • "private":"<Privacy level>" - Set privacy. 1 - private, 0 - public. Default: "0".
  • "password":"<Password>" - Set password. Default: "".
  • "title":"<Title>" - Set title. Default: "" (loaded automatically, if possible).
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":"https:\/\/cli.re\/<Short URL>",
        "stats_url":"https:\/\/cli.re\/<Short URL>+",
        "url":"<Some URL>",
        "folder":"None",
        "private":0|1,
        "password_protected":0|1,
        "title":"<Title>"
    }
}

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":"https:\/\/cli.re\/<Short URL>",
        "stats_url":"https:\/\/cli.re\/<Short URL>+",
        "url":"<Some URL>",
        "folder":"<Folder Name>|None",
        "private":0|1,
        "password_protected":0|1,
        "title":"<Title>"
    }
}

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":"https:\/\/cli.re\/<Short URL>",
        "stats_url":"https:\/\/cli.re\/<Short URL>+",
        "url":"<New URL>",
        "folder":"<Folder Name>|None",
        "private":0|1,
        "password_protected":0|1,
        "title":"<Title>"
    }
}

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",
        "private":0|1,
        "password_protected":0|1,
        "title":"<Title>"
    }
}

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":"https:\/\/cli.re\/<Your short URL>",
        "stats_url":"https:\/\/cli.re\/<Your short URL>+",
        "url":"<Some URL>",
        "folder":"<Folder Name>|None",
        "private":0|1,
        "password_protected":0|1,
        "title":"<Title>"
    }
}

Change capsule privacy

1 - private, 0 - public.

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

Change capsule password

Pass empty string to remove password.

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

Change capsule title

Pass empty string to reset to auto mode.

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

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":"2024-12-11"}'
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":"https:\/\/cli.re\/<Your short URL>",
        "stats_url":"https:\/\/cli.re\/<Your short URL>+",
        "url":"<Some URL>",
        "folder":"<Folder Name>|None",
        "private":0|1,
        "password_protected":0|1,
        "title":"<Title>"
    }
}

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 '{"folder":"<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":"https:\/\/cli.re\/<Your short URL>",
            "stats_url":"https:\/\/cli.re\/<Your short URL>+",
            "url":"<Some URL>",
            "folder":"<Folder Name>|None",
            "private":0|1,
            "password_protected":0|1,
            "title":"<Title>"
        },
        ...
    ]
}

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