Skip to content

Simple API that store words meanings and translate words to DB. Using Lumen Framework.

Notifications You must be signed in to change notification settings

bozanbungee/words-translation-API

Repository files navigation

Create words translation API

Installation note

  • git clone https://github.com/bozanbungee/words-translation-API.git
  • via terminal $> composer update (install all vendors)
  • Create Database schema translate-en-app in MySql
  • Connect DB via .env file
  • via terminal $> php artisan migrate (create table in DB Schema)
  • via terminal $> php -S localhost:8000 -t public (local web server on port 8000)

API Documentation

Login restriction with 1 account configured through the config file.

Login restriction trough middleware via boot method in /app/Providers/AuthServiceProvider.php

  • API accept Api-Token(key) and value that have to be the same as API_KEY in .env file
  • Should be sent for store, update and destroy method.

Simple CRUD for words that we have in the database

Database

  • Fields (id, word, word_in_bg, meaning, created_at, updated_at);
  • php artisan command for migration trough app/database/migration
  • php artisan command for Fake database through database Seeder in /app/database/seeds

CRUD OPERATION

API for store, update, destroy

  • POST http://localhost/api/v1/store/

    • Parameters via body [{key:word value:word in English}, {key:meaning value:meaning in english} ]
    • controller: 'TranslateController@store' -Protected via Auth (accept Api-Token in header)
    • This method will store a row to Database.
    • Word in English will be translated via method getEnToBgString($string) in /app/Http/Controller/Controller.php
  • PUT http://localhost/api/v1/update/{id}

    • Parameters via body [{key:word value:word in English}, {key:meaning value:meaning in english} ] and {id} from DB.
    • controller: 'TranslateController@update' -Protected via Auth (accept Api-Token in header)
    • This method will update a row to Database.
    • Word in English will be translated via method getEnToBgString($string) in /app/Http/Controller/Controller.php
  • DELETE http://localhost/api/v1/destroy/{id}

    • controller: 'TranslateController@destroy' -Protected via Auth (accept Api-Token in header)
    • {id} from DB.
    • This method will delete a row from Database.

API for get data

API for putting data via CSV file

Method via multipart/form

The only route which accepts api-token via get parameter ?api-token=API-Key from .env file

Method via POST and csv in server folder app/public/csv/

  • POST http://localhost/api/v1/csv/get_csv_from_folder
    • post parameter filename=name of csv from /public/csv folder without .csv extension*
    • controller: 'CsvController@getFromFolder'
    • This method will upload batch data to database from csv file in /public/csv folder

About

Simple API that store words meanings and translate words to DB. Using Lumen Framework.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published