0

For some time i have been trying to connect with Mouser API. I have already tried to use requests library as well as urllib. For the request without parameter such as getting the manufacturer list it is all working well. Problems starts when I tried to get information that requires providing some parameters.

Ask that is working:

string_req = f"{self.__api_host}/api/v{self.__version}/search/manufacturerlist?apiKey={self.__api_key}"
ans = urllib.request.urlopen(string_req)

where:

self.__api_host='https://api.mouser.com'
self.__version=1.0
self.__api_key= <key generated in Mouser webpage>

And here we get to the question. How can I pass my params which are for exaple:

parameters = {
    "SearchByKeywordRequest": {
        "keyword": "resistor",
        "records": 50,
        "startingRecord": 0,
        "searchOptions": 4,
        "searchWithYourSignUpLanguage": "Polish"
    }
}

to download the results in the same way that it is possible with the first ask about the manufacturers.

It is my first ask here in Stack, so if I have left to little information, please let me know i will provide them as soon as possible.

  • 1
    Does this answer your question? [Python Request Post with param data](https://stackoverflow.com/questions/15900338/python-request-post-with-param-data) – mkrieger1 Oct 12 '20 at 15:10
  • From Mouser when it comes to testing the asks i get following: *curl -X POST -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"SearchByKeywordRequest\": { \"keyword\": \"resistor\", ...}}"* and it showing: URL: _https://api.mouser.com/api/v1.0/search/keyword?apiKey=_ I am using this URL and base URL (without the keyword?apiKey=...) and it did not work. For most cases of testing i get: requests.exceptions.SSLError: HTTPSConnectionPool How should i pass the _parameters_, _apiKey_ and _url_ to get it working. If it is obvious, sorry! :) – pawelkocwa Oct 12 '20 at 15:52

0 Answers0