async-api.json 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. {
  2. "asyncapi": "2.0.0",
  3. "info": {
  4. "title": "Shlink",
  5. "version": "2.0.0",
  6. "description": "Shlink, the self-hosted URL shortener",
  7. "license": {
  8. "name": "MIT",
  9. "url": "https://github.com/shlinkio/shlink/blob/develop/LICENSE"
  10. }
  11. },
  12. "defaultContentType": "application/json",
  13. "channels": {
  14. "http://shlink.io/new-visit": {
  15. "subscribe": {
  16. "summary": "Receive information about any new visit occurring on any short URL.",
  17. "operationId": "newVisit",
  18. "message": {
  19. "payload": {
  20. "type": "object",
  21. "additionalProperties": false,
  22. "properties": {
  23. "shortUrl": {
  24. "$ref": "#/components/schemas/ShortUrl"
  25. },
  26. "visit": {
  27. "$ref": "#/components/schemas/Visit"
  28. }
  29. }
  30. }
  31. }
  32. }
  33. },
  34. "http://shlink.io/new-visit/{shortCode}": {
  35. "parameters": {
  36. "shortCode": {
  37. "description": "The short code of the short URL",
  38. "schema": {
  39. "type": "string"
  40. }
  41. }
  42. },
  43. "subscribe": {
  44. "summary": "Receive information about any new visit occurring on a specific short URL.",
  45. "operationId": "newShortUrlVisit",
  46. "message": {
  47. "payload": {
  48. "type": "object",
  49. "additionalProperties": false,
  50. "properties": {
  51. "shortUrl": {
  52. "$ref": "#/components/schemas/ShortUrl"
  53. },
  54. "visit": {
  55. "$ref": "#/components/schemas/Visit"
  56. }
  57. }
  58. }
  59. }
  60. }
  61. },
  62. "http://shlink.io/new-orphan-visit": {
  63. "subscribe": {
  64. "summary": "Receive information about any new orphan visit.",
  65. "operationId": "newOrphanVisit",
  66. "message": {
  67. "payload": {
  68. "type": "object",
  69. "additionalProperties": false,
  70. "properties": {
  71. "visit": {
  72. "$ref": "#/components/schemas/OrphanVisit"
  73. }
  74. }
  75. }
  76. }
  77. }
  78. }
  79. },
  80. "components": {
  81. "schemas": {
  82. "ShortUrl": {
  83. "type": "object",
  84. "properties": {
  85. "shortCode": {
  86. "type": "string",
  87. "description": "The short code for this short URL."
  88. },
  89. "shortUrl": {
  90. "type": "string",
  91. "description": "The short URL."
  92. },
  93. "longUrl": {
  94. "type": "string",
  95. "description": "The original long URL."
  96. },
  97. "dateCreated": {
  98. "type": "string",
  99. "format": "date-time",
  100. "description": "The date in which the short URL was created in ISO format."
  101. },
  102. "visitsCount": {
  103. "type": "integer",
  104. "description": "The number of visits that this short URL has recieved."
  105. },
  106. "tags": {
  107. "type": "array",
  108. "items": {
  109. "type": "string"
  110. },
  111. "description": "A list of tags applied to this short URL"
  112. },
  113. "meta": {
  114. "$ref": "#/components/schemas/ShortUrlMeta"
  115. },
  116. "domain": {
  117. "type": "string",
  118. "description": "The domain in which the short URL was created. Null if it belongs to default domain."
  119. }
  120. },
  121. "example": {
  122. "shortCode": "12C18",
  123. "shortUrl": "https://doma.in/12C18",
  124. "longUrl": "https://store.steampowered.com",
  125. "dateCreated": "2016-08-21T20:34:16+02:00",
  126. "visitsCount": 328,
  127. "tags": [
  128. "games",
  129. "tech"
  130. ],
  131. "meta": {
  132. "validSince": "2017-01-21T00:00:00+02:00",
  133. "validUntil": null,
  134. "maxVisits": 100
  135. },
  136. "domain": "example.com"
  137. }
  138. },
  139. "ShortUrlMeta": {
  140. "type": "object",
  141. "required": [
  142. "validSince",
  143. "validUntil",
  144. "maxVisits"
  145. ],
  146. "properties": {
  147. "validSince": {
  148. "description": "The date (in ISO-8601 format) from which this short code will be valid",
  149. "type": "string",
  150. "nullable": true
  151. },
  152. "validUntil": {
  153. "description": "The date (in ISO-8601 format) until which this short code will be valid",
  154. "type": "string",
  155. "nullable": true
  156. },
  157. "maxVisits": {
  158. "description": "The maximum number of allowed visits for this short code",
  159. "type": "number",
  160. "nullable": true
  161. }
  162. }
  163. },
  164. "Visit": {
  165. "type": "object",
  166. "properties": {
  167. "referer": {
  168. "type": "string",
  169. "description": "The origin from which the visit was performed"
  170. },
  171. "date": {
  172. "type": "string",
  173. "format": "date-time",
  174. "description": "The date in which the visit was performed"
  175. },
  176. "userAgent": {
  177. "type": "string",
  178. "description": "The user agent from which the visit was performed"
  179. },
  180. "visitLocation": {
  181. "$ref": "#/components/schemas/VisitLocation"
  182. }
  183. },
  184. "example": {
  185. "referer": "https://t.co",
  186. "date": "2015-08-20T05:05:03+04:00",
  187. "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36",
  188. "visitLocation": {
  189. "cityName": "Cupertino",
  190. "countryCode": "US",
  191. "countryName": "United States",
  192. "latitude": 37.3042,
  193. "longitude": -122.0946,
  194. "regionName": "California",
  195. "timezone": "America/Los_Angeles"
  196. }
  197. }
  198. },
  199. "OrphanVisit": {
  200. "allOf": [
  201. {"$ref": "#/components/schemas/Visit"},
  202. {
  203. "type": "object",
  204. "properties": {
  205. "visitedUrl": {
  206. "type": "string",
  207. "nullable": true,
  208. "description": "The originally visited URL that triggered the tracking of this visit"
  209. },
  210. "type": {
  211. "type": "string",
  212. "enum": [
  213. "invalid_short_url",
  214. "base_url",
  215. "regular_404"
  216. ],
  217. "description": "Tells the type of orphan visit"
  218. }
  219. }
  220. }
  221. ],
  222. "example": {
  223. "referer": "https://t.co",
  224. "date": "2015-08-20T05:05:03+04:00",
  225. "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36",
  226. "visitLocation": {
  227. "cityName": "Cupertino",
  228. "countryCode": "US",
  229. "countryName": "United States",
  230. "latitude": 37.3042,
  231. "longitude": -122.0946,
  232. "regionName": "California",
  233. "timezone": "America/Los_Angeles"
  234. },
  235. "visitedUrl": "https://doma.in",
  236. "type": "base_url"
  237. }
  238. },
  239. "VisitLocation": {
  240. "type": "object",
  241. "properties": {
  242. "cityName": {
  243. "type": "string"
  244. },
  245. "countryCode": {
  246. "type": "string"
  247. },
  248. "countryName": {
  249. "type": "string"
  250. },
  251. "latitude": {
  252. "type": "number"
  253. },
  254. "longitude": {
  255. "type": "number"
  256. },
  257. "regionName": {
  258. "type": "string"
  259. },
  260. "timezone": {
  261. "type": "string"
  262. }
  263. }
  264. }
  265. }
  266. }
  267. }