Lightning talk on JSON:API at PHP Sydney
Tonight I gave a lightning talk at the last PHP Sydney Meetup of the year.
The subject was “An Introduction to JSON:API”, which is the spec we use for our APIs at Pylon:
The slides are online here:
https://static.crabmusket.net/2024/json_api_php_sydney/
And the recording:
https://youtu.be/cc4N2TyXAKI?si=E5ypdUbZUYXspDV6&t=3895
It was the third talk I’d given at the meetup this year. The talk went well, despite me forgetting to bring the HDMI adapter port for my Framework laptop.
A few small things I forgot to say during the talk:
- It can be tempting to try to fit all API endpoints into the JSON:API mold, but sometimes they just don’t fit well. Like aggregates, charting, RPC calls like “merge these 3 entities”, basically anything outside CRUD. We have come up with various workarounds, but sometimes we just bail and create a cheeky endpoint with a verb in the URL.
- Mentioning some things we need to watch out for when preparing endpoints using Laravel, e.g. preventing 1+n query problems, or avoiding loading relationships entirely when they are excluded by sparse fieldsets.
- I did want to include some Laravel code examples, but since I wrote the slides in about 30min the morning of, I just didn’t have time.
- I also wanted to touch on how we’re working with Vue Query on the frontend and the way JSON:API’s entity-graph structure helps with that.
- Someone asked afterwards about type and documentation generation, which I had deliberately excluded from the talk to keep it focused. There seemed to be some interest in a follow-up talk on those aspects of our setup.
I was both relieved and very slightly disappointed nobody asked me afterwards about JSON Hyper-Schema (I guess they were just respecting my clearly-stated wishes).
On the subject of JSON:API, here are a few articles that have influenced me: