quranacademy / digital-quran-docs

Documentation for Quran Academy data distribution project: Digital Quran - https://quranacademy.gitbook.io/digital-quran/
39 stars 8 forks source link

why not follow standard restful API convention? #6

Closed thg303 closed 5 years ago

thg303 commented 5 years ago
Imangazaliev commented 5 years ago

I’ve been thinking about it so far and currenly I want to change the request method to GET for all endpoints that return data and do not perform any actions (like in REST).

The reason for using the POST method was the desire to use JSON to pass parameters, because it allows to preserve parameter types for numeric and boolean values, in contrast to URL-encoded.

thg303 commented 5 years ago

well, I don't know what kind of language do you want to use to parse the requests, but it shouldn't matter. Most nowadays languages (frameworks) can cast variables and convert them to a hashtable or similar structures. btw, API should make sense. since it's a communication mechanism for anybody who likes to use the service. I believe it's not a good idea to break general conventions just to make internal code easier to write or maintain.

Skillz4Killz commented 5 years ago

I think both sides have a valid point but a slight misunderstanding of the final goal of the API. From what I can imagine, an end user of the API such as myself would only ever need the GET to be able to get data from the API. The API's only purpose is to provide easy access to data. It is not meant to allow me to modify the API so any POST, PUT, PATCH are unnecessary for me entirely. These methods should be reserved for internal use for example using the POST to upload a new translation.

Also if the API has not been built yet, might I suggest GraphQL.

Imangazaliev commented 5 years ago

I don't know what kind of language do you want to use to parse the requests

We are using PHP and Laravel :)

I believe it's not a good idea to break general conventions just to make internal code easier to write or maintain.

Sure. The main goal is not to make the code easier but just so that parameter types are passed unambiguously.

So, as I said, we will change the method to GET, in shaa Allah.

Imangazaliev commented 5 years ago

might I suggest GraphQL

I think this overcomplication, because we don't have so complex queries. To use the current API you need just make an HTTP-request, that the most developers can do, but in case with GraphQL you have to learn what's it, use libraries and so on.

Imangazaliev commented 5 years ago

@thg303 can we close this pull request?

thg303 commented 5 years ago

So, as I said, we will change the method to GET, in shaa Allah.

It's up to you bro ;-)

Imangazaliev commented 5 years ago

@thg303 done

thg303 commented 5 years ago

thank you @Imangazaliev