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โโฆ
Doe mee aan de discussie - voeg hieronder een opmerking toe
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.