Git Product home page Git Product logo

Comments (3)

meezaan avatar meezaan commented on August 26, 2024

Salaam brother.

The Adhan audio and backgrounds aren't semantically arranged to return via an API, per se. If you can explain your use case we can always looking at doing it if it is useful or helpful.

But all of this is already available over HTTP via the AlAdhan CDN, which is a simple git repo. See https://github.com/islamic-network/cdn.aladhan.com/tree/master/html/images/backgrounds and https://github.com/islamic-network/cdn.aladhan.com/tree/master/html/audio/adhans.

Does this help?

from api.aladhan.com.

AlGantori avatar AlGantori commented on August 26, 2024

This is a good start is there. Thanks for sharing I missed to look into cdn.aladhan.com I will browse at what's available there shortly.

  • I am building my own view of the Timings and wanted to leverage the available audio and backgrounds like I leverage the API instead of building my own.

  • Is there a related JSON of these resources (background, audio) that's kept in sync with the files on the CDN? or should I for now just assume there are sequentially named and build my own JSON array for them?
    Thank you for helping out.

To be more concrete here is a sample of JSON I would think would be useful:

{
	"Adhans": [ {
		"URL": "https://cdn.aladhan.com/audio/adhans/a4.mp3",
		"Author": "AlAfasi"
	},
        {...} ]
}

like wise for the images....

{
	"Backgrounds": [ {
		"URL": "https://cdn.aladhan.com/images/backgrounds/3.jpg",
		"Location": "Lahore, Pakistan",
                "Description": "Famous palace, Mosque"
	},
        {...} ]
}
  • I am programming with TypeScript under Ionic/Angular frameworks. Perhaps this is trivial for you, but in my case I had to convert the timings into an array of objects in order to iterate over it using Angular html binding. Angular will not iterated over object keys. Perhaps it's not an issue in JS? or you may have directly referenced each time by its key for example timings.Fajr, to achieve the layout for all? I guess what I am trying to say is that you may want to consider presenting your API JSON with some arrays where it makes sense.

image
Here is the html
image

from api.aladhan.com.

meezaan avatar meezaan commented on August 26, 2024

The images are numeric values, so an array is not needed, at least not in the current state. See https://github.com/islamic-network/aladhan.com/blob/master/html/js/app.js#L8. Also, I actually don't know where all the locations are - most of them, yes, but not all, so a list might not be entirely accurate. Instead of an API, it might just be right to add a file in the images folder called images.json which contains this - and it will also be accessible over the CDN. You can make a start and raise a PR on the cdn.aladhan.com repo if this is something you need urgently.

As far as the timings response is concerned, it is an object on purpose. The order of that object might change any time, and I may add an additional field to it - if it was an array and clients looped around it to build their UI, their UI would break if we added an additional field or change the order.

I would, therefore, not loop through it.

Also, an array would be semantically incorrect, unless the response format was changed to something similar:

data: {
  timings: [
    {
      "name": "Fajr",
      "time": "04:28"
    },
    {
      "name": "Sunrise",
      "time": "05:37"
    },
    {
      "name": "Dhuhr",
      "time": "12:15"
    },
    ...
  ],
...
}

Aside from fitting a UI that wants to loop through timings, this design serves no purpose and simply increases the size of the payload - and it makes a particular object direct inaccessible.

from api.aladhan.com.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.