โก ๋น ๋ฅธ ์์
๋จ ํ ์ค์ ์ฝ๋๋ก ์งง์ URL์ ๋ง๋ค์ด๋ณด์ธ์!
curl -X POST https://short.kdnoito.me/api/create \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com"}'
๐ ๊ธฐ๋ณธ ์ ๋ณด
Base URL: https://short.kdnoito.me
์ธ์ฆ: HTTP Header X-API-KEY ํ์
์๋ต ํ์: JSON
CORS: ๋ชจ๋ ๋๋ฉ์ธ ํ์ฉ (*)
๐ก API ์๋ํฌ์ธํธ
POST /api/create
์๋ก์ด ์งง์ URL์ ์์ฑํฉ๋๋ค.
Headers
| Header | ๊ฐ | ์ค๋ช
|
X-API-KEY | string | ์๋ฒ์ ์ค์ ๋ API Key |
Request Body
| ํ๋ผ๋ฏธํฐ | ํ์
| ํ์ | ์ค๋ช
|
url | string | ํ์ | ๋จ์ถํ ์๋ณธ URL |
custom_code | string | ์ ํ | ์ปค์คํ
์งง์ ์ฝ๋ |
์์
curl -X POST https://short.kdnoito.me/api/create \
-H "Content-Type: application/json" \
-H "X-API-KEY: YOUR_API_KEY" \
-d '{"url": "https://example.com", "custom_code": "mylink"}'
JavaScript
const response = await fetch('https://short.kdnoito.me/api/create', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-KEY': 'YOUR_API_KEY'
},
body: JSON.stringify({ url: 'https://example.com' })
});
const data = await response.json();
Response
{
"success": true,
"short_code": "mylink",
"short_url": "https://short.kdnoito.me/mylink",
"long_url": "https://example.com",
"created_at": "2026-01-05 12:34:56"
}
GET /api/list
๋ชจ๋ ์งง์ URL ๋ชฉ๋ก์ ์กฐํํฉ๋๋ค.
Query Parameters
| ํ๋ผ๋ฏธํฐ | ํ์
| ๊ธฐ๋ณธ๊ฐ | ์ค๋ช
|
page | integer | 1 | ํ์ด์ง ๋ฒํธ |
limit | integer | 50 | ํ์ด์ง๋น ํญ๋ชฉ ์ |
curl https://short.kdnoito.me/api/list?page=1&limit=10
Response
{
"success": true,
"data": [
{
"short_code": "mylink",
"short_url": "https://short.kdnoito.me/mylink",
"long_url": "https://example.com",
"clicks": 42,
"created_at": "2026-01-05 12:34:56",
"last_accessed": "2026-01-05 14:20:30"
}
],
"pagination": { "page": 1, "limit": 10, "total": 1, "pages": 1 }
}
GET /api/stats/{code}
ํน์ ์งง์ URL์ ํต๊ณ๋ฅผ ์กฐํํฉ๋๋ค.
curl https://short.kdnoito.me/api/stats/mylink
Response
{
"success": true,
"data": {
"short_code": "mylink",
"short_url": "https://short.kdnoito.me/mylink",
"long_url": "https://example.com",
"clicks": 42,
"created_at": "2026-01-05 12:34:56",
"last_accessed": "2026-01-05 14:20:30"
}
}
DELETE /api/delete/{code}
์งง์ URL์ ์ญ์ ํฉ๋๋ค.
curl -X DELETE https://short.kdnoito.me/api/delete/mylink
Response
{
"success": true,
"message": "์ญ์ ๋์์ต๋๋ค",
"short_code": "mylink"
}
๐ก ์ฌ์ฉ ์์
HTML์์ ์ฌ์ฉํ๊ธฐ
<script>
async function shortenUrl(url) {
const res = await fetch('https://short.kdnoito.me/api/create', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-KEY': 'YOUR_API_KEY'
},
body: JSON.stringify({ url })
});
const data = await res.json();
console.log(data.short_url);
}
</script>
Python์์ ์ฌ์ฉํ๊ธฐ
import requests
response = requests.post(
'https://short.kdnoito.me/api/create',
headers={'X-API-KEY': 'YOUR_API_KEY'},
json={'url': 'https://example.com'}
)
print(response.json()['short_url'])
PHP์์ ์ฌ์ฉํ๊ธฐ
$data = json_encode(['url' => 'https://example.com']);
$opts = [
'http' => [
'method' => 'POST',
'header' => [
'Content-Type: application/json',
'X-API-KEY: YOUR_API_KEY'
],
'content' => $data
]
];
$result = file_get_contents(
'https://short.kdnoito.me/api/create',
false,
stream_context_create($opts)
);
$response = json_decode($result);
echo $response->short_url;
โ FAQ
Q: API ์ฌ์ฉ์ ์ ํ์ด ์๋์?
A: ํ์ฌ๋ ์ฌ์ฉ ์ ํ์ด ์์ต๋๋ค.
Q: ์ปค์คํ
์ฝ๋๋ฅผ ์ฌ์ฉํ ์ ์๋์?
A: ๋ค, custom_code ํ๋ผ๋ฏธํฐ๋ฅผ ์ฌ์ฉํ์ธ์. ์๋ฌธ์, ์ซ์, -, _ ๋ง ๊ฐ๋ฅํฉ๋๋ค.
Q: HTTPS๋ฅผ ์ง์ํ๋์?
A: ํ์ฌ๋ HTTP๋ง ์ง์ํฉ๋๋ค.