v1_short-urls_shorten.json 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. {
  2. "get": {
  3. "operationId": "shortenUrl",
  4. "tags": [
  5. "Short URLs"
  6. ],
  7. "summary": "Create a short URL",
  8. "description": "Creates a short URL in a single API call. Useful for third party integrations.",
  9. "parameters": [
  10. {
  11. "$ref": "../parameters/version.json"
  12. },
  13. {
  14. "name": "apiKey",
  15. "in": "query",
  16. "description": "The API key used to authenticate the request",
  17. "required": true,
  18. "schema": {
  19. "type": "string"
  20. }
  21. },
  22. {
  23. "name": "longUrl",
  24. "in": "query",
  25. "description": "The URL to be shortened",
  26. "required": true,
  27. "schema": {
  28. "type": "string"
  29. }
  30. },
  31. {
  32. "name": "format",
  33. "in": "query",
  34. "description": "The format in which you want the response to be returned. You can also use the \"Accept\" header instead of this",
  35. "required": false,
  36. "schema": {
  37. "type": "string",
  38. "enum": [
  39. "txt",
  40. "json"
  41. ]
  42. }
  43. }
  44. ],
  45. "responses": {
  46. "200": {
  47. "description": "The list of short URLs",
  48. "content": {
  49. "application/json": {
  50. "schema": {
  51. "$ref": "../definitions/ShortUrl.json"
  52. }
  53. },
  54. "text/plain": {
  55. "schema": {
  56. "type": "string"
  57. }
  58. }
  59. },
  60. "examples": {
  61. "application/json": {
  62. "longUrl": "https://github.com/shlinkio/shlink",
  63. "shortUrl": "https://doma.in/abc123",
  64. "shortCode": "abc123",
  65. "dateCreated": "2016-08-21T20:34:16+02:00",
  66. "visitsCount": 0,
  67. "tags": [
  68. "games",
  69. "tech"
  70. ],
  71. "meta": {
  72. "validSince": "2017-01-21T00:00:00+02:00",
  73. "validUntil": null,
  74. "maxVisits": 100
  75. },
  76. "domain": null,
  77. "title": null
  78. },
  79. "text/plain": "https://doma.in/abc123"
  80. }
  81. },
  82. "400": {
  83. "description": "The long URL was not provided or is invalid.",
  84. "content": {
  85. "application/problem+json": {
  86. "schema": {
  87. "$ref": "../definitions/Error.json"
  88. }
  89. },
  90. "text/plain": {
  91. "schema": {
  92. "type": "string"
  93. }
  94. }
  95. },
  96. "examples": {
  97. "application/problem+json": {
  98. "title": "Invalid URL",
  99. "type": "INVALID_URL",
  100. "detail": "Provided URL foo is invalid. Try with a different one.",
  101. "status": 400,
  102. "url": "https://invalid-url.com"
  103. },
  104. "text/plain": "INVALID_URL"
  105. }
  106. },
  107. "500": {
  108. "description": "Unexpected error.",
  109. "content": {
  110. "application/problem+json": {
  111. "schema": {
  112. "$ref": "../definitions/Error.json"
  113. }
  114. },
  115. "text/plain": {
  116. "schema": {
  117. "type": "string"
  118. }
  119. }
  120. },
  121. "examples": {
  122. "application/problem+json": {
  123. "error": "INTERNAL_SERVER_ERROR",
  124. "message": "Unexpected error occurred"
  125. },
  126. "text/plain": "INTERNAL_SERVER_ERROR"
  127. }
  128. }
  129. }
  130. }
  131. }