-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.md
119 lines (102 loc) · 2.6 KB
/
README.md
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
# CardCheck-API
![MIT License](https://img.shields.io/github/license/shine-jayakumar/Covid19-Exploratory-Analysis-With-SQL)
----
Validates a card number and returns the status and issuing network in json format
![CardCheck-API](https://github.com/shine-jayakumar/CardCheck-API/blob/main/cardcheck-api.PNG)
* #### URL
/api/cc/:cardnumber
* #### Method
`GET`
* #### URL Params
**Required:**
`cardnumber=[integer]`
* #### Data Params
None
* #### Success Response:
```json
{
"result":{
"cardnumber":"5100000010001004",
"is_valid":true,
"issuing_network":[
"Mastercard"
],
"length":16
},
"status":"success",
"status_code":"200"
}
```
* #### Error Response
**404:** Endpoint does not exist
```json
{
"result": {
"error": "Resource not found. Please refer to the documentation."
},
"status": "failed",
"status_code": "404"
}
```
**405:** A method except GET was used
```json
{
"result": {
"error": "This method type is not currently supported. Please refer to the documentation."
},
"status": "failed",
"status_code": "405"
}
```
**419:** Argument (cardnumber) missing
```json
{
"result": {
"error": "The requested resource is missing required arguments. Please refer to the documentation."
},
"status": "failed",
"status_code": "419"
}
```
**420:** Invalid arguments. Card number can only be digits not more than 20 characters.
```json
{
"result": {
"error": "The requested resource does not support one or more of the given parameters. Please refer to the documentation."
},
"status": "failed",
"status_code": "420"
}
```
**500:** Internal Server Error
```json
{
"result": {
"error": "Internal Server Error"
},
"status": "failed",
"status_code": "500"
}
```
* #### Sample Call
**Curl:**
```curl
curl https://cardcheck-api.herokuapp.com/api/cc/5100000010001004
```
**Python:**
```python
import requests
response = requests.get("https://cardcheck-api.herokuapp.com/api/cc/5100000010001004")
print(response)
```
**JavaScript:**
```javascript
// GET Request.
fetch('https://cardcheck-api.herokuapp.com/api/cc/5100000010001004')
// Handle success
.then(response => response.json()) // convert to json
.then(json => console.log(json)) //print data to console
.catch(err => console.log('Request Failed', err)); // Catch errors
```
#### LICENSE
[MIT LICENSE](https://github.com/shine-jayakumar/CardCheck-API/blob/main/LICENSE)