Code Examples
Code Examples
Code Examples
Choose an example
Login and authentication
Logging in to the API (JavaScript)
// התחברות ל-API וקבלת טוקן
// הטוקן תקף ל-24 שעות מאז הפעולה האחרונה
// שימו לב: אם נרשמתם דרך Google - יש להגדיר קודם סיסמה לחשבון
// (תפריט המשתמש > "לאזור האישי" > בדף הפרופיל: "הגדר / שנה סיסמה")
const API_BASE = 'https://api.itimlabina.co.il/v1';
let token = null;
async function login() {
const response = await fetch(`${API_BASE}/user/login`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
mail: '[email protected]',
password: 'yourpassword'
})
});
const data = await response.json();
token = data.token;
console.log('Token received:', token);
return token;
}
login();Logging in to the API (Python)
import requests
API_BASE = 'https://api.itimlabina.co.il/v1'
# התחברות וקבלת טוקן
response = requests.post(f'{API_BASE}/user/login', json={
'mail': '[email protected]',
'password': 'yourpassword'
})
token = response.json()['token']
print(f'Token: {token}')Logging in to the API (cURL)
curl -X POST https://api.itimlabina.co.il/v1/user/login \
-H "Content-Type: application/json" \
-d '{"mail":"[email protected]","password":"yourpassword"}'Getting lists (no authentication)
Getting the list of Itim LaBina zmanim
fetch('https://api.itimlabina.co.il/v1/zmanim/list/groups')
.then(response => response.json())
.then(data => console.log('Zmanim Groups:', data))
.catch(error => console.error('Error:', error));Getting the list of raw zmanim
fetch('https://api.itimlabina.co.il/v1/zmanim/list/basic')
.then(response => response.json())
.then(data => console.log('Basic Zmanim:', data))
.catch(error => console.error('Error:', error));Getting the list of Itim LaBina cities (locations)
// קבלת רשימת כל ערי עתים לבינה
// בקשה זו אינה דורשת אימות
fetch('https://api.itimlabina.co.il/v1/locations')
.then(response => response.json())
.then(locations => {
console.log(`נמצאו ${locations.length} ערים`);
// דוגמה: מציאת עיר לפי שם
const jerusalem = locations.find(loc => loc.name.includes('ירושלים'));
if (jerusalem) {
console.log(`ירושלים - מזהה: ${jerusalem.id}`);
console.log(`קואורדינטות: ${jerusalem.defaultLat}, ${jerusalem.defaultLng}`);
console.log(`גובה: ${jerusalem.defaultEl} מטר`);
}
});Getting details of specific zmanim by IDs
// קבלת פרטים על זמנים ספציפיים לפי מזהים
// שימושי כדי לקבל שמות ותיאורים של זמנים שכבר יש לך את ה-ID שלהם
const zmanIds = '1,5,12'; // מזהים מופרדים בפסיקים
fetch(`https://api.itimlabina.co.il/v1/zmanim/list/${zmanIds}`)
.then(response => response.json())
.then(data => console.log('Zmanim details:', data));Calculating zmanim - by list of zmanim
Requesting zmanim by location ID
const locationId = 123;
const year = 2026;
const month = 3;
const day = 30;
const token = 'YOUR_TOKEN_HERE';
const times = '1,5,12'; // מזהי הזמנים הרצויים
const url = `https://api.itimlabina.co.il/v1/zmanim/times/location/id/${locationId}/${year}/${month}/${day}?token=${token}×=${times}`;
fetch(url)
.then(response => response.json())
.then(data => console.log('Zmanim:', data))
.catch(error => console.error('Error:', error));Requesting zmanim by address
const year = 2026;
const month = 3;
const day = 30;
const token = 'YOUR_TOKEN_HERE';
const address = 'תל_אביב';
const times = '1,5,12';
const url = `https://api.itimlabina.co.il/v1/zmanim/times/address/${address}/${year}/${month}/${day}?token=${token}×=${times}`;
fetch(url)
.then(response => response.json())
.then(data => console.log('Zmanim:', data))
.catch(error => console.error('Error:', error));Requesting zmanim by coordinates
// בקשת זמנים לפי קואורדינטות (קו רוחב, קו אורך)
// מתאים למיקומים שאינם ברשימת ערי עתים לבינה
const lat = 31.7683; // קו רוחב - ירושלים
const lng = 35.2137; // קו אורך
const times = '1,5,12'; // רשימת מזהי הזמנים הרצויים
const token = 'YOUR_TOKEN_HERE';
const url = `https://api.itimlabina.co.il/v1/zmanim/times/coordinates/${lat},${lng}/2026/3/30?token=${token}×=${times}`;
fetch(url)
.then(response => response.json())
.then(data => console.log('Zmanim:', data));Calculating zmanim - by table
Requesting zmanim by table and location ID (the way to get zmanim like the printed calendar)
// בקשת זמנים לפי טבלה - הדרך הפשוטה ביותר
// אין צורך לציין אילו זמנים לבקש - הטבלה כוללת את כולם
// טבלה 251 = הטבלה המרכזית של עתים לבינה המודפס
const viewId = 251; // מזהה הטבלה המרכזית של עתים לבינה
const locationId = 1; // מזהה העיר (מתוך רשימת ערי עתים לבינה)
const token = 'YOUR_TOKEN_HERE';
const url = `https://api.itimlabina.co.il/v1/zmanim/table/${viewId}/location/id/${locationId}/2026/3/30?token=${token}`;
fetch(url)
.then(response => response.json())
.then(data => {
// שימו לב: מספר הזמנים עשוי להשתנות בין ימים
// (למשל, הדלקת נרות מופיעה רק ביום שישי)
data.dates.forEach(day => {
console.log(`${day.date}: ${day.times.length} זמנים`);
day.times.forEach(t => {
console.log(` ${t.zman}: ${t.formattedTime}`);
});
});
});Requesting zmanim by table and address
// בקשת זמנים לפי טבלה וכתובת
const viewId = 251; // הטבלה המרכזית של עתים לבינה
const address = 'בני ברק';
const token = 'YOUR_TOKEN_HERE';
const url = `https://api.itimlabina.co.il/v1/zmanim/table/${viewId}/address/${address}/2026/3/30?token=${token}`;
fetch(url)
.then(response => response.json())
.then(data => console.log('Zmanim:', data));Date ranges
Getting zmanim for a whole week
// קבלת זמנים לשבוע שלם בבקשה אחת
const viewId = 251;
const locationId = 1;
const token = 'YOUR_TOKEN_HERE';
// range=week - שבוע מתאריך ההתחלה
const url = `https://api.itimlabina.co.il/v1/zmanim/table/${viewId}/location/id/${locationId}/2026/3/30?token=${token}&range=week`;
fetch(url)
.then(response => response.json())
.then(data => {
console.log(`התקבלו ${data.dates.length} ימים`);
console.log(`מ: ${data.request.startDate}`);
console.log(`עד: ${data.request.endDate}`);
data.dates.forEach(day => {
console.log(`\n${day.date}:`);
day.times.forEach(t => {
console.log(` ${t.zman}: ${t.formattedTime}`);
});
});
});Getting zmanim by number of days or end date
// קבלת זמנים ל-14 ימים
const viewId = 251;
const locationId = 1;
const token = 'YOUR_TOKEN_HERE';
// לפי מספר ימים
const url1 = `https://api.itimlabina.co.il/v1/zmanim/table/${viewId}/location/id/${locationId}/2026/3/30?token=${token}&range=14`;
// לפי תאריך סיום
const url2 = `https://api.itimlabina.co.il/v1/zmanim/table/${viewId}/location/id/${locationId}/2026/3/30?token=${token}&range=2026-04-12`;
fetch(url1)
.then(response => response.json())
.then(data => console.log(`התקבלו ${data.dates.length} ימים`));Full workflow and error handling
Full flow: log in, choose zmanim and location, and request data
const API_BASE = 'https://api.itimlabina.co.il/v1';
let token = null;
// שלב 1: התחברות
async function login(email, password) {
const res = await fetch(`${API_BASE}/user/login`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ mail: email, password })
});
if (!res.ok) throw new Error('Login failed');
const data = await res.json();
token = data.token;
return token;
}
// שלב 2: בקשת זמנים עם טיפול בשגיאות וחידוש טוקן אוטומטי
async function getZmanim(url) {
let res = await fetch(url);
// אם הטוקן פג תוקף - מתחבר מחדש ומנסה שוב
if (res.status === 401) {
const error = await res.json();
if (error.code === 'TOKEN_EXPIRED') {
console.log('Token expired, reconnecting...');
await login('[email protected]', 'yourpassword');
url = url.replace(/token=[^&]+/, `token=${token}`);
res = await fetch(url);
}
}
if (!res.ok) {
const error = await res.json();
throw new Error(`API Error ${res.status}: ${error.code || error.message}`);
}
return res.json();
}
// שלב 3: דוגמה לשימוש מלא
async function main() {
try {
// התחברות
await login('[email protected]', 'yourpassword');
// בקשת זמנים לירושלים לשבוע הקרוב
// טבלה 251 = הטבלה המרכזית של עתים לבינה המודפס
const viewId = 251;
const locationId = 1;
const url = `${API_BASE}/zmanim/table/${viewId}/location/id/${locationId}/2026/3/30?token=${token}&range=week`;
const data = await getZmanim(url);
// הצגת התוצאות
console.log(`אזור זמן: ${data.timeZone}`);
for (const day of data.dates) {
console.log(`\n${new Date(day.date).toLocaleDateString('he-IL')}:`);
for (const t of day.times) {
console.log(` ${t.zman}: ${t.formattedTime || '---'}`);
}
}
} catch (error) {
console.error('Error:', error.message);
}
}
main();