Announcements

Help Wizard

Step 1

NEXT STEP

FAQs

Please see below the most popular frequently asked questions.

Loading article...

Loading faqs...

VIEW ALL

Ongoing Issues

Please see below the current ongoing issues which are under investigation.

Loading issue...

Loading ongoing issues...

VIEW ALL

Fully documented API

Solved!

Fully documented API

The API documentation is very incomplete. Sometimes certain fields of the JSON response can contain null and sometimes the entire response is null but they aren't documented (eg fetching the current playback state when the app isn't open on any device). Is there any (un)official documentation which fully documents what values the response can return?

 

 

Reply

Accepted Solutions
Marked as solution

You can check out my strongly-typed object model which has been tested for well over a year in my library. It has many properties marked as optional that you wouldn't expect.

View solution in original post

3 Replies
Marked as solution

You can check out my strongly-typed object model which has been tested for well over a year in my library. It has many properties marked as optional that you wouldn't expect.

Thank you very much for this. Your library has been the perfect reference.

I just had one question since I'm not familiar with Swift:

 

    func recentlyPlayed(
        _ timeReference: TimeReference? = nil,
        limit: Int? = nil
    ) -> AnyPublisher<CursorPagingObject<PlayHistory>, Error> {
 

Based on the return type and (and the fact that you haven't called .decodeOptionalSpotifyObject) - nil is never returned.

PlayHistory objects don't have a nullable "items" field either.

Does this imply that the JSON response never has the "items" key's value as null? Or do CursorPagingObjects/PlayHistory create an empty array for null values?

 

 

If the JSON payload is missing a key or the value for it is null, then trying to decode into an array will fail. It will NOT be automatically decoded into an empty array without special code. I should probably do some testing with a new account to see what  the structure of the JSON response is when the user has no play history. This is not a scenario I've considered before, so thanks for highlighting this.

Suggested posts