Skip to content

New type for queries with field filters #1

@g105b

Description

@g105b

I've found a bug with Spotify's API when adding field filters.

For example: https://api.spotify.com/v1/search?q=artist:"order of the toad" album:"spirit man"&type=album,track&limit=5

The first item in the result looks like this:

{
    "albums": {
        "href": "https://api.spotify.com/v1/search?query=artist%3A+%22order+of+the+toad%22+album%3A+%22spirit+man%22&type=album&offset=0&limit=5",
        "items": [
            {
                "album_type": "album",
                "artists": [
                    {
                        "external_urls": {
                            "spotify": "https://open.spotify.com/artist/0kZQLbj8h2SMVZHUJSbfBQ"
                        },
                        "href": "https://api.spotify.com/v1/artists/0kZQLbj8h2SMVZHUJSbfBQ",
                        "id": "0kZQLbj8h2SMVZHUJSbfBQ",
                        "name": "Jason Graves",
                        "type": "artist",
                        "uri": "spotify:artist:0kZQLbj8h2SMVZHUJSbfBQ"
                    }
                ],
                "external_urls": {
                    "spotify": "https://open.spotify.com/album/1IamuMB8i2g2vEJKNv7NFC"
                },
                "name": "The Order: 1886 (Video Game Soundtrack)",
                "release_date": "2015-02-16",
                "release_date_precision": "day",
                "total_tracks": 21,
                "type": "album",
                "uri": "spotify:album:1IamuMB8i2g2vEJKNv7NFC"
            }
     ]
}

After much prodding around in the dark, I found the fixed URL to look like this: https://api.spotify.com/v1/search?q=artist%3A"order of the toad" album%3A"spirit man"&type=album,track&limit=5.

So only the colon needs to be escaped, and if anything else is escaped or any spaces are surrounding the colons, seemingly random results are returned.

This is really hard to remember, and developers will never remember which characters to escape or where spaces are allowed, so a new type should be introduced to stringify perfectly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions