Files
m3o-go/examples/quran/README.md
2022-03-01 15:48:51 +00:00

2.0 KiB
Executable File

Quran

An m3o.com API. For example usage see m3o.com/quran/api.

Endpoints:

Chapters

List the Chapters (surahs) of the Quran

https://m3o.com/quran/api#Chapters

package example

import(
	"fmt"
	"os"

	"go.m3o.com/quran"
)

// List the Chapters (surahs) of the Quran
func ListChapters() {
	quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN"))
	rsp, err := quranService.Chapters(&quran.ChaptersRequest{
		Language: "en",

	})
	fmt.Println(rsp, err)
	
}

Summary

Get a summary for a given chapter (surah)

https://m3o.com/quran/api#Summary

package example

import(
	"fmt"
	"os"

	"go.m3o.com/quran"
)

// Get a summary for a given chapter (surah)
func GetChapterSummary() {
	quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN"))
	rsp, err := quranService.Summary(&quran.SummaryRequest{
		Chapter: 1,

	})
	fmt.Println(rsp, err)
	
}

Verses

Lookup the verses (ayahs) for a chapter including translation, interpretation and breakdown by individual words.

https://m3o.com/quran/api#Verses

package example

import(
	"fmt"
	"os"

	"go.m3o.com/quran"
)

// Lookup the verses (ayahs) for a chapter including
// translation, interpretation and breakdown by individual
// words.
func GetVersesOfAchapter() {
	quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN"))
	rsp, err := quranService.Verses(&quran.VersesRequest{
		Chapter: 1,

	})
	fmt.Println(rsp, err)
	
}

Search the Quran for any form of query or questions

https://m3o.com/quran/api#Search

package example

import(
	"fmt"
	"os"

	"go.m3o.com/quran"
)

// Search the Quran for any form of query or questions
func SearchTheQuran() {
	quranService := quran.NewQuranService(os.Getenv("M3O_API_TOKEN"))
	rsp, err := quranService.Search(&quran.SearchRequest{
		Query: "messenger",

	})
	fmt.Println(rsp, err)
	
}