sunnah-com / api

API for sunnah.com
https://sunnah.com
325 stars 62 forks source link

Should API return pure data? #116

Open Abdur-rahmaanJ opened 3 years ago

Abdur-rahmaanJ commented 3 years ago

Aslm,

saw that on this query: https://api.sunnah.com/v1/collections/bukhari/books/1/chapters?limit=50&page=1 you receive among the response:

    {
          "lang": "ar",
          "chapterNumber": "1",
          "chapterTitle": "باب كَيْفَ كَانَ بَدْءُ الْوَحْىِ إِلَى رَسُولِ اللَّهِ صلى الله عليه وسلم",
          "intro": "<p>وَقَوْلُ اللَّهِ جَلَّ ذِكْرُهُ: {إِنَّا أَوْحَيْنَا إِلَيْكَ كَمَا أَوْحَيْنَا إِلَى نُوحٍ وَالنَّبِيِّينَ مِنْ بَعْدِهِ}</p>",
          "ending": null
        }

for the intro part, should api not return html-less data? What if someone is using the API for a commandline application? He won't need HTML. Or what if the user expects only the text and the <p> messes with his UI?

ahadith commented 3 years ago

Wa`alaykum ussalam warahmatullah

Thank you for your message. For the hadith text field, I believe we have separate HTML and text-only fields. We may have neglected to do this for chapters.

@hasankhan Can we strip HTML tags from the returned chapter title and intro field? Or have HTML and non-HTML versions? Sometimes those fields contain hyperlinks to Qur'anic ayat.

Abdur-rahmaanJ commented 3 years ago

Jzkl for addressing issue!

hasankhan commented 3 years ago

@ahadith yes we can. I'll take a look insha'Allah