A simple java wrapper library for alquran-cloud api

Anas f23db8e2eb Merge pull request #37 from 0x61nas/snyk-upgrade-9542669b431409712b9f0615aac0c398 5 months ago
.github 0d1012462c chore(deps): update advanced-security/maven-dependency-submission-action digest to 645590b 6 months ago
.idea 5076a06fc2 Update jackson 1 year ago
.m2 053c393620 Fix my user name 😅 1 year ago
Screenshots 8bfca74d56 [ImgBot] Optimize images 1 year ago
src 3c913b43aa Create getAyah function 🥰 1 year ago
.editorconfig d3dd12b9da Create the editor configs 1 year ago
.gitignore 154ac53688 Add eclips settings file to the ignored files 1 year ago
.mergify.yml b643e4a790 ci(Mergify): configuration update 1 year ago
CODE_OF_CONDUCT.md 7b1632344d Create CODE_OF_CONDUCT.md 1 year ago
CONTRIBUTING.md 4a4c465cdf Remove line 1 year ago
LICENSE.txt 2f17f3f059 Create the license 🖤 1 year ago
README.md 09d77657b5 [doc] Update the verison in the examples 11 months ago
pom.xml 8c6c4540b6 fix: upgrade com.fasterxml.jackson.core:jackson-databind from 2.15.3 to 2.16.0 5 months ago
renovate.json 4104be013e Add renovate.json 1 year ago

README.md

A simple java wrapper library for alquran-cloud api 🤍

JitPack badge Lines of Code Code Smells Quality Gate Status Reliability Rating Vulnerabilities Bugs

It is still under development. 🚧

How to add this library into your project

Maven

Step 1. Add the JitPack repository to your build file


<repositories>
	<repository>
		<id>jitpack.io</id>
		<url>https://jitpack.io</url>
	</repository>
</repositories>

Step 2. Add the dependency

<dependency>
	<groupId>com.github.anas-elgarhy</groupId>
	<artifactId>alquran-cloud-api</artifactId>
	<version>0.4.4</version>
</dependency>

Gradle:

Step 1. Add the JitPack repository to your build file
Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Step 2. Add the dependency

	dependencies {
	        implementation 'com.github.anas-elgarhy:alquran-cloud-api:0.4.4'
	}

Usage

public class Example1 {
    public static void main(String[] args) throws IOException {
        Ayah ayah = Ayah.getAyah(1); // Get the first ayah in the quaran in arabic edition
        System.out.println(ayah.getText());
        System.out.println("***");

        System.out.println("----- آية عشوائية -----");
        Ayah randomAyah = Ayah.getRandomAyah(); // Get a random ayah in the quaran in arabic edition
        Surah surah = randomAyah.getSurah(); // Get the surah of the random ayah
        System.out.println(randomAyah.getText() + " - من " + surah.getName());
        System.out.println("***");

        Surah surah2 = Surah.getSurah(1); // Get the first surah in the quaran in arabic edition
        System.out.println(surah2.getName());
        System.out.println("الآيات: ");
        for (Ayah a : surah2.getAyahs()) {
            System.out.println(a.getText() + " (" + a.getNumberInSurah() + ")");
        }
    }
}

Example one output

public class Example2 {
    public static void main(String[] args) throws IOException {
        Edition[] editions = Edition.getEditions(); // Get all available editions
        System.out.println("The number of available editions: " + editions.length);

        System.out.println("Editions: ");

        for (Edition edition : editions) {
            System.out.println(edition.getName() + " (" + edition.getIdentifier() + ")" +
                    " - Edition type: " + edition.getFormat().toString());
        }
    }
}

Example two output

public class Example3 {
    public static void main(String[] args) throws IOException {
        // Get th all available editions in specific language
        Edition[] editionsInEnglish = Edition.getEditions("en");
        System.out.println("The number of available editions in English: " + editionsInEnglish.length);


        // Get th all available editions in specific language and format (audio or text) and type (quran or translation, etc)
        // null means all
        Edition[] editionsInEnglishAudio = Edition.getEditions(EditionFormat.AUDIO, "en", null);
        System.out.println("The number of available editions in English audio: " + editionsInEnglishAudio.length);

        Ayah ayah = Edition.getAyah(1, editionsInEnglishAudio[0]); // Get the first ayah in the quaran in specific edition
        // Becose the audio editions also have the text editions insiw, and usually the text editions are arabic.
        System.out.println(ayah.getText());
        System.out.println(ayah.getAudioUrl()); // Get the audio url of the ayah in 192 kbps.
        // Get the audio urls in other bitrates, returns same url if no other bitrates.
        System.out.println(Arrays.toString(ayah.getSecondaryAudioUrls()));

        Edition edition = editionsInEnglish[0];
        System.out.println(edition.getName());
        System.out.println(edition.getType());
        System.out.println(edition.getFormat());

        Ayah ayahFromEdition = Ayah.getAyah(1, edition); // Get the first ayah in the quaran in specific edition
        System.out.println(ayahFromEdition.getText());

        // Get the first surah in the quaran in specific edition
        Surah fistSurah = Surah.getSurah(1, edition);
        System.out.println(fistSurah.getName());

        // Or you can use the Surah enum to get the surah:
        Surah s = Surah.getSurah(Surahs.AL_ALAQ);
        System.out.println(s.getName());
    }
}

Example three output

Requirements for development:

  • Maven
  • jdk 17
  • IntelliJ IDEA (not required but recommended)

Available in

GitHub GitLab BitBucket Codeberg

Quality gate

SonarCloud