Files
m3o-go/examples/quran/README.md
2022-02-16 21:45:47 +00:00

123 lines
2.0 KiB
Markdown
Executable File

# Quran
An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/quran/api](https://m3o.com/quran/api).
Endpoints:
## Summary
Get a summary for a given chapter (surah)
[https://m3o.com/quran/api#Summary](https://m3o.com/quran/api#Summary)
```go
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](https://m3o.com/quran/api#Verses)
```go
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
Search the Quran for any form of query or questions
[https://m3o.com/quran/api#Search](https://m3o.com/quran/api#Search)
```go
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)
}
```
## Chapters
List the Chapters (surahs) of the Quran
[https://m3o.com/quran/api#Chapters](https://m3o.com/quran/api#Chapters)
```go
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)
}
```