5

I'm trying to make the Stack Exchange API request using the key provided by Stack Apps. But whenever I try it always throws the below error.

{'error_id': 400, 'error_message': "key doesn't match a known application", 'error_name': 'bad_parameter'}

I'm using the Python requests library to make the requests.

STACKEXCHANGE_ENDPOINT = "https://api.stackexchange.com/"
SIMILAR_ENDPOINT = "/2.2/similar"
endpoint = STACKEXCHANGE_ENDPOINT + SIMILAR_ENDPOINT

params = {
    "key": "<mykeyhere>",
    "order": "desc",
    "sort": "relevance",
    "tagged": "django",
    "site": "stackoverflow",
    "title": self.q,
}
response = requests.get(endpoint, params=params)

My final URL will be like this:

https://api.stackexchange.com/2.2/similar?key=<mykeyhere>&order=desc&sort=relevance&tagged=django&site=stackoverflow&title=how+to+install+django+channels

Can someone tell me why I'm getting that bad_parameter error?

4
  • What is your key? Your applications are here: stackapps.com/apps/oauth The detail page says about the key: "This is not considered a secret, and may be safely embed in client side code or distributed binaries." You can try mine: s1IeZpEeBaEZM9scI25Lsg(( as well.
    – Glorfindel
    Commented Mar 27, 2020 at 8:06
  • (For the record, when I use my key in your final URL, it works. I don't do much Python so I can't test that.)
    – Glorfindel
    Commented Mar 27, 2020 at 8:48
  • Oh now it's working. You know when I copied the key I forgot (( :( How do I close this question.
    – Raja Simon
    Commented Mar 27, 2020 at 9:09
  • Please don't close it, other users can make the same mistake in the future. When they search for e.g. "key doesn't match a known application" they'll find this question.
    – Glorfindel
    Commented Mar 27, 2020 at 9:20

1 Answer 1

3

When copying the application key, please keep in mind that the parentheses are actually part of the key, even if they are the only non-alphanumeric characters in it:

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .