Developers crunch it!

First and foremost; Please make sure that you read & understand diz.link's Privacy & Terms :-)

Alright, let's begin!

Each section of this page contains a brief description, an example, and a link to more detailed information. The examples in this guide all use a REST-style JSON protocol.

The examples use curl and OACurl to show you how to get started interacting with the API quickly, right from the command line. When developing your application, however, feel free to use your preferred clients and libraries.

To be able to use diz.link API endpoints, you must pass a valid apptoken with every API call!
You can pass as parameter or in the header! e.g.
  • parameter >> http://API_BASE/endpoint/?apptoken={your apptoken}
  • header >> x-apptoken={your apptoken}
How do I get apptoken?

Just access diz.link site from a web browser (chrome, firefox, opera, ...), that's all!

As you are doing so now...

Here's your apptoken (uniquely generated based on your active session!):

API Endpoints what-how

API Base URL (API_BASE): https://api.diz.link

Remember also to check clients/libraries you may be able to use.

https://api.diz.link/dev/shorten/

The DIZ.LINK API allows you to shorten URLs just as you would on diz.link. For example, to shorten the URL http://maps.google.com, send the following request:

POST https://api.diz.link/dev/shorten/
Content-Type: application/json

{"long_link": "http://maps.google.com","simple_links": ["gomaps","mapsgo"]}

simple_links is optional, and can be used to assign custom names to this link!

For instance, you could issue the following curl command:

curl https://api.diz.link/dev/shorten/ 
  -H 'x-apptoken: ' 
  -H 'Content-Type: application/json' 
  -d '{"long_link": "http://maps.google.com","simple_links":["gomaps","mapsgo"]}'
 

If successful, the response will look like:

{
 "meta": {
 	"code": 200
 }, 
 "data": {
	"short_link": "http://diz.link/40cc1a",
	"long_link": "http://maps.google.com", 
	"simple_links": ["gomaps","mapsgo"]
 }
}
  • short_link is the short URL that expands to the long URL you provided.
  • long_link is the long URL to which it expands. This will be the same as the URL you provided.
  • simple_links is the simple (& human friendly) names you've assigned to this URL.

If any error occurs, the response will look like:

{
 "meta": {
	"code": 400, 
	"errorType": "input_error",  
	"errorDetail": "The simple_link must be more than 5 and less than 21 characters long"
 }
}
  • code is the http status code.
  • errorType is keyword defining the errorType.
  • errorDetail is description of the error in detail (which can be used to display to the user).
https://api.diz.link/dev/{dizlink_id}.json

You can call this method to expand any diz.link short URL. For example, to expand http://diz.link/40cc1a, send the following request:

GET https://api.diz.link/dev/{dizlink_id}.json

For instance, you could issue the following curl command:

curl 'https://api.diz.link/dev/40cc1a.json?apptoken='

If successful, the response will look like:

{
 "meta": {
 	"code": 200
 }, 
 "data": {
	"short_link": "http://diz.link/40cc1a",
	"long_link": "http://maps.google.com", 
	"simple_links": ["gomaps","mapsgo"],
	"createdAt": "2014-09-16T06:48:57+0000"
 }
}
https://api.diz.link/dev/{dizlink_id}.json/stats
curl 'https://api.diz.link/dev/40cc1a.json/stats?apptoken='

If successful, the response will look like:

{
	"meta":{"code":200},
	"data":{
		"dizlink_id":"40cc1a"
		,"dizlink":{"short_link":"40cc1a","long_link":"http://maps.google.com","simple_links":["gomaps"],"userid":"sessionid_assigned_for_apptoken"}
		,"stats":{
			"clicks":{"40cc1a":7,"gomaps":1,"all":8}
			,"browsers":{"cURL":3,"Chrome":5}
			,"platforms":{"OS X 10_9 Mavericks":5,"unknown":3}
			,"types":{"Browser":5,"Library":3}
			}
		,"_created":1410854319794
		,"updatedAtStr":"2014-09-16T09:58:39+0200"
		}
}
https://api.diz.link/dev/mylinks.json

You can call this method to get all links created by this apptoken (). For example, send the following request:

GET https://api.diz.link/dev/mylinks.json

For instance, you could issue the following curl command:

curl 'https://api.diz.link/dev/mylinks.json?apptoken='

If successful, the response will look like:


{
	"meta":{
		"code":200
	},
	"data":[
		{"short_link":"http://diz.link/40cc1a","simple_links":["gomaps","mapsgo"],"long_link":"http://maps.google.com","createdAt":"2014-09-16T06:48:57+0000"}
	]
}