Hi,
I subscribed and my queries work from the web interface.
I am also aware that the field “X-Mashape-Key” contains my key.
I use Python3 for my application.
Since neither unirest
nor the wordsapi
libraries seem to work with Python3, I need to create my query on my own.
Taking the “also” example, I would imagine that I’d have to build something like that:
However, pasting this into the browser does not work: I get the following response:
{"message":"Missing Mashape application key. Go to http:\\/\\/docs.mashape.com\\/api-keys to learn how to get your API application key."}
So it seems that it is not understanding where to find the key.
Can you help me with that?
Ultimately, I plan to use Python module requests
for this, since as said the other interfaces/libs do not seem suitable at the moment.
I would then do something along these lines:
import requests
headers={ "X-Mashape-Key": "my_key_here", "Accept": "application/json" }
r = requests.get('https://entry_point', params=headers)
But that - again like in the case of copy paste into browser - gives the exact same response of “no key”…
Únase a la conversación, añada un comentario a continuación:
Thanks.
I am new to HTTP and the only way I’ve ever used an API was by setting up a long string with a website address, my query, and the key.
The way your API works is different as you say, so I understand I cannot just build a long simple string to make this work.
Since you used the specific word
headers
once more, I got triggered and looked up somePython
library that treats the HTTP protocol (which I know nothing of).I found
httplib2
: http://bitworking.org/projects/httplib2/doc/html/libhttplib2.htmlThen my full code is:
This works!! So the “trick” is that one has to formulate a GET request using the https protocol, not just “query” a website.
Thank you for pointing me in the right direction! Hope this can help other people down the line.
Hi Mike,
The ‘X-Mashape-Key’ must be sent as an HTTP header, not as part of the query string (as you’re doing in your first example).
I’m not familiar with Python, but your second example looks correct, in general. If you paste in the real code (without your read key) perhaps I can help more.