Closed PicoMitchell closed 3 years ago
I am hesitant to pick a specific model (ie. MacBook Pro (M1, Late 2020)
) and hope the versions remain Universal (even for new models that haven't released yet).
Having said that, I do like the idea of a single API call!
Some quick stats for the current implementation:
Endpoint | Size |
---|---|
Device list | 33KB |
MacBook Pro (M1, Late 2020) | 5KB |
MacBook Air (M1, Late 2020) | 5KB |
Mac Mini (M1, Late 2020) | 5KB |
iMac 24-inch (M1, Two Ports, 2021) | 3KB |
iMac 24-inch (M1, Four Ports, 2021) | 3KB |
Versus the proposed change:
Endpoint | Size |
---|---|
firmwares.json | 3.3MB |
firmwares.json/condensed | 2.5MB |
Definitely happy to trade 6 x API calls for 1 slightly larger download - considering the goal is to download gigabytes of macOS IPSW data, 2.5MB seems negligible 😃
Yeah, even though the v3/firmwares.json/condensed
is quite a bit bigger, it's actually about 2x faster (with decent internet) than doing 6 API calls (and that number will just grow over time as Apple releases more Apple Silicon models).
time curl -s https://api.ipsw.me/v3/firmwares.json/condensed > /dev/null
0.04s user 0.02s system 25% cpu 0.240 total
time ( curl -s https://api.ipsw.me/v4/devices > /dev/null; curl -s https://api.ipsw.me/v4/device/MacBookPro17,1 > /dev/null; curl -s https://api.ipsw.me/v4/device/MacBookAir10,1 > /dev/null; curl -s https://api.ipsw.me/v4/device/Macmini9,1 > /dev/null; curl -s https://api.ipsw.me/v4/device/iMac12,1 > /dev/null; curl -s https://api.ipsw.me/v4/device/iMac12,2 > /dev/null )
0.11s user 0.04s system 32% cpu 0.452 total
It seems those speeds were also quite fast because because of caching, I added arbitrary stuff (?nocache
) to the URLs to see the speeds with no caching on their first call. Quite a bit slower on both, but v3 is still about 2x faster than the 6 v4 calls.
time curl -s 'https://api.ipsw.me/v3/firmwares.json/condensed?nocache' > /dev/null
0.04s user 0.02s system 3% cpu 1.492 total
time ( curl -s 'https://api.ipsw.me/v4/devices?nocache' > /dev/null; curl -s 'https://api.ipsw.me/v4/device/MacBookPro17,1?nocache' > /dev/null; curl -s 'https://api.ipsw.me/v4/device/MacBookAir10,1?nocache' > /dev/null; curl -s 'https://api.ipsw.me/v4/device/Macmini9,1?nocache' > /dev/null; curl -s 'https://api.ipsw.me/v4/device/iMac12,1?nocache' > /dev/null; curl -s 'https://api.ipsw.me/v4/device/iMac12,2?nocache' > /dev/null )
0.11s user 0.03s system 3% cpu 4.043 total
In terms of the v3 API sticking around, I hope it does. It doesn't sound like it would be removed without notice from the note back in 2019 and it's still been reliably available since then:
https://twitter.com/icj_/status/1176583700848529409
I'm currently considering the long-term future of those older API versions. I dislike deprecating things, but those are difficult to maintain as things move forward. Any decisions I make will be warned months in advance. Nothing decided yet.
https://twitter.com/icj_/status/1176584002150551552
I fully appreciate the incredible wealth of software using the older versions of http://api.ipsw.me, and those will be my key considerations in any updates I make.
It is worth noting that the v3 API does not update as quickly at the v4 API when new stuff is released though:
https://twitter.com/icj_/status/1176583207531241479
For people experiencing slower update times on the v2, v2.1 and v3 versions of http://api.ipsw.me - my internal caching for those versions has an increased TTL now. I recommend updating to v4 - https://ipswdownloads.docs.apiary.io
https://twitter.com/icj_/status/1368997997200171016
older APIs have a significantly higher cache time. I imagine it will update within the next hour or so. I recommend updating to the latest API.
I'm not sure that's a big deal for this usage, but I wanted you to have all the info.
I'm sold on the gains from using the v3 API - I can live with a 1+ month warning 🤓
Since the macOS IPSWs currently support any and all Apple Silicon Mac models, I don't think there is great need to query the ipsw.me API for each and every available Mac model since it adds unnecessary time and that list will just grow without adding any extra IPSW downloads.
I know this is making an assumption about the future of macOS IPSWs, but the fact that they named it "UniversalMac" makes me think the macOS IPSWs will always work for any Mac models that support that version of macOS, like previous macOS installers do. I think the ipsw.me API is set up in this model based way since it was designed to handle iOS devices which have separate IPSWs for many models.
For macOS IPSWs, I think you could just query say "MacBook Pro (M1, Late 2020)" and simply don't show in the UI that you are only querying for a single model since that may confuse users. Just show a single "Retrieving firmware versions for Apple Silicon Macs" or something like that.
If we get to a point that these M1 Macs no longer support a new version of macOS, you would just need to add 1 more query for a future Apple Silicon Mac model. The other future-proof "single API call" alternative would be to use the ipsw.me v3 API (https://api.ipsw.me/v3/firmwares.json & https://api.ipsw.me/v3/firmwares.json/condensed) where you could analyze all available Mac models in code rather than needing to do multiple API calls first.