0

I received the error: AttributeError: 'set' object has no attribute 'items' while trying to get info via twitch API.

import requests

ENDPOINT = 'https://api.twitch.tv/kraken/clips/top?channel=Twitch&period=month&trending=true&limit=1'

HEAD = {
    'Accept: application/vnd.twitchtv.v5+json',
    'Client-ID: HIDDEN',
}

response = requests.get(url=ENDPOINT, headers=HEAD)
print (response.text)
1
  • my bad, marked as the right answer. Thanks for the help Amir! Commented Dec 9, 2020 at 14:48

1 Answer 1

3

The problem is the way you have defined your header in HEAD, you have actually created a set, not a dictionary. Revise your HEAD as follows:

HEAD = {
    'Accept': 'application/vnd.twitchtv.v5+json',
    'Client-ID': 'HIDDEN',
}

Not that the key and value are wrapped inside a quotation.

Dictionary:

{'key', 'value'}

What you had done was to create a Set:

{'key value'}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.