api icon indicating copy to clipboard operation
api copied to clipboard

Request for API access: [Your Name]

Open IlmiKitaabi opened this issue 2 years ago • 0 comments
trafficstars

  • Please tell us about yourself (include an email address): Muhammad Abdullah , [email protected]

  • Your purpose in using this API: I am creating a python program from where we choose ahadees book from top 10 books and search for hadees number overall not chapter wise in under one program, i will then create same app for mobile for personel use. I am Engineer Muhammad Ali Student and want to cross verify ahadees from different books easily without going to websites where it's difficult to search for ahadees universal number because they are chapterized so ahadees number does not match.

  • API rate limits:

    • Maximum requests per second: 0.001157 considering 100 requests per day
    • Maximum requests per day: <100
  • Is your use case better served by having an offline dump of hadith data or programmatic API access?

  • What are the languages in which would you like hadith data? urdu only, i am not interested in arabic (dont include arabic unless you have no other choice)

  • What programming language will your API client be in? python

  • My Code

import requests

def get_hadith(book, hadith_number): base_url = "https://api.sunnah.com/v1/hadiths" headers = { "X-API-KEY": "YOUR_API_KEY" # Get your API key from Sunnah.com }

params = {
    "book": book,
    "hadith_number": hadith_number
}

response = requests.get(base_url, headers=headers, params=params)

if response.status_code == 200:
    hadith_data = response.json()
    print(f"Book: {hadith_data['book']['name']}")
    print(f"Hadith Number: {hadith_data['hadith_number']}")
    print(f"Hadith Text: {hadith_data['hadith_text']}")
else:
    print("Hadith not found")

Example usage

book_name = "sahihbukhari" hadith_number = 1

get_hadith(book_name, hadith_number)

IlmiKitaabi avatar Oct 15 '23 12:10 IlmiKitaabi