1

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.

2
  • 1
    Does this answer your question? Python Request Post with param data Commented Oct 12, 2020 at 15:10
  • From Mouser when it comes to testing the asks i get following: curl -X POST <URL> -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"SearchByKeywordRequest\": { \"keyword\": \"resistor\", ...}}" and it showing: URL: api.mouser.com/api/v1.0/search/…> 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! :) Commented Oct 12, 2020 at 15:52

0

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.