forked from LachubCz/pero-ocr-api
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocs.swaggerhub
808 lines (790 loc) · 24 KB
/
docs.swaggerhub
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
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
openapi: 3.0.0
servers:
- description: Primary server.
url: https://pero-ocr.fit.vutbr.cz/api
info:
version: 1.0.3
title: PERO-API
description: The API allows users to automaticaly transcribe several types of printed and handwritten documents. The provided OCR engines are able to transcribe even very low-quality printed documents in most european languages including Latin, old documents in Fraktur and similar scripts in German and Czech, and handwritten documents mainly in Czech language. The API provides several formats of transcriptions for download (ALTO, PAGE XML, plain text). Be aware that the images you provide may be used for further training of our systems.
contact:
email: [email protected]
tags:
- name: external
description: Operations available to users with regular API key
- name: internal
description: Operations available to processing clients with special API key
paths:
/post_processing_request:
post:
tags:
- external
summary: creates processing request
operationId: post_processing_request
security:
- ApiKey: [admin]
requestBody:
description: JSON definition of request to be processed.
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ProcessingRequest'
responses:
'200':
description: Request accepted.
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: success
request_id:
type: string
example: 1ad17f85-cbaa-4767-8ca2-e86f95d501be
'404':
description: Engine has not been found.
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: failure
message:
type: string
example: Engine 3 has not been found.
'422':
description: Bad JSON formatting.
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: failure
message:
type: string
example: Bad JSON formatting.
/upload_image/{request_id}/{page_name}:
post:
tags:
- external
summary: uploads image to server
operationId: upload_image
security:
- ApiKey: [admin]
requestBody:
required: True
content:
multipart/form-data:
schema:
type: object
properties:
file:
type: string
format: binary
required:
- file
parameters:
- in: path
name: request_id
required: True
schema:
type: string
- in: path
name: page_name
required: True
schema:
type: string
responses:
'200':
description: Image upload was succesfull.
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: success
'400':
description: Request either does not contain image file or page is not in CREATED state.
content:
application/json:
schema:
type: object
properties:
status:
type: string
message:
type: string
examples:
Missing image file:
value:
status: failure
message: Request does not contain file.
Wrong page state:
value:
status: failure
message: Page Magna_Carta is in WAITING state. It should be in CREATED state.
'401':
description: Request does not belong to API key.
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: failure
message:
type: string
example: Request 1ad17f85-cbaa-4767-8ca2-e86f95d501be does not belong to API key wXh0PUD4HL2S9CcOmlqCFj6xhzcJSQvfIwe7HjQ1Tym.
'404':
description: Either request or page does not exist.
content:
application/json:
schema:
type: object
properties:
status:
type: string
message:
type: string
examples:
Nonexistent request:
value:
status: failure
message: Request 1ad17f85-cbaa-4767-8ca2-e86f95d501be does not exist.
Nonexistent page:
value:
status: failure
message: Page Magna_Carta does not exist.
'422':
description: Unsupported image format.
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: failure
message:
type: string
example: mp4 is not supported format. Supported formats are jpg, jpeg, png, jp2, j2k, jpf, jpm, jpg2, j2c, jpc, jpx, mj2, bmp, tiff, tif.
/request_status/{request_id}:
get:
tags:
- external
summary: returns status of processing request
operationId: request_status
security:
- ApiKey: [admin]
parameters:
- in: path
name: request_id
required: True
schema:
type: string
responses:
'200':
description: Request status returned.
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: succes
request_status:
type: object
additionalProperties:
type: object
properties:
quality:
type: number
state:
type: string
example:
Magna_Carta: {quality: 89.7, state: PROCESSED}
United_States_Declaration_of_Independence: {quality: , state: WAITING}
'401':
description: Request does not belong to API key.
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: failure
message:
type: string
example: Request 1ad17f85-cbaa-4767-8ca2-e86f95d501be does not belong to API key wXh0PUD4HL2S9CcOmlqCFj6xhzcJSQvfIwe7HjQ1Tym.
'404':
description: Request does not exist.
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: failure
message:
type: string
example: Request 1ad17f85-cbaa-4767-8ca2-e86f95d501be does not exist.
/get_engines:
get:
tags:
- external
summary: returns list of avaiable engines
operationId: get_engines
security:
- ApiKey: [admin]
responses:
'200':
description: List of engines returned.
content:
application/json:
schema:
allOf:
- type: object
properties:
status:
type: string
example: succes
- $ref: '#/components/schemas/Engines'
/download_results/{request_id}/{page_name}/{format}:
get:
tags:
- external
summary: returns processed page
operationId: download_results
security:
- ApiKey: [admin]
parameters:
- in: path
name: request_id
required: True
schema:
type: string
- in: path
name: page_name
required: True
schema:
type: string
- in: path
name: format
required: True
schema:
type: string
enum: [alto, page, txt]
responses:
'200':
description: Processed page returned in required format.
content:
text/plain: {}
application/xml: {}
'202':
description: Page isn't processed.
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: failure
message:
type: string
example: Page isn't processed.
'400':
description: Bad export format.
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: failure
message:
type: string
example: Bad export format. Supported formats are alto, page, txt.
'401':
description: Request does not belong to API key.
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: failure
message:
type: string
example: Request 1ad17f85-cbaa-4767-8ca2-e86f95d501be does not belong to API key wXh0PUD4HL2S9CcOmlqCFj6xhzcJSQvfIwe7HjQ1Tym.
'404':
description: Either request or page does not exist or page is not in PROCESSED state.
content:
application/json:
schema:
type: object
properties:
status:
type: string
message:
type: string
examples:
Nonexistent request:
value:
status: failure
message: Request 1ad17f85-cbaa-4767-8ca2-e86f95d501be does not exist.
Nonexistent page:
value:
status: failure
message: Page Magna_Carta does not exist.
Page expired:
value:
status: failure
message: Page Magna_Carta has expired. All processed pages are stored one week.
Page unprocessed:
value:
status: failure
message: Page Magna_Carta is not processed yet.
/cancel_request/{request_id}:
post:
tags:
- external
summary: cancels processing request
operationId: cancel_request
security:
- ApiKey: [admin]
parameters:
- in: path
name: request_id
required: True
schema:
type: string
responses:
'200':
description: Request canceled.
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: succes
'401':
description: Request does not belong to API key.
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: failure
message:
type: string
example: Request 1ad17f85-cbaa-4767-8ca2-e86f95d501be does not belong to API key wXh0PUD4HL2S9CcOmlqCFj6xhzcJSQvfIwe7HjQ1Tym.
'404':
description: Request does not exist.
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: failure
message:
type: string
example: Request 1ad17f85-cbaa-4767-8ca2-e86f95d501be does not exist.
/get_processing_request/{preferred_engine_id}:
get:
tags:
- internal
summary: returns page information for processing
operationId: get_processing_request
security:
- ApiKey: [admin]
parameters:
- in: path
name: preferred_engine_id
required: True
schema:
type: integer
responses:
'200':
description: Page information returned.
content:
application/json:
schema:
allOf:
- type: object
properties:
status:
type: string
example: succes
- $ref: '#/components/schemas/ProcessingPage'
'204':
description: No page available for processing.
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: failure
message:
type: string
example: No page available for processing.
/upload_results/{page_id}:
post:
tags:
- internal
summary: saves xml, alto and txt files of processed page
operationId: upload_results
security:
- ApiKey: [admin]
parameters:
- in: path
name: page_id
required: True
schema:
type: string
- in: header
name: score
required: true
schema:
type: number
- in: header
name: engine-version
required: true
schema:
type: string
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
alto:
type: string
format: binary
page:
type: string
format: binary
txt:
type: string
format: binary
required:
- alto
- page
- txt
responses:
'200':
description: Processed page saved.
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: succes
'404':
description: Page does not exist.
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: failure
message:
type: string
example: Page Magna_Carta does not exist.
/download_engine/{engine_id}:
get:
tags:
- internal
summary: returns latest engine version
operationId: download_engine
security:
- ApiKey: [admin]
parameters:
- in: path
name: engine_id
required: True
schema:
type: string
responses:
'200':
description: Engine returned in zip archive.
content:
application/zip: {}
'404':
description: Engine has not been found.
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: failure
message:
type: string
example: Engine 7 has not been found.
'500':
description: Too many models for engine.
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: failure
message:
type: string
example: Too many models for engine.
/failed_processing/{page_id}:
post:
tags:
- internal
summary: reports processing problem
operationId: failed_processing
security:
- ApiKey: [admin]
parameters:
- in: path
name: page_id
required: True
schema:
type: string
- in: header
name: type
required: true
schema:
type: string
enum: [NOT_FOUND, INVALID_FILE, PROCESSING_FAILED]
- in: header
name: engine-version
required: true
schema:
type: string
requestBody:
description: Error traceback.
required: true
content:
text/plain:
schema:
type: object
example: ''
responses:
'200':
description: Failed processing reported.
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: succes
/page_statistics:
get:
tags:
- internal
summary: returns page statistics for the last 24 hours
operationId: page_statistics
security:
- ApiKey: [admin]
responses:
'200':
description: Page statistics returned.
content:
application/json:
schema:
allOf:
- type: object
properties:
status:
type: string
example: succes
- $ref: '#/components/schemas/PageStatistics'
/download_image/{request_id}/{page_name}:
get:
tags:
- internal
summary: returns image saved on API server
operationId: download_image
security:
- ApiKey: [admin]
parameters:
- in: path
name: request_id
required: True
schema:
type: string
- in: path
name: page_name
required: True
schema:
type: string
responses:
'200':
description: Image returned.
content:
image/jpg: {}
image/jpeg: {}
image/png: {}
image/jp2: {}
image/j2k: {}
image/jpf: {}
image/jpm: {}
image/jpg2: {}
image/j2c: {}
image/jpc: {}
image/jpx: {}
image/mj2: {}
image/bmp: {}
image/tiff: {}
image/tif: {}
'404':
description: Either request or page does not exist or page image has not been uploaded yet.
content:
application/json:
schema:
type: object
properties:
status:
type: string
message:
type: string
examples:
Nonexistent request:
value:
status: failure
message: Request 1ad17f85-cbaa-4767-8ca2-e86f95d501be does not exist.
Nonexistent page:
value:
status: failure
message: Page Magna_Carta does not exist.
Not uploaded page:
value:
status: failure
message: Page Magna_Carta has not been uploaded yet.
'405':
description: Page has been already processed.
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: failure
message:
type: string
example: Page Magna_Carta has been already processed.
components:
schemas:
ProcessingRequest:
properties:
engine:
type: integer
example: 1
images:
type: object
additionalProperties:
type: string
example:
Magna_Carta: https://upload.wikimedia.org/wikipedia/commons/e/ee/Magna_Carta_%28British_Library_Cotton_MS_Augustus_II.106%29.jpg
United_States_Declaration_of_Independence: https://upload.wikimedia.org/wikipedia/commons/8/8f/United_States_Declaration_of_Independence.jpg
Treaty_of_Tordesillas: null
ProcessingPage:
properties:
page_id:
type: string
example: 0005dca9-7635-4971-90da-9c7e71cdb949
page_url:
type: string
example: https://upload.wikimedia.org/wikipedia/commons/e/ee/Magna_Carta_%28British_Library_Cotton_MS_Augustus_II.106%29.jpg
engine_id:
type: integer
example: 1
Engines:
type: object
properties:
engines:
type: object
additionalProperties:
type: object
properties:
id:
type: integer
description:
type: string
engine_version:
type: string
models:
type: array
items:
type: object
properties:
id:
type: integer
name:
type: string
example:
lidove_noviny: {id: 1, description: "Engine for czech printed newspapers from the begining of the 20. century.", engine_version: "2021-02-04", models: [{id: 6, name: "layout_printed_2021-02-04"}, {id: 7, name: "czech_ocr_2021-02-04"}, {id: 8, name: "language_model_2021-02-04"}]}
historical_handwritten: {id: 2, description: "Engine for historical handwritten documents.", engine_version: "2021-01-15", models: [{id: 4, name: "layout_handwritten_2021-01-15"}, {id: 5, name: "handwritten_ocr_2021-01-15"}]}
PageStatistics:
type: object
properties:
engine_stats:
type: object
additionalProperties:
type: integer
example:
{"1": 484, "2": 2, "3": 11}
page_stats:
properties:
CANCELED:
type: integer
EXPIRED:
type: integer
INVALID_FILE:
type: integer
NOT_FOUND:
type: integer
PROCESSED:
type: integer
PROCESSING:
type: integer
PROCESSING_FAILED:
type: integer
WAITING:
type: integer
example:
{"CANCELED": 23, "EXPIRED": 404, "INVALID_FILE": 1, "NOT_FOUND": 2, "PROCESSED": 456, "PROCESSING": 1, "PROCESSING_FAILED": 2, "WAITING": 20}
securitySchemes:
ApiKey:
type: apiKey
in: header
name: api-key