Shopping at LEGO or Amazon?
Please use our links: LEGO.comAmazon
As an Amazon Associate we earn from qualifying purchases.

Brickset API getSets call in Python

lin1eylin1ey Member Posts: 2
query = {'query': 'clone troopers'}

querystring = {'apiKey': secrets.API_KEY,
               'userHash': secrets.USER_HASH, 'params': query}

response = requests.request("GET", url, params=querystring)
print(response.json())

This is the code I use in my python script. However, it returns 
{'status': 'error', 'message': 'Parameter error'}

instead of a success. This is very confusing because the other methods of the API return successfully and calling the API from the website test pages return successfully. This is the only method that I used with a "params" parameter, so I suspect it is related somehow but I am unsure.

Both checkKey and checkUserHash method return successful on both Python and page. What am I doing wrong?

Comments

  • lin1eylin1ey Member Posts: 2
    Update: I did json.dumps(query) and passed that as a param for params instead and it seemed to do the trick.
    bluemonday
  • HuwHuw Administrator Posts: 7,087
    I'm glad you sussed it out because I have no idea how to actually use the API :-)
  • bluemondaybluemonday Member Posts: 1
    Hello, I came across this post as I've just started to look at using the API with Python. If it helps anyone else, the brickse library has been very easy for a new starter: https://pypi.org/project/brickse/
Sign In or Register to comment.

Shopping at LEGO.com or Amazon?

Please use our links: LEGO.com Amazon

Recent discussions Categories Privacy Policy Brickset.com

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Brickset.com is a participant in the Amazon Services LLC Associates Program, the Amazon.com.ca, Inc. Associates Program and the Amazon EU Associates Programme, which are affiliate advertising programs designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.

As an Amazon Associate we earn from qualifying purchases.