Hello, I just started learning typescript along making a practice project. I get an object from the API which has a lot of properties, some of which are objects or arrays themselves, and some have their objects too. How do I handle it with typescript, do I write every property by hand in interface or there is some other better way that I could do it?
I use this api https://developers.deezer.com/api/explorer
#How to handle big objects(relatively) that come from API?
12 messages · Page 1 of 1 (latest)
ts is a static system, it doesn't know what a request to the api would return, so you have to tell it
Deezer API has an OpenAPI spec, so you can use it to generate a type-safe client, plenty of tools to do so
Generate a headless Typescript API client from an OpenAPI spec
For example
@stuck finch Hi, I googled and found no openAPI spec for deezer. can you give me a hint?
Checking their docs I assumed they had one. Unfortunately, seems like they don't provide it (which kinda sucks for any kind of big public AP in 2024)
Spotify has one for sure, used it on the past.
Without a swagger / OpenAPI specs, you can't really generate a typed client reliably
An other alternative is to look for open-source TS sdk for deezer, not the greatest fan of these since it's hard to check if the sdk is in sync with API current version, but better than nothing
Apparently there previously was a provided JS sdk for deezer API, but Deezer deprecated it & isn't maintaining it since quite a while
Their care for developpers looks really awful overall