drdhaval2785 / prakriya

Create a web service for step by step derivation of verb forms of Sanskrit language.
16 stars 4 forks source link

API suggestions #6

Closed drdhaval2785 closed 6 years ago

drdhaval2785 commented 6 years ago

As per @vvasuki

  1. You'd be following REST API conventions (google it) better and it would be clearer if the URI were http://api.sanskritworld.in/v0.0.1/tinantas/slp1/jagAma/prakriya

  2. And you might have the API automatically produce the output in a desired encoding with query parameters of the type: http://api.sanskritworld.in/v0.0.1/tinantas/slp1/jagAma/prakriya?encoding=devanaagarii

  3. Further, you might want to publish the swagger API documentation (Example https://api.vedavaapi.org/scala/swagger/index.html#/grammarv1analyser/Analyse1 or https://api.vedavaapi.org/py/ullekhanam/docs#!/default/get_book_list ) for your API - just use flask-restplus library.

drdhaval2785 commented 6 years ago

@vvasuki

The flask_restplus application is working locally. I tried running it on apache2 server. It seems that I am missing something. Can you help me in deploying it?

https://github.com/drdhaval2785/prakriya/blob/master/yourapplication.wsgi is the wsgi file https://github.com/drdhaval2785/prakriya/blob/master/dhatu_restplus.py is the restplus app.

drdhaval2785 commented 6 years ago

Regarding point 2, I would leave it to the client side to do the transliteration.

vvasuki commented 6 years ago

What was the problem? log kim avadat?

https://github.com/kmadathil/sanskrit_parser/tree/master/wsgi ityapi pashyatu.

You need to enable wsgi module, and enable the wsgi configuration

drdhaval2785 commented 6 years ago

Point 3 done. It was a problem of not restarting apache after changes in app. Resolved now.

drdhaval2785 commented 6 years ago

http://api.sanskritworld.in/#/default is where the swagger documentation of API is available.

drdhaval2785 commented 6 years ago

Point 1 and 2, I am not so sure whether they are more intuitive. I will wait for user feedback. After swagger documentation, things looks quite simple. Thanks @vvasuki for drawing my attention to flask-restplus and swagger. This is my first python API.

screenshot from 2017-12-16 13-13-14

vvasuki commented 6 years ago

Looks great!

Regarding point 1

Now, I don't know and have to guess what the expected encoding is. should I type gacCati or gachChati or gacCawi etc..? Now, that's where http://api.sanskritworld.in/v0.0.1/tinantas/slp1/jagAma/prakriya?encoding=devanaagarii would make it crystal clear. It tells you the following:

Please note that REST API consumers in general are used to some conventions and best practices, which have been generally accepted for a reason. One should be wary of disregarding it without good reason (in other words, you should by default follow the convention, and expect users to demand that you don't rather than the other way round.)

Regarding point 2.

Regarding the output encoding though, atleast for http://api.sanskritworld.in/v0.0.1/jagAma/prakriya, which you claim is meant to be human readable - you should include the encoding=devanaagarii parameter. As it is, I find myself feeling the following:

Achieving this is quite simple - just use our indic_transliteration module and call sanscript. I can do it for you if you give me write permission here; and if dependencies are clear so that I can test it.

drdhaval2785 commented 6 years ago

New APIs for version 0.0.2. See documentation at https://api.sanskritworld.in/.

Full data API - https://api.sanskritworld.in/v0.0.2/verbforms/slp1/jagAma?output_transliteration=devanagari (Recommended for UI development by @avinashvarna , as it has all possible info.)

prakriya API - https://api.sanskritworld.in/v0.0.2/verbforms/slp1/jagAma/prakriya?output_transliteration=devanagari

Rest two APIs would not be much of interest, as they are subset / modification of the earlier two.

https://api.sanskritworld.in/v0.0.2/verbforms/slp1/jagAma/{argument}?output_transliteration=devanagari See documentation for argument details. https://api.sanskritworld.in/v0.0.2/verbforms/slp1/jagAma/prakriya/machine?output_transliteration=devanagari - returns prakriya in lists.

drdhaval2785 commented 6 years ago

@avinashvarna Please adjust the UI.

You can tweak the output_transliteration parameter with other values and see if the data is returned in proper encoding or not.