> For the complete documentation index, see [llms.txt](https://docs.mora-bot.kr/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mora-bot.kr/api/guide/version1/urlshortening.md).

# URL단축

### Templates

* API는 모두 GET 메서드를 사용합니다
* GET URL : <https://mora-bot.kr/api/v1/shorten?url={단축할> URL}

| Field    | Type   | Description |
| -------- | ------ | ----------- |
| url      | String | 반환된 단축 URL  |
| code     | String | 반환된 단축 코드   |
| original | String | 호출된 URL     |

{% code lineNumbers="true" %}

```json
// 응답 내용
{
    "message":"successfully registered link",
    "status":200,
    "url":"https://mora-bot.kr/u/Qjadtj3",
    "code":"Qjadtj3",
    "original":"https://mora-bot.kr",
    "success":true
}
```

{% endcode %}

### NodeJS

{% code lineNumbers="true" %}

```javascript
// node-fetch
let link = '단축할 URL'
const fetch = require('node-fetch')
fetch(`https://mora-bot.kr/api/v1/shorten?url=${encodeURI(link)}`)
    .then(res => res.json())
    .then(json => {
        console.log(`원래 링크 : ${json.original}`)
        console.log(`변환된 링크 : ${json.url}`)
        console.log(`URL 해시 : ${json.code}`)
    });

// request
let link = '단축할 URL'
let api_url = `https://mora-bot.kr/api/v1/shorten?url=${encodeURI(link)}`
const request = require('request');
let options = {
    url: api_url
}
request.get(options, function (error, response, body) {
    if (!error && response.status == 200) {
        let json = JSON.parse(body)
        console.log(`원래 링크 : ${json.original}`)
        console.log(`변환된 링크 : ${json.url}`)
        console.log(`URL 해시 : ${json.code}`)
    } else {
        console.log('error = ' + response.errorcode);
    }
});
```

{% endcode %}

### Python

{% code lineNumbers="true" %}

```python
import requests

response = requests.get("https://mora-bot.kr/api/v1/shorten?url=https://mora-bot.kr")
result = response.json()

if response.status == 200:
  print(result)
else:
  print(f"Error Code: {response.errorcode}")
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.mora-bot.kr/api/guide/version1/urlshortening.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
