๐Ÿ”— SHORT API ๋ฌธ์„œ

์งง์€ URL ์„œ๋น„์Šค REST API ๋ ˆํผ๋Ÿฐ์Šค

โšก ๋น ๋ฅธ ์‹œ์ž‘

๋‹จ ํ•œ ์ค„์˜ ์ฝ”๋“œ๋กœ ์งง์€ 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-KEYstring์„œ๋ฒ„์— ์„ค์ •๋œ API Key

Request Body

ํŒŒ๋ผ๋ฏธํ„ฐํƒ€์ž…ํ•„์ˆ˜์„ค๋ช…
urlstringํ•„์ˆ˜๋‹จ์ถ•ํ•  ์›๋ณธ URL
custom_codestring์„ ํƒ์ปค์Šคํ…€ ์งง์€ ์ฝ”๋“œ

์˜ˆ์ œ

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

ํŒŒ๋ผ๋ฏธํ„ฐํƒ€์ž…๊ธฐ๋ณธ๊ฐ’์„ค๋ช…
pageinteger1ํŽ˜์ด์ง€ ๋ฒˆํ˜ธ
limitinteger50ํŽ˜์ด์ง€๋‹น ํ•ญ๋ชฉ ์ˆ˜
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๋งŒ ์ง€์›ํ•ฉ๋‹ˆ๋‹ค.