API
You need to create an account to use the API. This way you will get an authentication token that you should provide with every request. The token will always be available for you on this page.
Base URL: https://synk.fun/api/v1/
Paths relative to the base URL
list/
— get all your links;
new/
— create a new link;
<code>/
— get extra data about an existing link;
update/<code>/
— update some fields of a link;
delete/<code>/
— delete a link (careful here).
Create links
You should use a POST method and pass a source
— the link that you want to shorten.
Create a new link using cURL:
curl -X POST https://synk.fun/api/v1/new/ -d "source=<THE LONG LINK>" -H "Authorization: Token <YOUR TOKEN>"
Using Python:
import requests
url = 'https://synk.fun/api/v1/new/'
auth_token = '<YOUR TOKEN>'
headers = {'Authorization': f'Token {auth_token}'}
data = {'source': '<THE LONG LINK>'}
r = requests.post(url, data=data, headers=headers)
result = r.json().get('link')
You will get an existing short link if you already created one with the same exact source.
Get a list of all your links
Using cURL, you can get a list of all your links by running a command like this:
curl https://synk.fun/api/v1/list/ -H "Authorization: Token <YOUR TOKEN>"
To get the same list using Python (and also pretty-print it), you can do the following:
import json
import requests
url = 'https://synk.fun/api/v1/list/'
auth_token = '<YOUR TOKEN>'
headers = {'Authorization': f'Token {auth_token}'}
r = requests.get(url, headers=headers)
result = r.json()
print(json.dumps(result, indent=4))
Get data about an existing link
Send a GET request including a code of the link to a path.
curl https://synk.fun/api/v1/<code>/ -H "Authorization: Token <YOUR TOKEN>"
Update existing link fields
Updatable fields: source
, code
, name
. Pass them in the body of a request using PUT or PATCH method.
curl -X PUT https://synk.fun/api/v1/update/<code>/ -d "name=<VALUE>&code=<VALUE>" -H "Authorization: Token <YOUR TOKEN>"
And here again is Python's Requests:
import requests
url = 'https://synk.fun/api/v1/update/<code>/'
auth_token = '<YOUR TOKEN>'
headers = {'Authorization': f'Token {auth_token}'}
data = {'source': 'value'}
r = requests.put(url, data=data, headers=headers)
Delete a link
Be careful if you don't want to lose the data you may need.
Send a DELETE request, passing a code of a link as usual.
curl -X DELETE https://synk.fun/api/v1/delete/<code>/ -H "Authorization: Token <YOUR TOKEN>"
And here again is Python's Requests:
import requests
url = 'https://synk.fun/api/v1/delete/<code>/'
auth_token = '<YOUR TOKEN>'
headers = {'Authorization': f'Token {auth_token}'}
r = requests.delete(url, headers=headers)