-
Notifications
You must be signed in to change notification settings - Fork 1
/
nanonets_openapi_3.1.0.yaml
3290 lines (2747 loc) · 141 KB
/
nanonets_openapi_3.1.0.yaml
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
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
openapi: 3.1.0
info:
title: NanoNets
description: |
Welcome to [NanoNets](https://nanonets.com)' API Reference!
<br />
<br />
<br />
Use Postman to quickly test the API.
<br />
<br />
<a href="https://www.postman.com/run-collection/2fcb1195d85e7a98ad74" rel="noreferrer" target="_blank">
<img src="https://run.pstmn.io/button.svg" alt="Run in Postman" />
</a>
<br />
<br />
<br />
[Get an API Key](https://app.nanonets.com/#/keys)
# SDKs
We have Node.js SDKs that can be used to make predictions after [creating and training models on our web app](https://app.nanonets.com).
- Optical Character Recognition
- [NPM Package](https://www.npmjs.com/package/@nanonets/optical-character-recognition)
- NPM: `npm install @nanonets/optical-character-recognition`
- Yarn: `yarn add @nanonets/optical-character-recognition`
- Image Classification
- [NPM Package](https://www.npmjs.com/package/@nanonets/image-classification)
- NPM: `npm install @nanonets/image-classification`
- Yarn: `yarn add @nanonets/image-classification`
contact:
name: NanoNets Support
url: "https://nanonets.com"
email: [email protected]
license:
name: MIT
url: "https://github.com/NanoNets/api-docs/blob/main/LICENSE"
version: 2.0.0
x-logo:
url: "https://nanonets.com/logo2.png"
altText: NanoNets
servers:
- url: "https://app.nanonets.com/api/v2"
description: "NanoNets API v2"
paths:
/OCR/Model/{model_id}:
get:
tags:
- ocrModelDetails
summary: Get Model Details by ID
description: Retrieve a specific model's details given its ID.
operationId: "ocr/model/id"
parameters:
- $ref: "#/components/parameters/modelId"
responses:
"200":
$ref: "#/components/responses/modelObject"
"401":
$ref: "#/components/responses/unauthorized"
"402":
$ref: "#/components/responses/paymentRequired"
deprecated: false
x-codeSamples:
- lang: JavaScript
label: Node.js
source: >
var request = require('request')
const options = {
url : 'https://app.nanonets.com/api/v2/OCR/Model/' + 'REPLACE_MODEL_ID',
headers: {
'Authorization' : 'Basic ' + Buffer.from('[[.ApiKey]]' + ':').toString('base64')
}
}
request.get(options, function(err, httpResponse, body) {
console.log(body)
});
- lang: Python
label: Python
source: >
import requests
url = 'https://app.nanonets.com/api/v2/OCR/Model/' + {{model_id}}
response = requests.request('GET', url,
auth=requests.auth.HTTPBasicAuth('[[.ApiKey]]',''))
print(response.text)
- lang: Shell
label: CLI
source: |
curl --request GET \
--url 'https://app.nanonets.com/api/v2/OCR/Model/{{model_id}}' \
-u '[[.ApiKey]]'
- lang: Go
label: Go
source: |
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://app.nanonets.com/api/v2/OCR/Model/" + {{model_id}}
req, _ := http.NewRequest("GET", url, nil)
req.SetBasicAuth("[[.ApiKey]]", "")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
- lang: Ruby
label: Ruby
source: >
require 'uri'
require 'net/http'
url = URI('https://app.nanonets.com/api/v2/OCR/Model/' + {{model_id}})
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request.basic_auth '[[.ApiKey]]', ''
response = http.request(request)
puts response.read_body
- lang: "C#"
label: "C#"
source: >
var client = new RestClient("https://app.nanonets.com/api/v2/OCR/Model/" + {{model_id}});
var request = new RestRequest(Method.GET);
request.AddHeader("authorization", "Basic " + Convert.ToBase64String(Encoding.Default.GetBytes("[[.ApiKey]]:")));
IRestResponse response = client.Execute(request);
- lang: Java
label: Java
source: |
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://app.nanonets.com/api/v2/OCR/Model/" + {{model_id}})
.get()
.addHeader("authorization", Credentials.basic("[[.ApiKey]]", ""))
.build();
Response response = client.newCall(request).execute();
/OCR/Model/{model_id}/UploadUrls:
post:
tags:
- ocrUpload
summary: Upload Training Images by URLs
description: |
Upload training images to a model using image URLs.
Multiple images can be uploaded in the same request by adding more URLs in the `urls` array.
On successful upload, model information along with the total number of images per category will be received.
operationId: "ocr/upload/url"
parameters:
- $ref: "#/components/parameters/contentType"
- $ref: "#/components/parameters/modelId"
requestBody:
$ref: "#/components/requestBodies/urls"
responses:
"200":
$ref: "#/components/responses/ok"
"202":
$ref: "#/components/responses/partiallySuccessfulURL"
"400":
$ref: "#/components/responses/missingURL"
"401":
$ref: "#/components/responses/unauthorized"
"402":
$ref: "#/components/responses/paymentRequired"
"404":
$ref: "#/components/responses/notFound"
deprecated: false
x-codeSamples:
- lang: JavaScript
label: Node.js
source: >
var request = require('request')
const form_data = {"data": [{"filename":"https://nanonets.s3-us-west-2.amazonaws.com/test-images/test1.jpg", "object": [{"name":"category1", "ocr_text":"text inside the bounding box", "bndbox": {"xmin": 1,"ymin": 1,"xmax": 100, "ymax": 100}}, {"name":"category2", "bndbox": {"xmin": 1,"ymin": 1,"xmax": 100, "ymax": 100}}]}], "urls": ["https://nanonets.s3-us-west-2.amazonaws.com/test-images/test1.jpg"]}
const options = {
url : 'https://app.nanonets.com/api/v2/OCR/Model/{model_id}/UploadUrls/',
body: JSON.stringify(form_data),
headers: {
'Authorization' : 'Basic ' + Buffer.from('[[.ApiKey]]' + ':').toString('base64'),
'Content-Type': ""application/json""
}
}
request.post(options, function(err, httpResponse, body) {
console.log(body)
});
- lang: Python
label: Python
source: |
import requests
url = "https://app.nanonets.com/api/v2/OCR/Model/{model_id}/UploadUrls/"
payload = "{\"data\": [{\"filename\":\"https://nanonets.s3-us-west-2.amazonaws.com/test-images/test1.jpg\", \"object\": [{\"name\":\"category1\", \"ocr_text\":\"text inside the bounding box\", \"bndbox\": {\"xmin\": 1,\"ymin\": 1,\"xmax\": 100, \"ymax\": 100}}, {\"name\":\"category2\", \"bndbox\": {\"xmin\": 1,\"ymin\": 1,\"xmax\": 100, \"ymax\": 100}}]}], \"urls\": [\"https://nanonets.s3-us-west-2.amazonaws.com/test-images/test1.jpg\"]}"
headers = {
'Content-Type': ""application/json""
}
response = requests.request("POST", url, auth=requests.auth.HTTPBasicAuth('[[.ApiKey]]', ''), data=payload, headers=headers)
print(response.text)
- lang: Shell
label: CLI
source: |
curl --request POST \
--url https://app.nanonets.com/api/v2/OCR/Model/{model_id}/UploadUrls/ \
-u '[[.ApiKey]]' \
-H 'Content-Type: "application/json"' \
--data '{"data": [{"filename":"https://nanonets.s3-us-west-2.amazonaws.com/test-images/test1.jpg", "object": [{"name":"category1", "ocr_text":"text inside the bounding box", "bndbox": {"xmin": 1,"ymin": 1,"xmax": 100, "ymax": 100}}, {"name":"category2", "bndbox": {"xmin": 1,"ymin": 1,"xmax": 100, "ymax": 100}}]}], "urls": ["https://nanonets.s3-us-west-2.amazonaws.com/test-images/test1.jpg"]}'
- lang: Go
label: Go
source: |
package main
import (
"fmt"
"io/ioutil"
"net/http"
"strings"
)
func main() {
url := "https://app.nanonets.com/api/v2/OCR/Model/REPLACE_MODEL_ID/UploadUrls/"
payload := strings.NewReader("{\"data\": [{\"filename\":\"https://nanonets.s3-us-west-2.amazonaws.com/test-images/test1.jpg\", \"object\": [{\"name\":\"category1\", \"ocr_text\":\"text inside the bounding box\", \"bndbox\": {\"xmin\": 1,\"ymin\": 1,\"xmax\": 100, \"ymax\": 100}}, {\"name\":\"category2\", \"bndbox\": {\"xmin\": 1,\"ymin\": 1,\"xmax\": 100, \"ymax\": 100}}]}], \"urls\": [\"https://nanonets.s3-us-west-2.amazonaws.com/test-images/test1.jpg\"]}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", ""application/json"")
req.SetBasicAuth("[[.ApiKey]]", "")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
- lang: Ruby
label: Ruby
source: |
require 'uri'
require 'net/http'
url = URI("https://app.nanonets.com/api/v2/OCR/Model/REPLACE_MODEL_ID/UploadUrls/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = '"application/json"'
request.basic_auth '[[.ApiKey]]', ''
request.body = "{\"data\": [{\"filename\":\"https://nanonets.s3-us-west-2.amazonaws.com/test-images/test1.jpg\", \"object\": [{\"name\":\"category1\", \"ocr_text\":\"text inside the bounding box\", \"bndbox\": {\"xmin\": 1,\"ymin\": 1,\"xmax\": 100, \"ymax\": 100}}, {\"name\":\"category2\", \"bndbox\": {\"xmin\": 1,\"ymin\": 1,\"xmax\": 100, \"ymax\": 100}}]}], \"urls\": [\"https://nanonets.s3-us-west-2.amazonaws.com/test-images/test1.jpg\"]}"
response = http.request(request)
puts response.read_body"
- lang: "C#"
label: "C#"
source: >
var client = new
RestClient("https://app.nanonets.com/api/v2/OCR/Model/REPLACE_MODEL_ID/UploadUrls/");
var request = new RestRequest(Method.POST);
request.AddHeader("authorization", "Basic [[.ApiKey]]");
request.AddHeader("Content-Type", ""application/json"");
request.AddParameter("undefined", "
{"data": [{"filename":"https://nanonets.s3-us-west-2.amazonaws.com/test-images/test1.jpg", "object":
[{"name":"category1", "ocr_text": "text inside the bounding box", "bndbox": {"xmin": 1,"ymin":
1,"xmax": 100, "ymax": 100}}, {"name":"category2", "ocr_text": "text inside the bounding box",
"bndbox": {"xmin": 1,"ymin": 1,"xmax": 100, "ymax":
100}}]}], "urls": ["https://nanonets.s3-us-west-2.amazonaws.com/test-images/test1.jpg"]}",
ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
- lang: Java
label: Java
source: >
OkHttpClient client = new OkHttpClient();
MediaType mediaType =
MediaType.parse(""application/json"");
RequestBody body = RequestBody.create(mediaType, "
{"data": [{"filename":"https://nanonets.s3-us-west-2.amazonaws.com/test-images/test1.jpg", "object":
[{"name":"category1", "ocr_text": "text inside the bounding box", "bndbox": {"xmin": 1,"ymin":
1,"xmax": 100, "ymax": 100}}, {"name":"category2", "ocr_text": "text inside the bounding box",
"bndbox": {"xmin": 1,"ymin": 1,"xmax": 100, "ymax":
100}}]}], "urls": ["https://nanonets.s3-us-west-2.amazonaws.com/test-images/test1.jpg"]}");
Request request = new Request.Builder()
.url("https://app.nanonets.com/api/v2/OCR/Model/REPLACE_MODEL_ID/UploadUrls/")
.post(body)
.addHeader("Content-Type", ""application/json"")
.addHeader("Authorization", Credentials.basic("[[.ApiKey]]", ""))
.build();
Response response = client.newCall(request).execute();
/OCR/Model/{model_id}/UploadFile:
post:
tags:
- ocrUpload
summary: Upload Training Images by File
description: |
Upload a training image to the specified model using a locally stored file.
On successful upload, model information along with the total number of images per category will be received.
<br />
<br />
**NOTE**: Batch file uploads are not supported by this end point.
operationId: "ocr/upload/file"
parameters:
- $ref: "#/components/parameters/modelId"
requestBody:
description: The parameters to be sent in the request's body.
content:
"multipart/form-data":
schema:
type: object
required:
- data
- file
properties:
data:
type: string
description: |
The name of the file to be uploaded.
<br />
**Format**: `"data": "[{"filename": "filename.ext"}]"`.
<br />
**NOTE**: The `filename` must be the same as the uploaded file name.
file:
$ref: "#/components/schemas/file"
encoding:
file:
contentType: "image/png, image/jpeg, application/pdf"
required: true
responses:
"200":
$ref: "#/components/responses/ok"
"400":
description: |
- File missing. Check if the file has been included in the request.
- Incorrect file type. Check if file you included is a valid PNG, JPEG or PDF file.
x-summary: BAD REQUEST
"401":
$ref: "#/components/responses/unauthorized"
"402":
$ref: "#/components/responses/paymentRequired"
"404":
$ref: "#/components/responses/notFound"
deprecated: false
x-codeSamples:
- lang: JavaScript
label: Node.js
source: >
var request = require('request')
var fs = require('fs')
const form_data = {'file' : fs.createReadStream('REPLACE_IMAGE_PATH.jpg'), 'data' : JSON.stringify([
{"filename":"REPLACE_IMAGE_FILENAME.jpg", "object":[{"name":"category1", "ocr_text":"text inside the bounding box", "bndbox": {"xmin": 1,"ymin":1,"xmax": 100, "ymax": 100}}]}])}
const options = {
url : 'https://app.nanonets.com/api/v2/OCR/Model/{{model_id}}/UploadFile/',
formData: form_data,
headers: {
'Authorization' : 'Basic ' + Buffer.from('[[.ApiKey]]' + ':').toString('base64')
}
}
request.post(options, function(err, httpResponse, body) {
console.log(body)
});
- lang: Python
label: Python
source: >
import requests
url = 'https://app.nanonets.com/api/v2/OCR/Model/{{model_id}}/UploadFile/'
data = {'file' :open('REPLACE_IMAGE_PATH.jpg', 'rb'), 'data' :('',
'[{"filename":"REPLACE_IMAGE_FILENAME.jpg", "object":
[{"name":"category1", "ocr_text":"text inside the bounding box", "bndbox": {"xmin": 1,"ymin":
1,"xmax": 100, "ymax": 100}}]}]')}
response = requests.post(url, auth=requests.auth.HTTPBasicAuth('[[.ApiKey]]', ''), files=data)
print(response.text)
- lang: Shell
label: CLI
source: |
curl --request POST \
--url 'https://app.nanonets.com/api/v2/OCR/Model/{{model_id}}/UploadFile/' \
--header 'Accept: multipart/form-data' \
-u '[[.ApiKey]]' \
-F 'data=[{"filename":"REPLACE_IMAGE_FILENAME.jpg", "object": [{"name":"category1", "ocr_text":"text inside the bounding box", "bndbox": {"xmin": 1,"ymin": 1,"xmax": 100, "ymax": 100}}]}]' \
-F 'file=@REPLACE_IMAGE_PATH.jpg'
- lang: Go
label: Go
source: |
package main
import (
"bytes"
"fmt"
"io"
"io/ioutil"
"mime/multipart"
"net/http"
"os"
"path/filepath"
)
func main() {
url := "https://app.nanonets.com/api/v2/OCR/Model/{{model_id}}/UploadFile/"
file, err := os.Open("test.jpg")
if err != nil {
fmt.Println(err)
return
}
defer file.Close()
body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
part, err := writer.CreateFormFile("file", filepath.Base("test.jpg"))
if err != nil {
fmt.Println(err)
return
}
_, err = io.Copy(part, file)
writer.WriteField("data", `[{"filename":"REPLACE_IMAGE_FILENAME.jpg", "object": [{"name":"category1", "ocr_text":"text inside the bounding box", "bndbox": {"xmin": 1,"ymin": 1,"xmax": 100, "ymax": 100}}]}]`)
contentType := writer.FormDataContentType()
err = writer.Close()
if err != nil {
fmt.Println(err)
return
}
req, _ := http.NewRequest("POST", url, body)
req.Header.Add("Content-Type", contentType)
req.SetBasicAuth("[[.ApiKey]]", "")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
outputBody, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(outputBody))
}
- lang: Ruby
label: Ruby
source: |
require 'uri'
require 'net/http'
require 'net/http/post/multipart'
url = URI('https://app.nanonets.com/api/v2/OCR/Model/{{model_id}}/UploadFile/')
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
File.open('REPLACE_IMAGE_PATH.jpg') do |jpg|
request = Net::HTTP::Post::Multipart.new url.path,
'file' => UploadIO.new(jpg, 'image/jpeg', 'REPLACE_IMAGE_PATH.jpg'),
'data' => '[{"filename":"REPLACE_IMAGE_FILENAME.jpg", "object":[{"name":"category1", "ocr_text":"text inside the bounding box", "bndbox":{"xmin":1,"ymin":1,"xmax":100, "ymax":100}}]}]'
request.basic_auth '[[.ApiKey]]', ''
response = Net::HTTP.start(url.host, url.port) do |http|
http.request(request)
end
puts response.read_body
end
- lang: "C#"
label: "C#"
source: |
var client = new RestClient("https://app.nanonets.com/api/v2/OCR/UploadFile/");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Basic [[.ApiKey]]");
request.AddHeader("Accept", "multipart/form-data");
request.AddParameter("data", "[{\"filename\":\"REPLACE_IMAGE_FILENAME.jpg\", \"object\": [{\"name\":\"category1\", \"ocr_text\":\"text inside the bounding box\", \"bndbox\": {\"xmin\": 1,\"ymin\": 1,\"xmax\": 100, \"ymax\": 100}}]}]");
request.AddFile("file", "REPLACE_IMAGE_PATH.jpg");
IRestResponse response = client.Execute(request);"
- lang: Java
label: Java
source: |
private static final MediaType MEDIA_TYPE_JPG = MediaType.parse("image/jpeg");
OkHttpClient client = new OkHttpClient();
RequestBody requestBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("data", "[{\"filename\":\"REPLACE_IMAGE_FILENAME.jpg\", \"object\": [{\"name\":\"category1\", \"ocr_text\":\"text inside the bounding box\", \"bndbox\": {\"xmin\": 1,\"ymin\": 1,\"xmax\": 100, \"ymax\": 100}}]}]")
.addFormDataPart("file", "REPLACE_IMAGE_PATH.jpg", RequestBody.create(MEDIA_TYPE_JPG, new File("REPLACE_IMAGE_PATH.jpg")))
.build();
request = new Request.Builder()
.url("https://app.nanonets.com/api/v2/OCR/Model/{{model_id}}/UploadFile/")
.post(requestBody)
.addHeader("Authorization", Credentials.basic("[[.ApiKey]]", ""))
.build();
Response response = client.newCall(request).execute();"
/OCR/Model/{model_id}/Train:
post:
tags:
- ocrTrain
summary: Train Model
description: |
Train a model after uploading files to the model.
The same end point is to be used to re-train a model after uploading more files to improve the model.
operationId: "ocr/train"
parameters:
- $ref: "#/components/parameters/modelId"
responses:
"200":
description: Request successful.
content:
"application/json":
schema:
type: object
examples:
ok:
summary: Request successful
description: >
200 OK: Request successful
value:
model_id: 00000000-0000-0000-0000-000000000000
model_type: ocr
state: 0
categories:
- name: category1
count: 0
- name: category2
count: 0
x-summary: OK
"400":
description: Model not ready for training. Check if the files for the model are uploaded.
x-summary: BAD REQUEST
"401":
$ref: "#/components/responses/unauthorized"
"402":
description: This feature is only supported for paid models. ([Pricing](https://nanonets.com/pricing))
x-summary: PAYMENT REQUIRED
"404":
$ref: "#/components/responses/notFound"
deprecated: false
x-codeSamples:
- lang: JavaScript
label: Node.js
source: >
var request = require('request')
const options = {
url : 'https://app.nanonets.com/api/v2/OCR/Model/{{model_id}}/Train/',
headers: {
'Authorization' : 'Basic ' + Buffer.from('[[.ApiKey]]' + ':').toString('base64')
}
}
request.post(options, function(err, httpResponse, body) {
console.log(body)
});
- lang: Python
label: Python
source: |
import requests
url = 'https://app.nanonets.com/api/v2/OCR/Model/{{model_id}}/Train/'
response = requests.request('POST', url, auth=requests.auth.HTTPBasicAuth('[[.ApiKey]]', ''))
print(response.text)
- lang: Shell
label: CLI
source: |
curl --request POST \
--url 'https://app.nanonets.com/api/v2/OCR/REPLACE_MODEL_ID/Train/' \
-u '[[.ApiKey]]'
- lang: Go
label: Go
source: |
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://app.nanonets.com/api/v2/OCR/Model/{{model_id}}/Train/"
req, _ := http.NewRequest("POST", url, nil)
req.SetBasicAuth("[[.ApiKey]]", "")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
- lang: Ruby
label: Ruby
source: >
require 'uri'
require 'net/http'
url = URI('https://app.nanonets.com/api/v2/OCR/Model/{{model_id}}/Train/')
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request.basic_auth '[[.ApiKey]]', ''
response = http.request(request)
puts response.read_body
- lang: "C#"
label: "C#"
source: >
var client = new
RestClient("https://app.nanonets.com/api/v2/OCR/Model/{{model_id}}/Train/");
var request = new RestRequest(Method.POST);
request.AddHeader("authorization", "Basic [[.ApiKey]]");
IRestResponse response = client.Execute(request);
- lang: Java
label: Java
source: |
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://app.nanonets.com/api/v2/OCR/Model/{{model_id}}/Train/")
.post(null)
.addHeader("Authorization", Credentials.basic("[[.ApiKey]]", ""))
.build();
Response response = client.newCall(request).execute();
/Inferences/Model/{model_id}/ImageLevelInferences:
get:
tags:
- ocrPredict
summary: Get All Prediction Files
description: Retrieve the files that have been processed by the prediction end points.
operationId: "ocr/predict/getFile"
parameters:
- $ref: "#/components/parameters/modelId"
- name: start_day_interval
in: query
description: |
The start of the interval for which prediction files are needed.
<br />
**Format**: Number of days since [Unix epoch time](https://www.epochconverter.com)
<br />
**Eg**: 1620130500 seconds / 86400 seconds per day ~ `18,751` days
required: true
schema:
type: integer
- name: current_batch_day
in: query
description: |
The end of the interval for which prediction files are needed.
<br />
**Format**: Number of days since [Unix epoch time](https://www.epochconverter.com)
<br />
**Eg**: 1630930872 seconds / 86400 seconds per day ~ `18,876` days
<br />
**NOTE**: The value of this parameter has to be greater than the value of the [`start_day_interval` parameter](#operation/ocr/predict/getfile!in=query&path=start_day_interval&t=request).
required: true
schema:
type: integer
responses:
"200":
description: Image object.
content:
"application/json":
schema:
type: object
examples:
ok:
summary: Request successful.
description: >
200 OK: Request successful
value:
moderated_images_count: 55
unmoderated_images_count: 156
moderated_images:
- model_id: category1
day_since_epoch: 18564
is_moderated: true
hour_of_day: 15
id: 00000000-0000-0000-0000-000000000000
url: uploadedfiles/00000000-0000-0000-0000-000000000000/PredictionImages/0000000001.jpeg
predicted_boxes:
- label: invoice_id
xmin: 616
ymin: 321
xmax: 984
ymax: 357
ocr_text: "877541"
unmoderated_images:
- model_id: 00000000-0000-0000-0000-000000000000
day_since_epoch: 18565
is_moderated: false
hour_of_day: 23
id: 00000000-0000-0000-0000-000000000000
url: uploadedfiles/00000000-0000-0000-0000-000000000000/PredictionImages/0000000002.jpeg
predicted_boxes:
- label: seller_name
xmin: 616
ymin: 321
xmax: 984
ymax: 357
ocr_text: "Apple"
x-summary: OK
"401":
$ref: "#/components/responses/unauthorized"
"402":
$ref: "#/components/responses/paymentRequired"
"404":
$ref: "#/components/responses/notFound"
deprecated: false
x-codeSamples:
- lang: JavaScript
label: Node.js
source: >
var request = require('request')
const options = {
url : 'https://app.nanonets.com/api/v2/Inferences/Model/' + 'REPLACE_MODEL_ID' + '/ImageLevelInferences?start_day_interval={start_day}¤t_batch_day={end_day}',
headers: {
'Authorization' : 'Basic ' + Buffer.from('[[.ApiKey]]' + ':').toString('base64')
}
}
request.get(options, function(err, httpResponse, body) {
console.log(body)
});
- lang: Python
label: Python
source: >
import requests
url = 'https://app.nanonets.com/api/v2/Inferences/Model/' + 'REPLACE_MODEL_ID' + '/ImageLevelInferences?start_day_interval={start_day}¤t_batch_day={end_day}'
response = requests.request('GET', url,
auth=requests.auth.HTTPBasicAuth('[[.ApiKey]]',''))
print(response.text)
- lang: Shell
label: CLI
source: |
curl --request GET \
--url 'https://app.nanonets.com/api/v2/Inferences/Model/{{model_id}}/ImageLevelInferences?start_day_interval={start_day}¤t_batch_day={end_day}' \
-u '[[.ApiKey]]'
- lang: Go
label: Go
source: |
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://app.nanonets.com/api/v2/Inferences/Model/{{model_id}}/ImageLevelInferences?start_day_interval={start_day}¤t_batch_day={end_day}"
req, _ := http.NewRequest("GET", url, nil)
req.SetBasicAuth("[[.ApiKey]]", "")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
- lang: Ruby
label: Ruby
source: >
require 'uri'
require 'net/http'
url = URI("https://app.nanonets.com/api/v2/Inferences/Model/{{model_id}}/ImageLevelInferences?start_day_interval={start_day}¤t_batch_day={end_day}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request.basic_auth '[[.ApiKey]]', ''
response = http.request(request)
puts response.read_body
- lang: "C#"
label: "C#"
source: >
var client = new RestClient("https://app.nanonets.com/api/v2/Inferences/Model/{{model_id}}/ImageLevelInferences?start_day_interval={start_day}¤t_batch_day={end_day}");
var request = new RestRequest(Method.GET);
request.AddHeader("authorization", "Basic " + Convert.ToBase64String(Encoding.Default.GetBytes("[[.ApiKey]]:")));
IRestResponse response = client.Execute(request);
- lang: Java
label: Java
source: |
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://app.nanonets.com/api/v2/Inferences/Model/{{model_id}}/ImageLevelInferences?start_day_interval={start_day}¤t_batch_day={end_day}")
.get()
.addHeader("authorization", Credentials.basic("[[.ApiKey]]", ""))
.build();
Response response = client.newCall(request).execute();
/Inferences/Model/{model_id}/ImageLevelInferences/{id}:
get:
tags:
- ocrPredict
summary: Get Prediction File by ID
description: Retrieve the prediction results of a particular file by its ID.
operationId: "ocr/predict/id"
parameters:
- $ref: "#/components/parameters/modelId"
- name: id
in: path
description: |
The ID of the file for which the prediction has to be retrieved. It can be found in the response on uploading prediction files [synchronously](#operation/ocr/predict/file) or [asynchronously](#operation/ocr/predict/file/async) or while [retrieving all prediction file data](#operation/ocr/predict/getFile).
<br />
**Eg**: `0a0aa000-0000-0a0-aa00-000a0000000a`
required: true
schema:
type: string
responses:
"200":
$ref: "#/components/responses/okPrediction"
"401":
$ref: "#/components/responses/unauthorized"
"402":
$ref: "#/components/responses/paymentRequired"
"404":
$ref: "#/components/responses/notFound"
deprecated: false
x-codeSamples:
- lang: JavaScript
label: Node.js
source: >
var request = require('request')
const options = {
url : 'https://app.nanonets.com/api/v2/Inferences/Model/{{model_id}}/ImageLevelInferences/{{id}}',
headers: {
'Authorization' : 'Basic ' + Buffer.from('[[.ApiKey]]' + ':').toString('base64')
}
}
request.get(options, function(err, httpResponse, body) {
console.log(body)
});
- lang: Python
label: Python
source: >
import requests
url = 'https://app.nanonets.com/api/v2/Inferences/Model/{{model_id}}/ImageLevelInferences/{{id}}'
response = requests.request('GET', url,
auth=requests.auth.HTTPBasicAuth('[[.ApiKey]]',''))
print(response.text)
- lang: Shell
label: CLI
source: |
curl --request GET \
--url 'https://app.nanonets.com/api/v2/Inferences/Model/{{model_id}}/ImageLevelInferences/{{id}}' \
-u '[[.ApiKey]]'
- lang: Go
label: Go
source: |
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://app.nanonets.com/api/v2/Inferences/Model/{{model_id}}/ImageLevelInferences/{{id}}"
req, _ := http.NewRequest("GET", url, nil)
req.SetBasicAuth("[[.ApiKey]]", "")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
- lang: Ruby
label: Ruby
source: >
require 'uri'
require 'net/http'
url = URI("https://app.nanonets.com/api/v2/Inferences/Model/{{model_id}}/ImageLevelInferences/{{id}}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request.basic_auth '[[.ApiKey]]', ''
response = http.request(request)
puts response.read_body
- lang: "C#"
label: "C#"
source: >
var client = new RestClient("https://app.nanonets.com/api/v2/Inferences/Model/{{model_id}}/ImageLevelInferences/{{id}}");
var request = new RestRequest(Method.GET);
request.AddHeader("authorization", "Basic " + Convert.ToBase64String(Encoding.Default.GetBytes("[[.ApiKey]]:")));