fawazahmed0/hadith-api

Add chapter names within the books.

Opened this issue · 3 comments

For example - https://sunnah.com/tirmidhi/1

You can see various chapter names like

(1) Chapter: What Has Been Related That Salat Is Not Accepted Without Purification
(2) Chapter: What Has Been Related About The Virtue Of Purification

etc.

I can work on this but first need to finalize the json structure.

{
	"metadata": {
		"name": "Jami At Tirmidhi",
		"section": {
			"1": "The Book on Purification"
		},

	},
	"hadiths": [
		{
			"hadithnumber": 1,
			"arabicnumber": 1,
			"text": ".........................",
			"grades":[....................],
			"reference": {
				"book": 1,
				"hadith": 1
			}
		}
	]
}

I recommend adding a sub json within the "hadiths" json

"chapter": {
    "id": 1,
    "isFirstHadithOfChapter": true,
    "eng-name": "Chapter: What Has Been Related That Salat Is Not Accepted Without Purification",
    "ara-name": " باب مَا جَاءَ لاَ تُقْبَلُ صَلاَةٌ بِغَيْرِ طُهُورٍ ‏ "
    }

The effective json will look like :

{
	"metadata": {
		"name": "Jami At Tirmidhi",
		"section": {
			"1": "The Book on Purification"
		},

	},
	"hadiths": [
		{
			"hadithnumber": 1,
			"arabicnumber": 1,
                        "chapter": {
                                "id": 1,
                                "isFirstHadithOfChapter": true,
                                "eng-name": "Chapter: What Has Been Related That Salat Is Not Accepted Without Purification",
                                "ara-name": " باب مَا جَاءَ لاَ تُقْبَلُ صَلاَةٌ بِغَيْرِ طُهُورٍ ‏ "
                        }
			"text": ".........................",
			"grades":[....................],
			"reference": {
				"book": 1,
				"hadith": 1
			}
		}
	]
}

Let me know if you are ok with this design. I can start working on this.

Brother, I will take up all these issues & complete it later, as this is related to structure change.
(because once I add something in api, I will not be able to remove it, otherwise it will break things for others)

Well, I need it for my website. I have already created a few such additions in my fork of your repo so I will continue making those changes.

https://github.com/GibreelAbdullah/hadith-api/tree/2/updates

You may have a look and see if you want to adopt any of those in your repo whenever you are redesigning your api.