trakt / api-help

Trakt API docs at https://trakt.docs.apiary.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

/shows/id/last_episode returns 204. 200 and Null was expected.

mpfc75 opened this issue · comments

Trakt endpoint shows/id/last_episode returns HTTP 204 for shows that do not have any episodes. For example:

--> GET https://api.trakt.tv/shows/173650/last_episode?extended=full
--> END GET
<-- 204 https://api.trakt.tv/shows/173650/last_episode?extended=full (37ms)
date: Wed, 01 Nov 2023 21:29:04 GMT
x-frame-options: SAMEORIGIN
x-xss-protection: 0
x-content-type-options: nosniff
x-download-options: noopen
x-permitted-cross-domain-policies: none
referrer-policy: strict-origin-when-cross-origin
expires: Thu, 02 Nov 2023 05:10:27 GMT
cache-control: public, max-age=28800
x-ratelimit: {"name":"AUTHED_API_GET_LIMIT","period":300,"limit":1000,"remaining":815,"until":"2023-11-01T21:15:00Z"}
x-request-id: 7f110739-3ba5-4ce5-8dab-c96e5ecfe6a9
x-runtime: 0.011299
cf-cache-status: HIT
age: 1116
vary: Accept-Encoding
server: cloudflare
cf-ray: 81f73b2c1f78a253-YYZ
alt-svc: h3=":443"; ma=86400
<-- END HTTP

I was expecting to receive a 200 and a null episode. Is this an incorrect assumption on my part?

Actually, I think I misspoke about the show not having episodes. It does, just one and the show is in status 'planned'. Here is the info on the show, seasons, and episode:

https://api.trakt.tv/shows/173650/?extended=full,episodes

{
    "title": "Mr. & Mrs. Smith",
    "year": null,
    "ids": {
        "trakt": 173650,
        "slug": "mr-mrs-smith-173650",
        "tvdb": 396773,
        "imdb": "tt14044212",
        "tmdb": 118642,
        "tvrage": null
    },
    "tagline": null,
    "overview": "Based on the 2005 film Mr. & Mrs. Smith.",
    "first_aired": null,
    "airs": {
        "day": "Thursday",
        "time": "00:00",
        "timezone": "America/New_York"
    },
    "runtime": 42,
    "certification": null,
    "network": "Amazon",
    "country": "us",
    "trailer": null,
    "homepage": null,
    "status": "planned",
    "rating": 5.0,
    "votes": 2,
    "comment_count": 0,
    "updated_at": "2023-10-11T22:27:55.000Z",
    "language": "en",
    "available_translations": [
        "en",
        "es",
        "ru"
    ],
    "genres": [],
    "aired_episodes": 0
}

https://api.trakt.tv/shows/173650/seasons?extended=full,episodes

{
        "number": 1,
        "ids": {
            "trakt": 243979,
            "tvdb": null,
            "tmdb": 181189,
            "tvrage": null
        },
        "rating": 0.0,
        "votes": 0,
        "episode_count": 1,
        "aired_episodes": 0,
        "title": "Season 1",
        "overview": null,
        "first_aired": null,
        "updated_at": "2023-11-01T13:02:37.000Z",
        "network": "Amazon",
        "episodes": [
            {
                "season": 1,
                "number": 1,
                "title": "Episode 1",
                "ids": {
                    "trakt": 4810701,
                    "tvdb": null,
                    "imdb": null,
                    "tmdb": 2726037,
                    "tvrage": null
                },
                "number_abs": null,
                "overview": null,
                "rating": 0.0,
                "votes": 0,
                "comment_count": 0,
                "first_aired": null,
                "updated_at": "2023-10-31T23:11:12.000Z",
                "available_translations": [],
                "runtime": 42,
                "episode_type": "series_premiere"
            }
        ]
    }

Closing... sorry for confusion. I reread the doc (RTFM right?) and I see that the endpoint returns the most recently aired episode or a 204. Apparently working as designed.

A 204 is a valid success, just with no content (i.e. null) being return. I think that is valid if there is no episode found. For that show, there are no aired episodes. We use the first_aired and it is null.