The Pejvak API
Everything you can read on Pejvak is also available as JSON. Use it in a program, a spreadsheet or a script. It is free.
What it is
Each address below answers with JSON. You can search phrases, read one phrase with all its verses, list poets and books, and get the numbers of the statistics page. To take the whole archive at once, use the downloads on the open data page.
Limits
These numbers are the settings of the site right now.
- Without a key, for your own reading: 120 requests a minute and 2,000 a day from one address, 20 results a page, 25 pages deep.
- With a free key: 100 requests a minute and 3,000 a day for each key, 20 results a page, 1,000 pages deep. Each person can hold 3 keys.
- When you pass a limit, the answer is a 429 that tells you how many seconds to wait.
Terms
Reading without a key is for personal use: your own reading, or a small tool of your own. A program, site or bot that reads often should use a free key. When you publish what you read, credit Pejvak with a link. The data is open under CC BY-SA 4.0.
Examples
Copy a line into a terminal. The addresses are real. If you have a key, take the lines marked with a key and put yours in place of YOUR_KEY.
With a key
bash (macOS, Linux)
curl -s -H "Authorization: Bearer YOUR_KEY" "https://pejvak.it/api/v1/phrases?q=%D8%AC%D8%A7%D9%86&pageSize=3"
PowerShell (Windows)
Invoke-RestMethod -Headers @{ Authorization = "Bearer YOUR_KEY" } "https://pejvak.it/api/v1/phrases?q=%D8%AC%D8%A7%D9%86&pageSize=3"Search phrases
GET /api/v1/phrases
Phrases that match some words, a tag or a poet, each with a sample verse.
What you can send
q: words of the phrase or of a versetag: a tag as group/name, can be repeatedpoet: the poet's short name in the addresssort: relevance, new, old, az, liked, verses, gentle (gentle to harsh) or harsh (harsh to gentle)page: the page numberpageSize: results a page, up to the limit above
Without a key
bash (macOS, Linux)
curl -s "https://pejvak.it/api/v1/phrases?q=%D8%AC%D8%A7%D9%86&pageSize=3"
PowerShell (Windows)
Invoke-RestMethod "https://pejvak.it/api/v1/phrases?q=%D8%AC%D8%A7%D9%86&pageSize=3"
What comes back
itemsitems[].iditems[].slugitems[].headworditems[].occurrenceCountitems[].poetsitems[].tagsitems[].sampleitems[].sample.occurrenceIditems[].sample.linestotalpagepageSize
One phrase
GET /api/v1/phrases/{slug}
One phrase with every published verse, its meanings, synonyms, antonyms and translations. {slug} is the phrase's short name in the address.
What you can send
Nothing to add.
Without a key
bash (macOS, Linux)
curl -s "https://pejvak.it/api/v1/phrases/%D8%A8%D8%AA"
PowerShell (Windows)
Invoke-RestMethod "https://pejvak.it/api/v1/phrases/%D8%A8%D8%AA"
What comes back
phrase.idphrase.slugphrase.headwordphrase.notephrase.updatedAtvariantsglossesoccurrencesoccurrences[].idoccurrences[].linesoccurrences[].passageIdoccurrences[].poetoccurrences[].tagstagssynonymsantonymsrelatedtranslationsnotes
Poets
GET /api/v1/poets
The poets, with the number of phrases each has.
What you can send
Nothing to add.
Without a key
bash (macOS, Linux)
curl -s "https://pejvak.it/api/v1/poets"
PowerShell (Windows)
Invoke-RestMethod "https://pejvak.it/api/v1/poets"
What comes back
poetspoets[].slugpoets[].nameFapoets[].nameEn
A poet's books
GET /api/v1/works
The books of the poet whose name you give. If there is no such poet, poet is empty.
What you can send
poet: the poet's name, in any spelling
Without a key
bash (macOS, Linux)
curl -s "https://pejvak.it/api/v1/works?poet=%D8%AD%D8%A7%D9%81%D8%B8"
PowerShell (Windows)
Invoke-RestMethod "https://pejvak.it/api/v1/works?poet=%D8%AD%D8%A7%D9%81%D8%B8"
What comes back
poetpoet.slugpoet.nameFaworksworks[].titleworks[].kind
Verses by id
GET /api/v1/verses
The published verses with these ids, in the same order. Up to sixty ids.
What you can send
ids: the ids, separated by commas
Without a key
bash (macOS, Linux)
curl -s "https://pejvak.it/api/v1/verses?ids=cb742fbc-109a-4667-868f-b1fc787fc4de"
PowerShell (Windows)
Invoke-RestMethod "https://pejvak.it/api/v1/verses?ids=cb742fbc-109a-4667-868f-b1fc787fc4de"
What comes back
itemsitems[].occurrenceIditems[].slugitems[].headworditems[].linesitems[].isProseitems[].isFreeVerseitems[].poetSlugitems[].poetFaitems[].poetEn
Statistics
GET /api/v1/stats
The numbers of the statistics page. No person is named and groups under 5 are empty.
What you can send
Nothing to add.
Without a key
bash (macOS, Linux)
curl -s "https://pejvak.it/api/v1/stats"
PowerShell (Windows)
Invoke-RestMethod "https://pejvak.it/api/v1/stats"
What comes back
licensegeneratedAttotalstotals.phrasestotals.versestotals.poetstotals.worksmonthsgrowthgrowth.versesbreakdownsbreakdowns.poetschannelsprivacy.minGroup
Suggestions while typing
GET /api/v1/suggest
Phrases, poets and tags that match half-typed text.
What you can send
q: at least two letterslang: fa or en
Without a key
bash (macOS, Linux)
curl -s "https://pejvak.it/api/v1/suggest?q=%D8%B3%D8%B1%D9%88&lang=en"
PowerShell (Windows)
Invoke-RestMethod "https://pejvak.it/api/v1/suggest?q=%D8%B3%D8%B1%D9%88&lang=en"
What comes back
phrasesphrases[].namephrases[].hrefpoetstags
Is this phrase here?
GET /api/v1/phrases/check
Asks whether a phrase is already in the archive: the same phrase, the same letters in another order, or close phrases.
What you can send
q: the phrase
Without a key
bash (macOS, Linux)
curl -s "https://pejvak.it/api/v1/phrases/check?q=%D8%B3%D8%B1%D9%88%20%D8%B1%D9%88%D8%A7%D9%86"
PowerShell (Windows)
Invoke-RestMethod "https://pejvak.it/api/v1/phrases/check?q=%D8%B3%D8%B1%D9%88%20%D8%B1%D9%88%D8%A7%D9%86"
What comes back
exactreorderedsimilar
Try it
Send a request from here. It goes without a key, so it counts against the limits for readers without one.