FindMy.py icon indicating copy to clipboard operation
FindMy.py copied to clipboard

Get reports between dates

Open webfrank opened this issue 1 year ago • 1 comments

Hi, I cannot query for reports between two dates as always get last seven days.

This is my code:

    key = request.args.get('key')
    t0 = datetime.datetime.fromtimestamp(float(request.args.get('t0'))/1000.0)
    t1 = datetime.datetime.fromtimestamp(float(request.args.get('t1'))/1000.0)

    priv_key = KeyPair.from_b64(key)

    # It's that simple!
    reports = acc.fetch_reports(keys=priv_key, date_from=t0, date_to=t1)

    reports.sort(reverse=True, key=lambda e: e.timestamp)

    return [{
        "timestamp": report.timestamp, 
        "latitude": report.latitude, 
        "longitude": report.longitude
    } for report in reports]

t0 and t1 are timestamps in milliseconds, whatever I set I always got last seven days.

webfrank avatar Nov 10 '24 11:11 webfrank

This is actually a bug on Apple's side; the library correctly requests reports between those two timestamps, but Apple returns them with an all-or-nothing approach. I am planning to 'fix' this soon by just always requesting the maximum time range and having the library filter out reports outside the given range.

Do note that Apple only stores reports for up to 7 days, so pulling older locations than that is unfortunately not possible.

malmeloo avatar Nov 10 '24 12:11 malmeloo

Should be fixed in the next release!

malmeloo avatar Dec 23 '24 16:12 malmeloo