shorten

post
Shorten a URL

https://app.ayrshare.com/api/shorten
URL Shortener. Submit a URL and get a shortened URL to save characters, e.g. Twitter. Note: in the /post endpoint you automatically shorten URLs in the post text.
Request
Response
Request
Path Parameters
url
optional
string
URL to be shortened
Headers
Authorization
optional
string
Format: Authorization: Bearer [API Key] See Overview for more information.
Response
200: OK
Return of the shortened URL
https://ayr.app/l/unique

Request Example

cURL
Node.js
Python
cURL
curl \
-H "Authorization: Bearer [API Key]" \
-H 'Content-Type: application/json' \
-d '{"url": "https://www.ayrshare.com"}' \
-X POST https://app.ayrshare.com/api/shorten
Node.js
const fetch = require("node-fetch");
const API_KEY = "Your API Key";
const url = "https://www.ayrshare.com";
fetch("https://app.ayrshare.com/api/shorten", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({ url }),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
Python
import requests
payload = {'url': 'https://www.ayrshare.com'}
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer [API_KEY]'}
r = requests.post('https://app.ayrshare.com/api/shorten',
json=payload,
headers=headers)
print(r.json())