← Developers
SDK Examples
Ready-to-use code snippets for popular languages.
PHP
$ch = curl_init('https://linkshor.com/api/create');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer YOUR_TOKEN',
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'organization_key' => 'YOUR_ORG_KEY',
'url_group_id' => '1',
'url' => 'https://example.com/page',
]));
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
Laravel
use Illuminate\Support\Facades\Http;
$response = Http::withToken('YOUR_TOKEN')
->post('https://linkshor.com/api/create', [
'organization_key' => 'YOUR_ORG_KEY',
'url_group_id' => '1',
'url' => 'https://example.com/page',
]);
$shortUrl = $response->json('data.short_url');
Node.js
const response = await fetch('https://linkshor.com/api/create', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
organization_key: 'YOUR_ORG_KEY',
url_group_id: '1',
url: 'https://example.com/page',
}),
});
const { data } = await response.json();
Python
import requests
response = requests.post(
'https://linkshor.com/api/create',
headers={'Authorization': f'Bearer {token}'},
json={
'organization_key': 'YOUR_ORG_KEY',
'url_group_id': '1',
'url': 'https://example.com/page',
}
)
short_url = response.json()['data']['short_url']
Go
body := []byte(`{
"organization_key": "YOUR_ORG_KEY",
"url_group_id": "1",
"url": "https://example.com/page"
}`)
req, _ := http.NewRequest("POST", "https://linkshor.com/api/create", bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer "+token)
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)