git clone https://github.com/vinodnimbalkar/MarathiDictionaryAPI.git
cd MarathiDictionaryAPI
pip install -r requirements.txt
python marathiapi.py
-
POST /user
Register a new user.
The body must contain a JSON object that definesemail
andpassword
fields.
On success a status code 201 is returned. The body of the response contains a JSON object with the newly added user.{'message' : 'New user created!'}
On failure status code 400 (bad request) is returned.
Notes:- The password is hashed before it is stored in the database. Once hashed, the original password is discarded.
- In a production deployment secure HTTP must be used to protect the password in transit.
-
GET /login
Return an authentication token.
This request must be authenticated using a HTTP Basic Authentication header.
On success a JSON object is returned with a fieldtoken
set to the authentication token for the user and a fieldduration
set to the (approximate) number of seconds the token is valid. (here only for 30 minute)
On failure status code 401 (unauthorized) is returned. -
GET /engmar
Return a word with its meaning.
This request must be authenticated using a HTTP Basic Authentication header. Instead of email and password, the client can provide a valid authentication token in the x-access-token field.
On success a JSON object with data for the authenticated user is returned.
On failure status code 401 (unauthorized) is returned.