-
Notifications
You must be signed in to change notification settings - Fork 0
/
apiary.apib
759 lines (595 loc) · 22.2 KB
/
apiary.apib
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
FORMAT: 1A6
HOST: https://osobniskore.cz/api
# Personal Score Partner API
Personal Score is API for evaluating client credibility and recommend useful step how to improve it.
# Rules of thumb
## API Quota, limits, rate limiting, QoS
And other ugly words may follow. Please take into account that even our system has limits.
Do to this API as you would have others to do to your own API.
Currently, there is an API Throttle functionality that forbids users to make huge amount of requests per time interval.
The algorithm used is Leaky Bucket that refreshes three token every second with a capacity of 500 tokens.
It means that if your robot makes three request per seconds on average, you're fine.
You can choose whether it is making three request every second, 1500 requests every 500 seconds on something in between.
These numbers can be changed anytime so make your client aware of the throttled HTTP response.
In case of client hitting the limit, the API responds with HTTP status code 429 - Too Many Requests.
If you're trying to accomplish any use case and the API Throttling functionality is preventing you from success, please contact us and we'll try to figure something out.
## Secure access
Use secure transport protocol (HTTPS) when accessing Partner API.
## OAuth 2 authentication
Zonky users are identified using [OAuth 2.0](http://oauth.net/2/) protocol. At the moment we support following OAuth 2 grant type:
* Client Credentials Grant Flow where client app obtains client ID and client Secret which is later exchanged for access token.
In case that you don't have valid access token you should initiate Client Credentials Grant Flow to obtain new one with limited validity.
If valid access token still exists repeating Client Credentials Grant Flow will always return same token.
# General errors
### API Quota
When using of API fulfil API Quota and rate limiting rule, or when week or month limit is reach for partner
subscription plan.
Response 429 (application/json)
```js
{
"error": "TOO_MANY_REQUESTS",
"error_description": "limit for using Partner API reached"
}
```
### Access token expired
When validity of subscription plan for partner expires.
Response 401 (application/json)
```js
{
"error": "invalid_token",
"error_description": "Invalid access token: 0e4c0a38-fefb-40f3-b4fb-e312f0caf501"
}
```
### API Subscription plan expired
When validity of subscription plan for partner expires.
Response 403 (application/json)
```js
{
"error": "SUBSCRIPTION_PLAN_EXPIRED",
"error_description": "Partner subscription plan expired"
}
```
## OAuth Authorization [/oauth]
### Request Access token [POST /oauth/token]
For OAuth2 authentication we provided `client_id` and `client_secret`.
Use both to generate username/password basic authentication header.
Within response you will obtain `access_token` that you will use for secured comunitation with API.
+ Request (application/x-www-form-urlencoded)
+ Headers
Authorization: Basic d2ViOndlYg==
+ Body
grant_type=client_credentials
+ Response 200 (application/json)
{
"access_token": "f6cb1d8c-f7a9-4e3f-a035-67ec5ad32ad1",
"token_type": "bearer",
"expires_in": 899,
"scope": "SCOPE_PARTNER_API"
}
+ Response 400 (application/json)
{
"error": "unauthorized",
"uuid": "Bad credentials"
}
+ Response 400 (application/json)
{
"error": "invalid_scope",
"error_description": "Invalid scope: SCOPE_PARTNER_APIS",
"scope": "SCOPE_PARTNER_API"
}
+ Response 400 (application/json)
{
"error": "invalid_client",
"error_description": "Bad Unauthorized grant type: password"
}
## Applications [/partners/me/applications]
### Create new Application [POST /partners/me/applications]
Create new application. Use response `Location` header for following operations.
+ Attributes
- `email` (string, optional)
- `phone` (string, optional)
- `birthYear` (number, required)
Valid date from 1900 to 2100
- `education` (enum, required)
- `PRIMARY`
- `CERTIFIED`
- `HIGH_SCHOOL`
- `HIGHER`
- `UNDERGRADUATE`
- `GRADUATE`
- `housingType` (enum, required)
- `RENT`
- `OWN_WITH_MORTGAGE`
- `OWN_WITHOUT_MORTGAGE`
- `COOPERATIVE`
- `FAMILY`
- `PARTNER`
- `SHARED`
- `gender` (enum, required)
- `MALE`
- `FEMALE`
- `maritalStatus` (enum, required)
- `MARRIED`
- `SINGLE`
- `PARTNER`
- `DIVORCED`
- `REGISTERED_PARTNERSHIP`
- `WIDOWER`
- `zipCode` (number, required)
5 digits e.g. 70200
- `primaryIncome` (number, required)
without space e.g. 10000, 505.90
+ Request (application/json)
+ Headers
Authorization: Bearer f6cb1d8c-f7a9-4e3f-a035-67ec5ad32ad1
+ Body
```js
{
"email": "[email protected]",
"phone": "+420777888999",
"birthYear" : 1989,
"education" : "HIGH_SCHOOL",
"housingType" : "RENT",
"gender" : "MALE",
"maritalStatus" : "MARRIED",
"zipCode" : 70200,
"primaryIncome": 10000.00
}
```
+ Response 201 (application/json)
+ Headers
Location: /partners/me/applications/f6cb1d8c-f7a9-4e3f-a035-67ec5ad32ad1
+ Response 400 (application/json)
```js
{
"error": "VALIDATION_ERROR",
"errorDescription": "The request validation did not pass",
"uuid": "e16e2f3f-b19b-4da4-a860-0e955de2c950",
"fieldErrors": [
{
"fieldName": "birthYear",
"rejectedValue": "2210",
"errorType": "Max",
"message": "must be less than or equal to 2100"
},
{
"fieldName": "education",
"rejectedValue": "MAM ZAKLADKU",
"errorType": "ValueOfEnum",
"message": "Must be any of enum [PRIMARY, CERTIFIED, HIGH_SCHOOL, HIGHER, UNDERGRADUATE, GRADUATE]"
}
]
}
```
### Get All Applications [GET /partners/me/applications{?page,size,createdFrom,createdTo,status}]
Gets all partners created applications data. Its possible to perform pagination and filtering.
+ Parameters
- page (number, optional) - Default is 0
- size (number, optional) - Default is 10
- createdFrom (string, `2021-03-14`, optional)
- createdTo (string, `2021-04-14`, optional)
- status (enum, optional)
- `OPEN`
- `PROCESSING_REQUESTED`
- `PROCESSING`
- `FAILED`
- `FINISHED`
- `EXPIRED`
+ Request
+ Headers
Authorization: Bearer f6cb1d8c-f7a9-4e3f-a035-67ec5ad32ad1
+ Response 200 (application/json)
```js
{
"uuid" : "6fdd5451-4476-4d11-8c17-407a13b8898d",
"createdAt": "2021-03-14T12:35:00",
"scoringFinishedAt": null
"email": null,
"phone": null,
"status": "OPEN"
}
```
+ Response 400 (application/json)
{
"error": "VALIDATION_ERROR",
"error_description":"The parameter with name 'status' has not valid value 'EXPIRE'",
"uuid": "4a934eef-86e7-46e3-a286-61b41b5f17e1"
}
### Get Application [GET /partners/me/applications/{application_uuid}]
Gets the applications data. If scoring is successfully completed we also provide scoring data result.
+ Parameters
+ application_uuid (string, `6fdd5451-4476-4d11-8c17-407a13b8898d`, required)
+ Request
+ Headers
Authorization: Bearer f6cb1d8c-f7a9-4e3f-a035-67ec5ad32ad1
+ Response 200 (application/json)
+ Attributes
- status (enum)
- `OPEN`
- `PROCESSING_REQUESTED`
- `PROCESSING`
- `FAILED`
- `FINISHED`
- `EXPIRED`
- `education` (enum)
- `PRIMARY`
- `CERTIFIED`
- `HIGH_SCHOOL`
- `HIGHER`
- `UNDERGRADUATE`
- `GRADUATE`
- `housingType` (enum)
- `RENT`
- `OWN_WITH_MORTGAGE`
- `OWN_WITHOUT_MORTGAGE`
- `COOPERATIVE`
- `FAMILY`
- `PARTNER`
- `SHARED`
- `gender` (enum)
- `MALE`
- `FEMALE`
- `maritalStatus` (enum)
- `MARRIED`
- `SINGLE`
- `PARTNER`
- `DIVORCED`
- `REGISTERED_PARTNERSHIP`
- `WIDOWER`
+ Body
```js
{
"uuid" : "6fdd5451-4476-4d11-8c17-407a13b8898d",
"createdAt": "2021-03-14T12:35:00",
"scoringFinishedAt": null
"email": null,
"phone": null,
"birthYear" : 1989,
"education" : "HIGH_SCHOOL",
"housingType" : "RENT",
"gender" : "MALE",
"maritalStatus" : "SINGLE",
"zipCode" : 70200,
"primaryIncome": 10000
"status": "OPEN",
"score": null
"recommendations": null,
"warnings": null
}
```
+ Response 200 (application/json)
```js
{
"uuid": "f6cb1d8c-f7a9-4e3f-a035-67ec5ad32ad1",
"createdAt": "2021-03-14T12:35:00",
"scoringFinishedAt": "2021-03-14T12:48:00",
"email": "[email protected]",
"phone": "+420777888999",
"birthYear" : 1989,
"education" : "HIGH_SCHOOL",
"housingType" : "RENT",
"gender" : "MALE",
"maritalStatus" : "SINGLE",
"zipCode" : 70200,
"primaryIncome": 10000,
"status": "FINISHED",
"score": {
"finalScore": 525,
"estimatedInterestRate": 5.99
},
"recommendations": [
{
"title": "Plaťte včas",
"message": "Splátky půjček a faktury za služby plaťte vždy včas. Nastavte si trvalý příkaz nebo inkaso.",
"priority": 1
},
{
"title": "Mějte kontrolu nad svými výdaji",
"message": "Neutrácejte víc, než si můžete dovolit. Neřešte období před výplatou mikropůjčkami.",
"priority": 2
},
{
"title": "Budujte si úvěrovou historii",
"message": "Lepší než nemít žádnou půjčku je mít rozumnou půjčku a řádně ji splácet. Prokážete se jako důvěryhodný a spolehlivý člověk.",
"priority": 3
}
],
"warnings": [
"OLD_STATEMENTS"
]
}
```
+ Response 404 (application/json)
{
"error": "NOT_FOUND",
"error_description":"Resource was not found",
"uuid": "4f6e5019-3c21-4dc5-ab1c-e5df414b1176"
}
### Update Application [PUT /partners/me/applications/{application_uuid}]
Update existing application data.
+ Parameters
+ application_uuid (string, `6fdd5451-4476-4d11-8c17-407a13b8898d`, required)
+ Request (application/json)
+ Headers
Authorization: Bearer f6cb1d8c-f7a9-4e3f-a035-67ec5ad32ad1
+ Attributes
- `email` (string, optional)
- `phone` (string, optional)
- `birthYear` (number, required)
Valid date from 1900 to 2100
- `education` (enum, required)
- `PRIMARY`
- `CERTIFIED`
- `HIGH_SCHOOL`
- `HIGHER`
- `UNDERGRADUATE`
- `GRADUATE`
- `housingType` (enum, required)
- `RENT`
- `OWN_WITH_MORTGAGE`
- `OWN_WITHOUT_MORTGAGE`
- `COOPERATIVE`
- `FAMILY`
- `PARTNER`
- `SHARED`
- `gender` (enum, required)
- `MALE`
- `FEMALE`
- `maritalStatus` (enum, required)
- `MARRIED`
- `SINGLE`
- `PARTNER`
- `DIVORCED`
- `REGISTERED_PARTNERSHIP`
- `WIDOWER`
- `zipCode` (number, required)
e.g. 70200
- `primaryIncome` (number, required)
not space or decimal points e.g. 10000
+ Body
```js
{
"email": "[email protected]",
"phone": "+420777888999",
"birthYear" : 1989,
"education" : "HIGH_SCHOOL",
"housingType" : "RENT",
"gender" : "MALE",
"maritalStatus" : "MARRIED",
"zipCode" : 70200,
"primaryIncome": 10000
}
```
+ Response 200 (application/json)
+ Attributes
- status (enum)
- `OPEN`
- `PROCESSING_REQUESTED`
- `PROCESSING`
- `FAILED`
- `FINISHED`
- `EXPIRED`
- `education` (enum)
- `PRIMARY`
- `CERTIFIED`
- `HIGH_SCHOOL`
- `HIGHER`
- `UNDERGRADUATE`
- `GRADUATE`
- `housingType` (enum)
- `RENT`
- `OWN_WITH_MORTGAGE`
- `OWN_WITHOUT_MORTGAGE`
- `COOPERATIVE`
- `FAMILY`
- `PARTNER`
- `SHARED`
- `gender` (enum)
- `MALE`
- `FEMALE`
- `maritalStatus` (enum)
- `MARRIED`
- `SINGLE`
- `PARTNER`
- `DIVORCED`
- `REGISTERED_PARTNERSHIP`
- `WIDOWER`
+ Body
```js
{
"uuid" : "6fdd5451-4476-4d11-8c17-407a13b8898d",
"createdAt": "2021-03-14T12:35:00",
"scoringFinishedAt": null,
"email": null,
"phone": null,
"birthYear" : 1989,
"education" : "HIGH_SCHOOL",
"housingType" : "RENT",
"gender" : "MALE",
"maritalStatus" : "SINGLE",
"zipCode" : 70200,
"primaryIncome": 10000
"status": "OPEN",
"score": null,
"recommendations": null,
"warnings": null
}
```
+ Response 400 (application/json)
{
"error": "APPLICATION_STATUS_ERROR",
"error_description": "Application has invalid status for update",
"uuid": "4f6e5019-3c21-4dc5-ab1c-e5df414b1176"
}
+ Response 400 (application/json)
```js
{
"error": "VALIDATION_ERROR",
"errorDescription": "The request validation did not pass",
"uuid": "e16e2f3f-b19b-4da4-a860-0e955de2c950",
"fieldErrors": [
{
"fieldName": "birthYear",
"rejectedValue": "2210",
"errorType": "Max",
"message": "must be less than or equal to 2100"
}
]
}
```
+ Response 404 (application/json)
{
"error": "NOT_FOUND",
"error_description":"Resource was not found",
"uuid": "4f6e5019-3c21-4dc5-ab1c-e5df414b1176"
}
### Finish application [PUT /partners/me/applications/{application_uuid}/finish]
Finish populating data for application and execute scoring algorithm. State of parsing attachments and scoring could be
pool on `GET /partners/me/applications/{application_uuid}/status`. Final score and recomendations will be available
on `GET /partners/me/applications/{application_uuid}` and state of parsing and scoring is marked as `COMPLETED`.
+ Parameters
+ application_uuid (string, `6fdd5451-4476-4d11-8c17-407a13b8898d`, required)
+ Request
+ Headers
Authorization: Bearer f6cb1d8c-f7a9-4e3f-a035-67ec5ad32ad1
+ Response 202
+ Response 400
{
"error": "APPLICATION_STATUS_ERROR",
"errorDescription": "Application has invalid status for finish",
"uuid": "4f6e5019-3c21-4dc5-ab1c-e5df414b1176"
}
+ Response 400
{
"error": "MISSING_ATTACHMENT",
"errorDescription": "No attachments found for application, at least one is required",
"uuid": "4f6e5019-3c21-4dc5-ab1c-e5df414b1176"
}
+ Response 404 (application/json)
{
"error": "NOT_FOUND",
"error_description":"Resource was not found",
"uuid": "4f6e5019-3c21-4dc5-ab1c-e5df414b1176"
}
### Get Application processing status [GET /partners/me/applications/{application_uuid}/status]
Gets state of processing for specific application.
+ Parameters
+ application_uuid (string, `6fdd5451-4476-4d11-8c17-407a13b8898d`, required)
+ Request
+ Headers
Authorization: Bearer f6cb1d8c-f7a9-4e3f-a035-67ec5ad32ad1
+ Response 200 (application/json)
+ Attributes
- attachmentsParsingState(enum)
- `PENDING`
- `COMPLETED`
- `FAILED`
- scoringState(enum)
- `PENDING`
- `COMPLETED`
- `FAILED`
- attachmentsParsingErrorCode (enum)
- `UNSUPPORTED_MEDIA_TYPE`
Uploaded Attachment file is not PDF with bank statement
- `UNPROCESSABLE_ENTITY`
PDF file contans data that we are not able to process or bank is not supported
- `PARSER_ERROR`
Parsing of bank statements failed with unexpected error
- scoringErrorCode (enum)
- `TRANSACTION_QUERY_ERROR`
Preparing transaction data from bank statements failed
- `BRIEF_HISTORY_OF_STATEMENTS`
Transaction history is too short, required 3 months in row
- `LOW_NUMBER_OF_TRANSACTIONS`
Bank statements data contains low number of transactions for calculating score
Only CZK transactions will be processed
- `MISSING_STATEMENT_IN_ROW`
Required 3 months in row of bank statements in attachment
- `SCORING_FAILED`
Calculating of score failed with unexpected error
+ Response 200 (application/json)
```js
{
"attachmentsParsingState" : "PENDING",
"attachmentsParsingErrorCode" : null,
"scoringState" : "PENDING",
"scoringErrorCode" : null
}
```
+ Response 200 (application/json)
```js
{
"attachmentsParsingState" : "COMPLETED",
"attachmentsParsingErrorCode" : null,
"scoringState" : "COMPLETED",
"scoringErrorCode" : null
}
```
+ Response 200 (application/json)
```js
{
"attachmentsParsingState" : "FAILED",
"attachmentsParsingErrorCode" : "UNPROCESSABLE_ENTITY",
"scoringState" : "FAILED",
"scoringErrorCode" : "LOW_NUMBER_OF_TRANSACTIONS"
}
```
+ Response 404 (application/json)
{
"error": "NOT_FOUND",
"error_description":"Resource was not found",
"uuid": "4f6e5019-3c21-4dc5-ab1c-e5df414b1176"
}
## Application Attachments [/partners/me/applications/{application_uuid}/attachments]
### Upload attachment to application [POST /partners/me/applications/{application_uuid}/attachments]
Upload bank account statement in PDF format. Could be called multiple times, each statement will be parsed and include
into calculation of final score.
+ Request (multipart/form-data)
+ Parameters
+ application_uuid (string, `6fdd5451-4476-4d11-8c17-407a13b8898d`, required)
+ Headers
Authorization: Bearer f6cb1d8c-f7a9-4e3f-a035-67ec5ad32ad1
+ Body
file: [file content]
+ Response 201 (application/json)
+ Headers
Location: /partners/me/applications/6fdd5451-4476-4d11-8c17-407a13b8898d/attachments/4f6e5019-3c21-4dc5-ab1c-e5df414b1176
+ Response 400 (application/json)
{
"error": "APPLICATION_STATUS_ERROR",
"error_description": "Application has invalid status for update",
"uuid": "4f6e5019-3c21-4dc5-ab1c-e5df414b1176"
}
+ Response 400 (application/json)
{
"error": "UNSUPPORTED_MEDIA_TYPE",
"error_description": "Unsupported attachment media type 'image/svg+xml'",
"uuid": "4f6e5019-3c21-4dc5-ab1c-e5df414b1176"
}
+ Response 404 (application/json)
{
"error": "NOT_FOUND",
"error_description":"Resource was not found",
"uuid": "4f6e5019-3c21-4dc5-ab1c-e5df414b1176"
}
### Delete attachments for application [DELETE /partners/me/applications/{application_uuid}/attachments]
Delete all uploaded attachments for specific application. Use it to start over with sending application attachments
if there is some problem with previously uploaded files.
+ Request (application/json)
+ Parameters
+ application_uuid (string, `6fdd5451-4476-4d11-8c17-407a13b8898d`, required)
+ Headers
Authorization: Bearer f6cb1d8c-f7a9-4e3f-a035-67ec5ad32ad1
+ Response 204 (application/json)
+ Response 400 (application/json)
{
"error": "APPLICATION_STATUS_ERROR",
"error_description": "Application has invalid status for update",
"uuid": "4f6e5019-3c21-4dc5-ab1c-e5df414b1176"
}
+ Response 404 (application/json)
{
"error": "NOT_FOUND",
"error_description":"Resource was not found",
"uuid": "4f6e5019-3c21-4dc5-ab1c-e5df414b1176"
}