Skip to content

Commit 32ecaca

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 4ecfff2 + 2591afe commit 32ecaca

File tree

1 file changed

+76
-1
lines changed

1 file changed

+76
-1
lines changed

README.md

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,76 @@
1-
# API_Names
1+
# API_Names
2+
3+
API developed to search for a name by it's metaphone (br) on database and returns all similar names that it can found based on metaphone code and the levenshtein algorithm (0.8 of similarity).
4+
5+
## Setup
6+
- first run the API ```go run main.go```
7+
- use import wizzard on mysql workbench to upload the [.csv file](https://github.com/Darklabel91/API_Names/blob/main/database/name_types.csv)
8+
- have fun
9+
10+
## API
11+
This project suports a simple CRUD. the main endpoint is ```/name``` where you can search for a name and it returns the name, metaphone code and all it's variations
12+
13+
Every method expect Status:200 and JSON content-type as show bellow:
14+
15+
| Req | Endpoint | Description | Success | Error |
16+
|--------|----------------------------------------|-------------------------------------|-------------------|--------------------|
17+
| POST | /name | Create a name in the database | Status:200 - JSON | Status: 400 - JSON |
18+
| DELETE | /:id | Delete a name by given id | Status:200 - JSON | Status: 404 - JSON |
19+
| PUT | /:id | Update a name by given id | Status:200 - JSON | Status: 500 - JSON |
20+
| GET | /:id | Read name with given id | Status:200 - JSON | Status: 400 - JSON |
21+
| GET | /name/:name | Read name with given name | Status:200 - JSON | Status: 404 - JSON |
22+
| GET | /metaphone/:name | Read metaphones of given name | Status:200 - JSON | Status: 404 - JSON |
23+
24+
25+
## Endpoint Examples
26+
27+
- GET - /:id
28+
```json
29+
{
30+
"ID": 3,
31+
"CreatedAt": "0001-01-01T00:00:00Z",
32+
"UpdatedAt": "0001-01-01T00:00:00Z",
33+
"DeletedAt": null,
34+
"Name": "ARON",
35+
"Classification": "M",
36+
"Metaphone": "ARM",
37+
"NameVariations": "|AARON|AHARON|AROM|ARON|ARYON|HARON|"
38+
}
39+
```
40+
41+
- GET - /name/:name
42+
```json
43+
{
44+
"ID": 3,
45+
"CreatedAt": "0001-01-01T00:00:00Z",
46+
"UpdatedAt": "0001-01-01T00:00:00Z",
47+
"DeletedAt": null,
48+
"Name": "ARON",
49+
"Classification": "M",
50+
"Metaphone": "ARM",
51+
"NameVariations": "|AARON|AHARON|AROM|ARON|ARYON|HARON|"
52+
}
53+
```
54+
55+
- GET - /metaphone/:name
56+
```json
57+
{
58+
"Name": "ARON",
59+
"metaphone": "ARM",
60+
"nameVariations": [
61+
"AARON",
62+
"AHARON",
63+
"ARION",
64+
"ARION",
65+
"ARNOM",
66+
"ARNON",
67+
"ARNON",
68+
"AROM",
69+
"ARON",
70+
"ARON",
71+
"ARYON",
72+
"HARNON",
73+
"HARON"
74+
]
75+
}
76+
```

0 commit comments

Comments
 (0)