📚 Daf PDF Viewer API Documentation

This API provides access to Gemara Tzuras Hadaf PDF files. Request a specific masechta (tractate) and daf (page) to receive the corresponding PDF.

🔗 Base URL

https://www.shas.org/daf-pdf/api/

📋 Endpoints

GET /

Retrieve a specific daf from a masechta as a PDF file.

📝 Request Parameters

Parameter Type Required Description
masechta string Required Name of the masechta (see list below)
daf integer Required Daf number (starts from 2)
amud string Optional Side of the daf: a (default), b, aleph, bet, 1, or 2
format string Optional Set to json to get metadata instead of the PDF file

📖 Available Masechtot

Use these exact masechta names in your API requests (case-insensitive):

Note: Some masechtot end on amud 'a' rather than 'b'. Attempting to access a non-existent amud 'b' will return an error.

berachos (2a - 64a)
shabbos (2a - 157b)
eruvin (2a - 105a)
pesachim (2a - 121b)
shekalim (2a - 22b)
yoma (2a - 88a)
sukkah (2a - 56b)
beitzah (2a - 40b)
rosh-hashanah (2a - 35a)
taanis (2a - 31a)
megillah (2a - 32a)
moed-katan (2a - 29a)
chagigah (2a - 27a)
yevamos (2a - 122a)
kesubos (2a - 112b)
nedarim (2a - 91b)
nazir (2a - 66b)
sotah (2a - 49b)
gittin (2a - 90b)
kiddushin (2a - 82b)
bava-kamma (2a - 119b)
bava-metzia (2a - 119a)
bava-basra (2a - 176b)
sanhedrin (2a - 113b)
makkos (2a - 24b)
shevuos (2a - 49b)
avodah-zarah (2a - 76b)
horayos (2a - 14a)
zevachim (2a - 120b)
menachos (2a - 110a)
chullin (2a - 142a)
bechoros (2a - 61a)
arachin (2a - 34a)
temurah (2a - 34a)
kereisos (2a - 28b)
meilah (2a - 37b) - Includes Kinim, Tamid, and Middos
niddah (2a - 73a)
Use meilah, kinim, tamid, or middos as aliases to access:
• Me'ilah proper: 2a-22a
• Kinim: 22b-25a
• Tamid: 25b-33b
• Middos: 34a-37b

✅ Examples

Example 1: Get Berachos 2a as PDF

GET /?masechta=berachos&daf=2

Response: application/pdf

Returns the PDF file for Berachos daf 2, amud aleph.

Example 2: Get Shabbos 5b as PDF

GET /?masechta=shabbos&daf=5&amud=b

Response: application/pdf

Returns the PDF file for Shabbos daf 5, amud bet.

Example 3: Get metadata as JSON

GET /?masechta=bava-metzia&daf=10&amud=a&format=json

Response: application/json

{
  "success": true,
  "masechta": "Bava Metzia",
  "daf": 10,
  "amud": "a",
  "page_number": 3043,
  "pdf_url": "3043.pdf",
  "file_size": 1234567
}

❌ Error Responses

Missing Parameters

Status Code: 400 Bad Request

{
  "error": "Missing masechta parameter",
  "message": "Please provide a masechta name (e.g., ?masechta=berachos&daf=2)"
}

Invalid Masechta

Status Code: 404 Not Found

{
  "error": "Invalid masechta",
  "message": "Masechta 'invalid' not found",
  "available_masechtot": ["berachos", "shabbos", ...]
}

Daf Out of Range

Status Code: 400 Bad Request

{
  "error": "Daf out of range",
  "message": "Masechta Berachos only has 64 dapim",
  "max_daf": 64
}

Amud Does Not Exist

Status Code: 400 Bad Request

{
  "error": "Amud does not exist",
  "message": "Masechta Berachos ends at daf 64a (amud aleph only)",
  "last_daf": 64,
  "last_amud": "a"
}

PDF Not Found

Status Code: 404 Not Found

{
  "error": "PDF not found",
  "message": "PDF file for page 1234 does not exist",
  "requested": {
    "masechta": "Berachos",
    "daf": 10,
    "amud": "a",
    "page_number": 1234
  }
}

💡 Usage Tips

🔧 Integration Example (JavaScript)

// Fetch and display a PDF
function loadDaf(masechta, daf, amud = 'a') {
    const url = `https://www.shas.org/daf-pdf/api/?masechta=${masechta}&daf=${daf}&amud=${amud}`;
    
    // Display PDF in iframe
    document.getElementById('pdf-viewer').src = url;
    
    // Or get metadata
    fetch(`${url}&format=json`)
        .then(response => response.json())
        .then(data => {
            console.log('Loaded:', data.masechta, data.daf, data.amud);
        });
}

// Example usage
loadDaf('berachos', 2, 'a');