1.1. URL
1.2. Requests
1.3. Responses
2.2 List of links
3.1 Create group
3.2 List of groups
3.3 Delete group
Piq.ru API allows you to create short links, create link groups, manage links and link groups, get statistical information.
Our main API service is available here:
https://piq.ru/api
You need to use in HTTP requests only HTTPS protocol and UTF-8 encoding. All requests require a header X-Piq-Api-Token.
All responses are returned in JSON format and UTF-8 encoding.
Possible response HTTP status codes:
POST /links/create
Service alows to create short link with any parameters
String
URL to be shortenedString
This value will be displayed as an identifier. For example for "cool" alias, the short link will look like this - https://piq.ru/cool. Max length 10 characters. By default, the alias will be randomly generated.Boolean
By choosing the PUBLIC type, the link may be available to other Internet users. If you want the link to be private, set the value to Personal. By default value is TRUE
STRING
Set a password to protect your links from unauthorized access. By default this value is NULL.INTEGER
The id of one of your groups. By setting the identifier, the created link will be available among other links within the group. By default this value is NULL.DATE
Format 'Y-m-d'. The date until which the link will be available. After the expiration of the period, referrals to the link will be unavailable. If this parameter is not set, then the link will always be available. By default this value is NULL.curl --request POST \
--url https://piq.ru/api/links/create \
--header 'content-type: application/json' \
--header 'X-Piq-Api-Token: XXXXXX' \
--data '{
"url":"https://www.api.com",
"alias":"cool",
"is_public": true,
"group_id":2
}'
{
"successful": true,
"message": "Link successfully created",
"link": {
"long_url": "https://www.api.com",
"short": "cool",
"hits": 0,
"group": {
"id": 2,
"name": "Test Group",
"short": "wow",
"description": "Description of the group",
"url": "https://piq.ru/g/wow"
}
},
"short_url": "https://piq.ru/cool",
"qr": {
"base64": "iVBORw0KGgoAAAANSUhEUgAAASwAAAEsAQAAAABRBrPYAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QAAd2KE6QAAAGPSURBVGje7ZpdroQgDIV5Y9m4ZHbQ64iUU/7u43TIIcag8+nE1LanxRB0RLnHvb+nqU4mg9hPYe+mh8NN3vs8m+R21fsTMTeYMSjaNFqgu7bOiXnG0D0TseOwnZ/mz03Knphz7GPxHFY2bc5eMEjQ84BP7FsYaiSc/CuluvxLzCc2FcDPEBwZYng054l5wMbKJYFr69ZhqQTzEs+J+cbUrCOWalJuyVexOiHmBHt9E3UR2vdhmqdrRs7EXGO91h0x24kq+qo5clVcxLxgM6WUsjk0TSfQUULMHzZvNYzaWKtUeCX69yQT84Whb2JAbidrtdvqX8zIp2DXEU/6GtE2jlaYpuYErwf+BTEXWJdJMcOCodXuqr7ENhILQMwVtlx+tR0M49GqvoSYF2xUQTulFALWubt+IzFP2NymNjuLzKukA7DriCc1a22y7fDHxTcw4/rdz2LXcU+6D7lGMolZyyPmF9OSZ4Nh5avrO6t0TMwHNmkPxl5uaZRO2awCEPs+NkTjDpuvsIfWmBJivrA/OACaB5gWD2cAAAAASUVORK5CYII="
}
}
Boolean
Successful requestString
Text message. By default is NULLString
Source urlString
Alias of the short linkInteger
Number of clicks on the linkInteger
Id of the link groupString
Name of the link groupString
Description of the link groupString
Url of the link groupString
Short linkString
Image of the QR code of the link in base64 formatGET /links
Piq.ru Api alows to get list of your links.
Integer
The number of links contained in the result. Max value is 25. By default is 25.Integer
The number of items to skip. By default is 0.Integer
Id of one of your groups. The result will include links for this group. By default NULL.curl --header 'X-Piq-Api-Token: XXXXXXX' 'https://piq.ru/api/links?limit=2&offset=3&group_id=2'
{
"successful": true,
"message": "",
"count": 6,
"limit": 2,
"offset": 3,
"links": [
{
"long_url": "https://docs.google.com/",
"short": "A",
"hits": 0,
"group": {
"id": 2,
"name": "Test Group",
"short": "wow",
"description": "Description of the group",
"url": "https://piq.ru/g/wow"
},
"short_url": "https://piq.local/A",
"qr": {
"base64": "1TcdDYAfMJNqAAvxewusLbDh+eIg1OXqjeFtvb00cj5APCyGNHrBqVp7+xfCz6RQ65cyevtaKqzVMErWArWF9N0CDgAXOznjb22eh+xl38dHJ53tnhbcmLZX3vEvflXe62YxtW+TZ7ftVXsVD4UALrcFGwA7ttu786rAIBmckqMLgKAw4OZi6blE1tyadXIuzEuBQDGnTRkDwHee5DzEu0eAQAfkOlQ8QoA4EHKzNYwiXVpYxlDaKPQze7IPubIuYbCUNZbA6P4FIY9BYYsnCc9WcmK2A+AN4PMEBsbfMCVT8/890/wQcvtzWzzD1chFDtDsaIiFJfqLFXwCpaCNWBMh52xZfCe5Twzwh57GZGSPnwDZE+zOSjvzujc6Rk0QAcO5OZesoE1JjZWy3lXe9pv/kJbepEa104O4aKxqzt15C0hCfPFLk2ShDzqsk4WT60ne+5l3xixy7l9a5TmzyOw4osovB0AzPwIOoUGzXI2wR3R84l8u0J1lip4BUvBUrC+APT/l5ygYhinPbUAAAAASUVORK5CYII="
},
"active_before":"2020-12-15"
},
{
"long_url": "http://test.ru",
"short": "p",
"hits": 0,
"group": {
"id": 2,
"name": "Test Group",
"short": "wow",
"description": "Description of the group",
"url": "https://piq.ru/g/wow"
},
"short_url": "https://piq.local/p",
"qr": {
"base64": "1rc1av1mtOveAmEWABxawgAUsBCxgAQtYwFpR1WxuuHieo/JZlKquPv5qh9Ud25/bDQLrbzVFrOxOP0pVMY73+3ZY272afQfiNg+1Zo6crHfNKx3ELAI8sIAFLGAhYAELWMAC1orq2tyw9ESnFXiU+ktYt5t2WLul99XLjiLypf4eJjvKDZnZ9FgbsrjMoz2s4MfTcrJKyXyp3gkcNTuK1DQ7s+pcbTgmJysBHljAAhawELCABSxgAQtYSNG/sv+mdR376s4AAAAASUVORK5CYII="
},
"active_before": null
}
]
}
Boolean
Successful requestString
Text message. By default is NULLInteger
Total number of links on requestInteger
The number of links contained in the result.Integer
The number of items to skip.Array of Link
List of links.String
Source urlString
Alias of the short linkInteger
Number of clicks on the linkInteger
Id of the link groupString
Name of the link groupString
Description of the link groupString
Url of the link groupString
Short linkString
Image of the QR code of the link in base64 formatDate|null
The date until which the link will be available. After the expiration of the period, referrals to the link will be unavailable. If this parameter is not set, then the link will always be available.POST|DELETE /links/delete/<alias>
You can remove your short link using the link alias.
curl --request POST \
--url https://piq.local/api/links/delete/cool \
--header 'content-type: application/json' \
--header 'X-Piq-Api-Token: XXXXXX'
{
"successful": true,
"message": "Link removed"
}
POST /groups/create
Service alows to create groups for your links.
String
Group nameString
Group description. Default NULLString
This value will be displayed as an identifier. For example for "super" alias, link to new group will look like this - https://piq.ru/g/super. Max length 10 characters. By default, the alias will be randomly generated.Boolean
Whether this link group is publicly viewable. By default value is TRUE
Boolean
If set, the above URL will redirect to a random link from the group instead of displaying all links belonging to the group. By default value is FALSE
curl --request POST \
--url https://piq.ru/api/groups/create \
--header 'content-type: application/json' \
--header 'X-Piq-Api-Token: XXXXXX' \
--data '{
"name":"My links",
"description":"Links to my social networks",
"alias": "super",
"is_active":true,
"is_rotation":true
}'
{
"successful": true,
"message": "Group created",
"group": {
"id": 3,
"name": "My links",
"short": "super",
"description": "Links to my social networks",
"url": "https://piq.local/g/super"
}
}
Boolean
Successful requestString
Text message.Integer
Group IDString
Group nameString
Group aliasString
Group descriptionString
Group urlGET /groups
You can receive list of your groups.
Integer
The number of groups contained in the result. Max value is 100. By default is 100.Integer
The number of items to skip. By default is 0.curl --request GET \
--url https://piq.ru/api/groups \
--header 'token: XXXXX'
{
"successful": true,
"message": "",
"count": 1,
"groups": [
{
"id": 3,
"name": "My links",
"short": "super",
"description": "Links to my social networks",
"url": "https://piq.local/g/super"
}
]
}
Boolean
Successful requestString
Text message.Array of Group
List of your groups.String
Group idString
Group nameString
Group aliasString
Group descriptionString
Group urlPOST|DELETE /groups/delete/<group_id>
You can remove your group using the group id.
curl --request POST \
--url https://piq.ru/api/groups/delete/3 \
--header 'content-type: application/json' \
--header 'X-Piq-Api-Token: XXXXX'
{
"successful": true,
"message": "Group removed"
}