-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvat-validation.openapi.yaml
More file actions
538 lines (538 loc) · 18.7 KB
/
Copy pathvat-validation.openapi.yaml
File metadata and controls
538 lines (538 loc) · 18.7 KB
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
openapi: 3.0.3
info:
title: Abstract VAT Validation API
description: 'Validate a VAT number and retrieve the registered company details,
calculate VAT-compliant prices for a given amount and country, and look up the
latest VAT rates and reduced-rate categories for a country. Authenticate with
your API key as the `api_key` query parameter, or as an `Authorization: Bearer
<key>` header. GET and POST (form-encoded or JSON) are both supported.'
version: 1.0.0
termsOfService: https://www.abstractapi.com/legal/legal
contact:
name: Abstract API
url: https://www.abstractapi.com/api/vat-validation-rates-api
license:
name: Commercial — see Terms of Service
url: https://www.abstractapi.com/legal/legal
externalDocs:
description: Official documentation
url: https://docs.abstractapi.com/api/vat-validation
servers:
- url: https://vat.abstractapi.com/v1
security:
- ApiKeyQuery: []
- BearerAuth: []
x-openItems:
- The exact code and message strings for the 422 (quota reached / insufficient credits),
429 (rate limit) and 500 (server error) responses are unconfirmed. The error
envelope shape is modeled from the documented 400/401 examples, but the literal
code and message values for these statuses are not verified against production.
- Which response fields can truly return null is assumed generously per the
nullability convention and needs production confirmation. Specifically, this
spec marks VatCalculation.amount_excluding_vat, amount_including_vat, vat_amount
and vat_rate as nullable, and VatCategory.rate and category as nullable; these
assumptions need backend confirmation.
- Whether VatValidation.company and VatValidation.country can be null on a valid
VAT lookup (and which of their sub-fields can be null) is assumed and needs
production confirmation.
- The calculate and categories docs label the monetary/rate fields
(amount_excluding_vat, amount_including_vat, vat_amount, vat_rate, and
VatCategory.rate) as Float, but the documented JSON examples return them as
quoted strings (e.g. '175.00', '0.190', '0.070'). They are modeled as
type:string to match the actual wire format; the Float-vs-string discrepancy
needs backend confirmation.
- CORS support is unknown and needs confirmation.
paths:
/validate:
get:
operationId: getValidateVat
summary: Validate a VAT number
description: Checks whether the submitted VAT number is valid and, if it is,
returns the registered company details.
parameters:
- name: vat_number
in: query
required: true
description: The VAT number to validate.
schema:
type: string
example: SE556656688001
responses:
'200':
description: Validation result for the VAT number.
content:
application/json:
schema:
$ref: '#/components/schemas/VatValidation'
example:
vat_number: SE556656688001
valid: true
company:
name: GOOGLE SWEDEN AB
address: "GOOGLE IRLAND LTD \nM COLLINS, GORDON HOUSE \nBARROW STREET,\
\ DUBLIN 4 \nIRLAND"
country:
code: SE
name: Sweden
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'422':
$ref: '#/components/responses/QuotaReached'
'429':
$ref: '#/components/responses/TooManyRequests'
'500':
$ref: '#/components/responses/ServerError'
post:
operationId: postValidateVat
summary: Validate a VAT number
description: 'Same as the GET operation. The API key may be supplied in the
request body, as the `api_key` query parameter, or as an `Authorization: Bearer
<key>` header.'
requestBody:
required: true
content:
application/x-www-form-urlencoded:
schema:
$ref: '#/components/schemas/ValidateRequest'
application/json:
schema:
$ref: '#/components/schemas/ValidateRequest'
responses:
'200':
description: Validation result for the VAT number.
content:
application/json:
schema:
$ref: '#/components/schemas/VatValidation'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'422':
$ref: '#/components/responses/QuotaReached'
'429':
$ref: '#/components/responses/TooManyRequests'
'500':
$ref: '#/components/responses/ServerError'
/calculate:
get:
operationId: getCalculateVat
summary: Calculate VAT for an amount
description: Determines VAT-compliant prices for a given value, country, and
purchase type.
parameters:
- name: amount
in: query
required: true
description: The amount that you would like to get the VAT amount for or from.
schema:
type: string
example: '175'
- name: country_code
in: query
required: true
description: The two-letter ISO 3166-1 alpha-2 code of the country in which
the transaction takes place.
schema:
type: string
example: DE
- name: is_vat_incl
in: query
required: false
description: Set to true if the amount already includes VAT and you would
like to perform the reverse calculation. Defaults to false.
schema:
type: boolean
example: false
- name: vat_category
in: query
required: false
description: The category of goods or services, used when a country offers
a reduced VAT rate for certain categories.
schema:
type: string
example: standard
responses:
'200':
description: The calculated VAT-inclusive and VAT-exclusive amounts.
content:
application/json:
schema:
$ref: '#/components/schemas/VatCalculation'
example:
amount_excluding_vat: '175.00'
amount_including_vat: '208.25'
vat_amount: '33.25'
vat_category: standard
vat_rate: '0.190'
country:
code: DE
name: Germany
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'422':
$ref: '#/components/responses/QuotaReached'
'429':
$ref: '#/components/responses/TooManyRequests'
'500':
$ref: '#/components/responses/ServerError'
post:
operationId: postCalculateVat
summary: Calculate VAT for an amount
description: 'Same as the GET operation. The API key may be supplied in the
request body, as the `api_key` query parameter, or as an `Authorization: Bearer
<key>` header.'
requestBody:
required: true
content:
application/x-www-form-urlencoded:
schema:
$ref: '#/components/schemas/CalculateRequest'
application/json:
schema:
$ref: '#/components/schemas/CalculateRequest'
responses:
'200':
description: The calculated VAT-inclusive and VAT-exclusive amounts.
content:
application/json:
schema:
$ref: '#/components/schemas/VatCalculation'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'422':
$ref: '#/components/responses/QuotaReached'
'429':
$ref: '#/components/responses/TooManyRequests'
'500':
$ref: '#/components/responses/ServerError'
/categories:
get:
operationId: getVatCategories
summary: List VAT rates and categories for a country
description: Returns the latest VAT rates for a specific country, including the
standard rate and any reduced-rate categories.
parameters:
- name: country_code
in: query
required: true
description: The two-letter ISO 3166-1 alpha-2 code of the country in which
the transaction takes place.
schema:
type: string
example: DE
responses:
'200':
description: An array of VAT rate categories for the specified country.
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/VatCategory'
example:
- country_code: DE
rate: '0.070'
category: water
description: Supply of water. No reduced rate for bottled water...
- country_code: DE
rate: '0.070'
category: foodstuffs
description: Foodstuffs (including beverages but excluding alcoholic
beverages) for human...
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'422':
$ref: '#/components/responses/QuotaReached'
'429':
$ref: '#/components/responses/TooManyRequests'
'500':
$ref: '#/components/responses/ServerError'
post:
operationId: postVatCategories
summary: List VAT rates and categories for a country
description: 'Same as the GET operation. The API key may be supplied in the
request body, as the `api_key` query parameter, or as an `Authorization: Bearer
<key>` header.'
requestBody:
required: true
content:
application/x-www-form-urlencoded:
schema:
$ref: '#/components/schemas/CategoriesRequest'
application/json:
schema:
$ref: '#/components/schemas/CategoriesRequest'
responses:
'200':
description: An array of VAT rate categories for the specified country.
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/VatCategory'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'422':
$ref: '#/components/responses/QuotaReached'
'429':
$ref: '#/components/responses/TooManyRequests'
'500':
$ref: '#/components/responses/ServerError'
components:
securitySchemes:
ApiKeyQuery:
type: apiKey
in: query
name: api_key
description: Your unique VAT Validation API key.
BearerAuth:
type: http
scheme: bearer
description: Send your API key as a Bearer token; omit `api_key` from the query
string.
responses:
BadRequest:
description: Bad request — a required parameter is missing or failed validation.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error:
message: A validation error occurred.
code: validation_error
details:
vat_number:
- This is a required argument.
Unauthorized:
description: Unauthorized — missing or invalid API key.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error:
message: Invalid API key provided.
code: unauthorized
details: null
QuotaReached:
description: Unprocessable — monthly quota reached or insufficient API credits.
The body follows the standard error envelope.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
TooManyRequests:
description: Too Many Requests — rate limit exceeded (free plans are limited
to 1 request per second). The body follows the standard error envelope.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
ServerError:
description: Internal server error. The body follows the standard error envelope.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
schemas:
ValidateRequest:
type: object
required:
- vat_number
properties:
vat_number:
type: string
description: The VAT number to validate.
example: SE556656688001
api_key:
type: string
description: 'Your API key. Optional here if supplied as the `api_key` query
parameter or an `Authorization: Bearer <key>` header.'
CalculateRequest:
type: object
required:
- amount
- country_code
properties:
amount:
type: string
description: The amount that you would like to get the VAT amount for or
from.
example: '175'
country_code:
type: string
description: The two-letter ISO 3166-1 alpha-2 code of the country in which
the transaction takes place.
example: DE
is_vat_incl:
type: boolean
description: Set to true if the amount already includes VAT and you would
like to perform the reverse calculation. Defaults to false.
example: false
vat_category:
type: string
description: The category of goods or services, used when a country offers
a reduced VAT rate for certain categories.
example: standard
api_key:
type: string
description: 'Your API key. Optional here if supplied as the `api_key` query
parameter or an `Authorization: Bearer <key>` header.'
CategoriesRequest:
type: object
required:
- country_code
properties:
country_code:
type: string
description: The two-letter ISO 3166-1 alpha-2 code of the country in which
the transaction takes place.
example: DE
api_key:
type: string
description: 'Your API key. Optional here if supplied as the `api_key` query
parameter or an `Authorization: Bearer <key>` header.'
Error:
type: object
required:
- error
properties:
error:
type: object
required:
- message
- code
properties:
message:
type: string
description: Human-readable description of the error.
example: A validation error occurred.
code:
type: string
description: Machine-readable error code, e.g. validation_error or unauthorized.
example: validation_error
details:
type: object
nullable: true
description: Field-keyed validation messages for validation_error responses;
null for other error types.
additionalProperties:
type: array
items:
type: string
VatValidation:
type: object
properties:
vat_number:
type: string
description: The VAT number that was submitted for validation.
example: SE556656688001
valid:
type: boolean
description: True if the submitted VAT number is valid.
example: true
company:
type: object
nullable: true
description: Registered company details associated with the VAT number;
may be null when no company details are available.
properties:
name:
type: string
nullable: true
description: The name of the company associated with the VAT number.
address:
type: string
nullable: true
description: The address of the company associated with the VAT number.
country:
type: object
nullable: true
description: The country associated with the VAT number; may be null when
it cannot be determined.
properties:
code:
type: string
nullable: true
description: The two-letter ISO 3166-1 alpha-2 code of the country.
name:
type: string
nullable: true
description: The name of the country.
VatCalculation:
type: object
properties:
amount_excluding_vat:
type: string
nullable: true
description: The transaction amount before VAT.
example: '175.00'
amount_including_vat:
type: string
nullable: true
description: The transaction amount with VAT included.
example: '208.25'
vat_amount:
type: string
nullable: true
description: The VAT portion of the amount.
example: '33.25'
vat_category:
type: string
nullable: true
description: The category of goods or services used for the calculation;
null when no specific category applies.
example: standard
vat_rate:
type: string
nullable: true
description: The VAT rate applied, expressed as a decimal fraction.
example: '0.190'
country:
type: object
nullable: true
description: The country in which the transaction takes place.
properties:
code:
type: string
nullable: true
description: The two-letter ISO 3166-1 alpha-2 code of the country.
name:
type: string
nullable: true
description: The name of the country.
VatCategory:
type: object
properties:
country_code:
type: string
description: The two-letter ISO 3166-1 alpha-2 code of the country.
example: DE
rate:
type: string
nullable: true
description: The VAT rate for this category, expressed as a decimal fraction.
example: '0.070'
category:
type: string
nullable: true
description: The name of the category.
example: water
description:
type: string
nullable: true
description: A description of the category; may be an empty string or null.
example: Supply of water. No reduced rate for bottled water...