|
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 | +- GET - /metaphone/:name |
| 27 | +```json |
| 28 | +{ |
| 29 | + "Name": "THIAGO", |
| 30 | + "metaphone": "TG", |
| 31 | + "name_variations": [ |
| 32 | + "TAGO", |
| 33 | + "TAGOR", |
| 34 | + [...] |
| 35 | + ] |
| 36 | +} |
| 37 | +``` |
| 38 | + |
| 39 | +- GET - /:id |
| 40 | +```json |
| 41 | +{ |
| 42 | + "ID": 1, |
| 43 | + "CreatedAt": "0001-01-01T00:00:00Z", |
| 44 | + "UpdatedAt": "0001-01-01T00:00:00Z", |
| 45 | + "DeletedAt": null, |
| 46 | + "Name": "ALINE", |
| 47 | + "Classification": "F", |
| 48 | + "Metaphone": "A", |
| 49 | + "NameVariations": "|AALINE|AILINE|ALEINE|ALIINE|ALINE|ALINER|ALINHE|ALINNE|ALYNE|ALYNNE|AYLINE|EALINE|ELEINE|ELINE|ELINER|ELINNE|ELYNE|EULINE|HALINE|HALYNE|HELEINE|HELINE|HELYNE|IALINE|ILEINE|ILINE|LEINE|LEINER|LEYNE|LINE|LINER|LUEINE|LUINE|LUYNE|LYNE|LYNNE|OLINE|UELINE|" |
| 50 | +} |
| 51 | +``` |
| 52 | + |
| 53 | +- GET - /name/:name |
| 54 | +```json |
| 55 | +{ |
| 56 | + "ID": 3, |
| 57 | + "CreatedAt": "0001-01-01T00:00:00Z", |
| 58 | + "UpdatedAt": "0001-01-01T00:00:00Z", |
| 59 | + "DeletedAt": null, |
| 60 | + "Name": "ARON", |
| 61 | + "Classification": "M", |
| 62 | + "Metaphone": "ARM", |
| 63 | + "NameVariations": "|AARON|AHARON|AROM|ARON|ARYON|HARON|" |
| 64 | +``` |
| 65 | + |
0 commit comments