← 开发者工具

URL 缩短器

GET /url/shorten

将任何长 URL 缩短为紧凑、可分享的短链接。返回重定向到原始链接的短 URL。适用于字数有限的社交媒体分享、为印刷材料生成简洁链接、追踪链接使用情况,以及使带有许多参数的长 URL 更易管理和用户友好。

参数

url 必填

URL to shorten

请求示例

基本用法
curl "https://nordapi.ee/api/v1/url/shorten?url=https://nordapi.ee"
Shorten the NordAPI URL
curl "https://nordapi.ee/api/v1/url/shorten?url=https://nordapi.ee"
Shorten a long GitHub URL
curl "https://nordapi.ee/api/v1/url/shorten?url=https://github.com/elixir-lang/elixir"

实时响应

HTTP 500: "# UndefinedFunctionError at GET /api/v1/url/shorten\n\nException:\n\n    ** (UndefinedFunctionError) function App.UrlShortener.shorten/1 is undefined (module App.UrlShortener is not available)\n        (app 0.1.0) App.UrlShortener.shorten(\"\")\n        (app 0.1.0) lib/app_web/controllers/api/v1/url_controller.ex:7: AppWeb.API.V1.UrlController.shorten/2\n        (app 0.1.0) lib/app_web/controllers/api/v1/url_controller.ex:1: AppWeb.API.V1.UrlController.action/2\n        (app 0.1.0) lib/app_web/controllers/api/v1/url_controller.ex:1: AppWeb.API.V1.UrlController.phoenix_controller_pipeline/2\n        (phoenix 1.8.5) lib/phoenix/router.ex:416: Phoenix.Router.__call__/5\n        (app 0.1.0) lib/app_web/endpoint.ex:1: AppWeb.Endpoint.plug_builder_call/2\n        (app 0.1.0) deps/plug/lib/plug/debugger.ex:155: AppWeb.Endpoint.\"call (overridable 3)\"/2\n        (app 0.1.0) lib/app_web/endpoint.ex:1: AppWeb.Endpoint.call/2\n        (phoenix 1.8.5) lib/phoenix/endpoint/sync_code_reload_plug.ex:22: Phoenix.Endpoint.SyncCodeReloadPlug.do_call/4\n        (bandit 1.10.4) lib/bandit/pipeline.ex:131: Bandit.Pipeline.call_plug!/2\n        (bandit 1.10.4) lib/bandit/pipeline.ex:42: Bandit.Pipeline.run/5\n        (bandit 1.10.4) lib/bandit/http1/handler.ex:13: Bandit.HTTP1.Handler.handle_data/3\n        (bandit 1.10.4) lib/bandit/delegating_handler.ex:18: Bandit.DelegatingHandler.handle_data/3\n        (bandit 1.10.4) lib/bandit/delegating_handler.ex:8: Bandit.DelegatingHandler.handle_continue/2\n        (stdlib 7.3) gen_server.erl:2424: :gen_server.try_handle_continue/3\n        (stdlib 7.3) gen_server.erl:2291: :gen_server.loop/4\n        (stdlib 7.3) proc_lib.erl:333: :proc_lib.init_p_do_apply/3\n    \n\n## Connection details\n\n### Params\n\n    %{\"url\" => \"\"}\n\n### Request info\n\n  * URI: http://localhost:4000/api/v1/url/shorten\n  * Query string: url=\n\n### Headers\n  \n  * accept-encoding: gzip\n  * host: localhost:4000\n  * user-agent: req/0.5.17\n\n### Session\n\n    %{}\n"