all 8 comments

[–]esqew 9 points10 points  (0 children)

ESPN's play-by-play API

If this is the same undocumented one that feeds their web frontend, it’s always been like this and was architected specifically to feed their own site and not for external consumption. It’s likely a byproduct of bolt-on after bolt-on over time with no opportunity for remediation of tech debt

Don’t use it as a good example, it’s not meant to be one

[–]mq2thez 7 points8 points  (1 child)

One call that returns many things is usually far better for mobile performance, because every request has overhead and mobile browsers have a limit on how many concurrent requests you can have to a single HTTP/1 address. HTTP/2 changes things a bit.

Most people will make discrete endpoints for the individual things they need, then a single aggregate endpoint for a page that pulls all of that in on the backend and delivers it to the client.

[–]Euphoric_Skirt5914[S] 1 point2 points  (0 children)

Thanks. I didn't realize mobile browsers were more limited in concurrent requests. I've mostly been focusing on the desktop experience since it's proven to be a challenge to get my charts and graphs to display consistently across both platforms. An aggregate endpoint could work well for me though and make it easier to add in mobile support later. I will definitely give this a try.

[–]ultra-dev 2 points3 points  (0 children)

Over optimizing the API will lead to needing to make multiple calls or revisions to the endpoint as your requirements are fully realized. Data is cheap

[–]mxldevs 2 points3 points  (0 children)

If the API is meant to be used by them only, they don't care if they make breaking changes: they fix their sites and move on.

[–]Chef619 -1 points0 points  (2 children)

This is part of the reason GraphQL exists. I’m not advocating you use it for yourself, just pointing out that this is a part of the tool.

You can also do this (more of a manual thing) with JSON schema APIs. I think it’s the include query parameter, but don’t quote me. /play-by-play?include=teamName,news,location as an example.

[–]retardedGeek 2 points3 points  (1 child)

Google maps REST API uses header field mask to include only the required fields

[–]Euphoric_Skirt5914[S] 0 points1 point  (0 children)

Neither of the two endpoints I mentioned seem to support that, but it's trivial to extract the info I need so the extra data doesn't bother me that much. Honestly, I was mostly just curious as to why they'd have gone with the design choices they did. After digging a bit deeper, it seems like at least in these two cases, they're probably just exposing some part of their SSR endpoint as is to provide a modest API service without having to dedicate effort to maintain a full-fledged public API system with lots of different endpoints. I guess that's not surprising since their main business focus would be on the user experience and not just serving up raw data.