jonathan
jonathan

Reputation: 23

Response has no items array in it

When making a GET request to the API for GoogleDevelopers channel, I'm getting the following result as expected.

Request: https://www.googleapis.com/youtube/v3/channels?part=contentDetails&forUsername=GoogleDevelopers&key=MY_API_KEY

Response:

{
    "kind": "youtube#channelListResponse",
    "etag": "w0k6RzPUxkrdtxJxL2f_V-wMmtE",
    "pageInfo": {
        "totalResults": 1,
        "resultsPerPage": 5
    },
    "items": [
        {
            "kind": "youtube#channel",
            "etag": "P81a-u1XylztNDFIIotdR2fpRn8",
            "id": "UC_x5XG1OV2P6uZZ5FSM9Ttw",
            "contentDetails": {
                "relatedPlaylists": {
                    "likes": "",
                    "favorites": "",
                    "uploads": "UU_x5XG1OV2P6uZZ5FSM9Ttw"
                }
            }
        }
    ]
}

When making the request to my own Youtube Channel, Im just getting the following response.

Request: https://www.googleapis.com/youtube/v3/channels?part=contentDetails&forUsername=JOSCHLI1304&key=MY_API_KEY

{
    "kind": "youtube#channelListResponse",
    "etag": "nR8QCUcJvaTfaxr2vzyDGZfMitE",
    "pageInfo": {
        "totalResults": 0,
        "resultsPerPage": 5
    }
}

The items Array is missing...

I have no idea why this API Call works for all other channels, but not for my Channel?

I hope somebody can help me out.

Thanks

Upvotes: 1

Views: 550

Answers (1)

stvar
stvar

Reputation: 6985

That happens because JOSCHLI1304 is not the user name of any YouTube channel:

$ python3 youtube-search.py --user-name JOSCHLI1304
youtube-search.py: error: user name "JOSCHLI1304": no associated channel found

$ python3 youtube-search.py --custom-url JOSCHLI1304
youtube-search.py: error: custom URL "JOSCHLI1304": no associated channel found

$ python3 youtube-search.py --search-term JOSCHLI1304 --type channel
UCtwQthkBopRVzS5NrneQ8ZQ: JOSCHLI1304

$ python3 youtube-search.py --channel-url UCtwQthkBopRVzS5NrneQ8ZQ
joschli1304svideosundtutorials

The third command above (the one containing the command line argument --search-term) shows that there's a channel -- UCtwQthkBopRVzS5NrneQ8ZQ -- that has its title set to JOSCHLI1304.

Furthermore, the fourth command above shows that the channel of which ID is UCtwQthkBopRVzS5NrneQ8ZQ has it's custom URL set to something that's close to the name you're looking for: joschli1304svideosundtutorials.

Appendix

The script youtube-search.py used above is a public (MIT licensed) Python 3 program (that I developed) implementing an algorithm that searches for custom URLs and also is querying the API for user names.

Note that youtube-search.py requires a valid API key to be passed to it as argument of the command line option --app-key or, otherwise, passed on as the environment variable YOUTUBE_DATA_APP_KEY. (Use the command line option --help for brief helping info.)

Upvotes: 2

Related Questions