-
Notifications
You must be signed in to change notification settings - Fork 2
/
openapi.json
643 lines (643 loc) · 19.7 KB
/
openapi.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
{
"openapi": "3.0.0",
"info": {
"title": "Pastebin.fi API",
"description": "Some endpoints might return more fields than are specified in this document. They are not supposed to be used by public until they are added to this document (since they are mostly for testing and can be removed at any point of time).\n\nUseful resources:\n- [Pastebin.fi API backend code](https://github.com/pastebin-fi/backend)\n- [Official frontend for pastebin.fi API](https://github.com/pastebin-fi/frontend)",
"termsOfService": "https://pastebin.fi/about",
"contact": {
"email": "sysadmin@pastebin.fi"
},
"license": {
"name": "AGPL-3.0",
"url": "https://www.gnu.org/licenses/agpl-3.0.en.html"
},
"version": "1.0.0"
},
"servers": [
{
"url": "https://api.pastebin.fi",
"description": "Production server (uses live data)"
}
],
"tags": [
{
"name": "paste",
"description": "Requests related to pastes"
},
{
"name": "metrics",
"description": "Requestes related to metrics"
}
],
"paths": {
"/metrics": {
"get": {
"tags": [
"metrics"
],
"summary": "Get metrics",
"description": "Get public metrics of the service in JSON format",
"operationId": "getMetrics",
"responses": {
"200": {
"description": "JSON object containing metrics",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/MetricsResponse"
}
}
}
},
"404": {
"description": "No metrics available (no pastes created / database query failed)",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
},
"example": {
"title": "Liitteitä ei löytynyt",
"message": "Emme ole vastaanottaneet vielä yhtäkään liitettä. Ole ensimmäinen!"
}
}
}
}
}
}
},
"/pastes": {
"get": {
"tags": [
"paste"
],
"summary": "Get list of public pastes",
"description": "Get list of public pastes",
"operationId": "listPastes",
"parameters": [
{
"in": "query",
"name": "q",
"schema": {
"type": "string"
},
"description": "Search for the following text in title and paste (keep in mind that the title is weighted)"
},
{
"in": "query",
"name": "offset",
"schema": {
"type": "integer",
"default": 0
},
"description": "The number of pastes to skip before starting to collect the result set"
},
{
"in": "query",
"name": "limit",
"schema": {
"type": "integer",
"default": 0,
"maximum": 30
},
"description": "The amount of pastes that are returned in the result set."
},
{
"in": "query",
"name": "sorting",
"schema": {
"type": "string",
"default": "-date",
"enum": [
"date",
"-date",
"meta.views",
"-meta.views",
"meta.size",
"-meta.size"
]
},
"description": "Sort the results from mongodb with the following method. Hyphen (-) in front of the value switch the sorting to descending order (normally ascending). Has to match the available values or else set to default value."
}
],
"responses": {
"200": {
"description": "Paste list found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PasteListResponse"
}
}
}
}
}
},
"post": {
"tags": [
"paste"
],
"summary": "Create a paste",
"description": "This endpoint is ratelimited to 20 pastes per 30 mins (this might change in the future when accounts come).",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PasteCreateRequest"
}
}
}
},
"responses": {
"200": {
"description": "Paste has been created succesfully",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PasteCreateResponse"
}
}
}
},
"400": {
"description": "Request body missing",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
},
"example": {
"title": "Pyynnön vartalo on pakollinen",
"message": "Et voi luoda tyhjää pyyntöä."
}
}
}
},
"403": {
"description": "Blocked by safeguards\n\nCurrent safeguards:\n - AbuseIPDB check\n",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
},
"example": {
"title": "Pääsy hylätty",
"message": "IP-osoitteesi maine on huono, joten hylkäsimme pyyntösi uuden liitteen luomiseksi."
}
}
}
},
"409": {
"description": "The same content is in another paste",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
},
"example": {
"title": "Liite on jo olemassa",
"description": "Luotu liite on jo olemassa, joten sitä ei luotu.",
"data": {
"pasteIdentifier": "Daehn4t"
}
}
}
}
},
"413": {
"description": "Exceeds limits defined by server\n\nLimits:\n - Programming language must be under 30 characters\n - Paste size must be under 10 MB (Megabytes)\n - Title must be under 300 characters\n",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
},
"examples": {
"large": {
"summary": "Over 10MB pastes are not allowed",
"value": {
"title": "Liite on liian iso",
"message": "Palveluun ei voi luoda yli kymmenen (10) MB liitteitä."
}
},
"name": {
"summary": "Names over 300 characters are disallowed",
"value": {
"title": "Virheellinen nimi",
"message": "Palveluun ei voi luoda liitettä yli 300 merkin otsikolla."
}
},
"lang": {
"summary": "Programming language names over 30 characters are disallowed",
"value": {
"title": "Virheellinen ohjelmointikieli",
"message": "Ohjelmointikielen nimi ei voi olla yli kolmeakymmentä (30) merkkiä."
}
}
}
}
}
},
"500": {
"description": "Unknown error occurred when creating the paste (database connection might have broken)\n",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
},
"example": {
"title": "Liitettä ei voitu luoda",
"description": "Jotain meni vikaan, eikä liitettä luotu."
}
}
}
}
}
}
},
"/pastes/{id}": {
"get": {
"tags": [
"paste"
],
"summary": "Get paste",
"description": "Get paste and its metadata (views & size)",
"operationId": "getPaste",
"parameters": [
{
"in": "path",
"name": "id",
"required": true,
"schema": {
"type": "string"
},
"description": "The paste ID"
}
],
"responses": {
"200": {
"description": "Paste found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PasteResponse"
}
}
}
},
"404": {
"description": "Paste not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
},
"example": {
"title": "Liitettä ei löytynyt",
"message": "Olemme pahoillamme, mutta hakemaasi liitettä ei löytynyt"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"PasteListResponse": {
"type": "array",
"items": {
"type": "object",
"properties": {
"title": {
"type": "string",
"description": "Paste title"
},
"id": {
"type": "string",
"description": "Paste ID (very useful for querying it later)"
},
"meta": {
"type": "object",
"properties": {
"views": {
"type": "integer",
"description": "Amount of page loads the paste has received"
},
"size": {
"type": "integer",
"format": "byte",
"description": "Size in bytes"
}
}
},
"date": {
"type": "string",
"format": "datetime",
"description": "Time when paste was created"
}
},
"example": [
{
"title": "jamsanseutu.fi - 2000009558326 - Maksumuuri poistettu",
"id": "GOtkjL0",
"author": "Tuntematon lataaja",
"meta": {
"votes": null,
"favs": null,
"views": 2,
"size": 1929
},
"date": "2023-05-05T05:58:52.590Z"
},
{
"title": "jamsanseutu.fi - 2000009560587 - Maksumuuri poistettu",
"id": "MOaY1Ux",
"author": "Tuntematon lataaja",
"meta": {
"votes": null,
"favs": null,
"views": 4,
"size": 7064
},
"date": "2023-05-05T05:49:57.027Z"
},
{
"title": "Ecoshift Corp, LED Tube Lights Manila Philippines",
"id": "fgJRrSP",
"author": "Tuntematon lataaja",
"meta": {
"votes": null,
"favs": null,
"views": 7,
"size": 359
},
"date": "2023-05-04T11:00:18.642Z"
},
{
"title": "hs.fi - 2000009511830 - Maksumuuri poistettu",
"id": "WQ9LqBe",
"author": "Tuntematon lataaja",
"meta": {
"votes": null,
"favs": null,
"views": 16,
"size": 16650
},
"date": "2023-05-03T07:32:11.872Z"
},
{
"title": "LinkHelpers Phoenix Digital Marketing",
"id": "1uw3d0o",
"author": "Tuntematon lataaja",
"meta": {
"votes": null,
"favs": null,
"views": 12,
"size": 506
},
"date": "2023-05-03T06:15:41.181Z"
},
{
"title": "aamulehti.fi - 2000008948411 - Maksumuuri poistettu",
"id": "RDmebqX",
"author": "Tuntematon lataaja",
"meta": {
"votes": null,
"favs": null,
"views": 12,
"size": 3382
},
"date": "2023-05-02T12:51:29.109Z"
},
{
"title": "AI Monthly SEO plans",
"id": "IZs1kdC",
"author": "Tuntematon lataaja",
"meta": {
"votes": null,
"favs": null,
"views": 11,
"size": 398
},
"date": "2023-05-02T05:31:15.515Z"
},
{
"title": "Improve local visibility for pastebin.fi",
"id": "3iNenOB",
"author": "Tuntematon lataaja",
"meta": {
"votes": null,
"favs": null,
"views": 11,
"size": 440
},
"date": "2023-04-30T12:52:16.058Z"
},
{
"title": "hs.fi - 2000009514770 - Maksumuuri poistettu",
"id": "rVTg2Qv",
"author": "Tuntematon lataaja",
"meta": {
"votes": null,
"favs": null,
"views": 23,
"size": 37275
},
"date": "2023-04-30T11:46:01.626Z"
},
{
"title": "",
"id": "HRvvPWw",
"author": "Tuntematon lataaja",
"meta": {
"votes": null,
"favs": null,
"views": 23,
"size": 1209
},
"date": "2023-04-29T12:24:03.176Z"
}
]
}
},
"PasteCreateRequest": {
"type": "object",
"required": [
"title",
"paste"
],
"properties": {
"title": {
"type": "string",
"example": "Placeholder text",
"description": "Paste title"
},
"paste": {
"type": "string",
"example": "Lorem ipsum dolor sit amet...",
"description": "Paste content"
},
"lang": {
"type": "string",
"default": "text",
"example": "python",
"description": "Paste programming langauge (currently not used anywhere)"
},
"private": {
"type": "boolean",
"default": false,
"example": true,
"description": "Do not show the paste to others (only the ones that have access to the ID can see it)"
}
}
},
"PasteCreateResponse": {
"type": "object",
"required": [
"id",
"lang"
],
"properties": {
"id": {
"type": "string",
"example": "Placeholder text",
"description": "Paste identifier can be used for a redirect to the paste when created"
},
"lang": {
"type": "string",
"example": "ts",
"default": "plaintext",
"description": "Paste programming language reported by [vscode-languagedetection](https://github.com/microsoft/vscode-languagedetection) (that uses [yoeo/guesslang](https://github.com/yoeo/guesslang) model). Language is plaintext when the paste content is under 20 characters or the confidence is under 0.1."
}
}
},
"PasteMeta": {
"required": [
"views",
"size"
],
"type": "object",
"properties": {
"views": {
"type": "integer",
"example": 1,
"description": "Amount of page loads the paste has received"
},
"size": {
"type": "integer",
"format": "byte",
"example": 109,
"description": "Size in bytes"
}
}
},
"PasteResponse": {
"required": [
"meta",
"title",
"id",
"hidden",
"date",
"lang"
],
"type": "object",
"properties": {
"meta": {
"type": "array",
"items": {
"$ref": "#/components/schemas/PasteMeta"
}
},
"title": {
"type": "string",
"example": "Example title"
},
"id": {
"type": "string",
"example": "58hMQlk"
},
"hidden": {
"type": "boolean",
"example": true
},
"date": {
"type": "string",
"format": "date-time",
"example": "2023-05-03T11:19:20.137Z"
},
"lang": {
"type": "string",
"example": "ts",
"default": "plaintext",
"description": "Paste programming language reported by [vscode-languagedetection](https://github.com/microsoft/vscode-languagedetection) (that uses [yoeo/guesslang](https://github.com/yoeo/guesslang) model). Language is plaintext when the paste content is under 20 characters or the confidence is under 0.1."
}
}
},
"ErrorResponse": {
"required": [
"title",
"message"
],
"type": "object",
"properties": {
"title": {
"type": "string",
"example": "error type",
"description": "Error type"
},
"message": {
"type": "string",
"example": "",
"description": "More specific data of the error"
},
"data": {
"type": "object",
"description": "In some cases additional fields are given in the error response",
"properties": {
"pasteIdentifier": {
"type": "string",
"description": "existing paste ID"
}
}
}
}
},
"MetricsResponse": {
"required": [
"totalViews",
"pasteCount - total - public - private"
],
"type": "object",
"properties": {
"totalviews": {
"type": "integer",
"example": 138953,
"description": "Sum of all paste views"
},
"pasteCount": {
"type": "object",
"properties": {
"total": {
"type": "integer",
"description": "Amount of all pastes (both public and private)",
"example": 1557
},
"public": {
"type": "integer",
"description": "Amount of public pastes",
"example": 1129
},
"private": {
"type": "integer",
"description": "Amount of private pastes",
"example": 428
}
}
}
}
}
}
}
}