Keeping in sync
Jobs open and close every day. Keep your copy current so your users never apply to a job that has closed.
How often
Run a full sync at least once a day. Every 1 to 4 hours is better, and well inside the limits. There’s no need to sync more than once an hour: we cache the XML feed for 10 minutes and most jobs change far less often.
A full sync
- Walk the feed from the start, following
next_cursoruntil it’snull. - Collect every job you receive.
- When the walk finishes, replace your stored jobs with the new set. Jobs you no longer received have closed: remove them.
Jobs come in a fixed order, by id, so a walk is stable while jobs are added.
If a sync fails part way, keep your last full copy. Don’t delete jobs because a walk stopped early; try again later.
Checking one job
To check a single job between syncs:
curl -H "Authorization: Bearer $MUSLIMJOBS_KEY" \
"https://www.muslimjobs.io/api/partner/v1/jobs/JOB_ID"A live job returns 200. A job that has closed returns 410 job_ended: remove it. An id we don’t know returns 404.
Logos
company.logo_url points to a PNG on MuslimJobs, at most 256 pixels square. Fetch each logo once and keep your own copy; logos rarely change. On your first sync, fetch them gently, a few at a time, rather than all at once. Companies without a logo have logo_url: null; show their initials or a placeholder.
Node.js example
const BASE = 'https://www.muslimjobs.io/api/partner/v1/jobs';
const headers = { Authorization: `Bearer ${process.env.MUSLIMJOBS_KEY}` };
async function fetchAllJobs() {
const jobs = [];
let cursor = null;
do {
const url = new URL(BASE);
url.searchParams.set('limit', '100');
if (cursor) url.searchParams.set('cursor', cursor);
const response = await fetch(url, { headers });
if (!response.ok) throw new Error(`Feed returned ${response.status}`);
const page = await response.json();
jobs.push(...page.data);
cursor = page.next_cursor;
} while (cursor);
return jobs;
}
async function sync(store) {
const jobs = await fetchAllJobs();
// Only replace the stored jobs once the whole walk has worked
await store.replaceAll(jobs);
}Python example
import os
import requests
BASE = "https://www.muslimjobs.io/api/partner/v1/jobs"
HEADERS = {"Authorization": f"Bearer {os.environ['MUSLIMJOBS_KEY']}"}
def fetch_all_jobs():
jobs, cursor = [], None
while True:
params = {"limit": 100}
if cursor:
params["cursor"] = cursor
response = requests.get(BASE, headers=HEADERS, params=params, timeout=30)
response.raise_for_status()
page = response.json()
jobs.extend(page["data"])
cursor = page["next_cursor"]
if not cursor:
return jobs
def sync(store):
jobs = fetch_all_jobs()
# Only replace the stored jobs once the whole walk has worked
store.replace_all(jobs)When something goes wrong
429 rate_limited: wait for the number of seconds in theRetry-Afterheader, then carry on.401 invalid_key: the key is wrong or has been revoked. Check your secrets.403 partner_paused: your access is paused. Keep your stored jobs but stop showing them until we’ve been in touch.- Any
5xx: try again later, and keep your last full copy meanwhile.