hello! I’ve just started playing with speckle today and have run into some problems trying to use the API in python. I’m not too familiar with this so I may be missing something obvious, but my call doesn’t seem to pass on the parameters. this is how I’ve set it up:
search: {'success': False, 'message': 'no search criteria present, or too short search string (must be > 2).'}
login: {'success': False, 'message': 'Invalid credentials.'}
register: {'success': False, 'message': 'Do not fuck with us. Give us your email.'}
(lol at the last one)
I’m able to get and create, but I just can’t pass my parameters. if someone could please point out to me where I’m going wrong, I’d really appreciate it!
Hello Izzy, disclaimer: I have no knowledge of python. I’ll point you towards @TomSvilans’s work on the blender plugin, which uses python and he’s got quite a bit of the speckle api calls set up in a separate speckle python library.
Hope this helps!
As a little extra, you could just register on the test server hestia and get your api token from your profile page - you can use this thereafter straight away in your authorization headers.
As well, if on windows, try using fiddler to debug your requests; you can see exactly what headers you’re sending, any body params, etc.
hi Dimitrie, thanks for the link to the python lib! I’ll have a look through and see if I can work it out.
I’m on hestia and am using my actual API token in my script, I just didn’t want to post it on here for fear that someone would have a bit too much fun with it haha
I’ll def try out fiddler; thanks for the recommendation!
Take a look at https://github.com/speckleworks/PySpeckle and - once you have installed it - take a look at the implemented API calls in SpeckleClient.py. It should be enough to get you started, but do tell if you run into issues…
thanks a lot for the help; I’m mostly up and running! I have no problems reading or deleting, however I did run into one problem trying to create a stream. I’ve set it up as so:
AttributeError: 'SpeckleApiClient' object has no attribute 'baseUrl'
I’m thinking it might just be a typo in the SpeckleClient.py; the other calls work fine with url = self.server while the StreamCreateAsync def defines the url as self.baseURL?
other than that though, it’s all working smoothly. thanks again!
thanks for the update @TomSvilans!
sorry just one more thing I should have also noticed, but I think the return for that def should be r = self.session.post() rather than r = session.post()? it’s currently throwing a name error:
Also, @izzylys, if you’re so inclined, there are a bunch of simple API calls that need to be implemented. If you’re up to speed with Git and forking and such, have a go at implementing some if you feel that they are important, submit a pull request, etc. Most of it is copypasta from other API calls, using the .NET client as a reference for the relevant URLs and such.
I’'m just quite busy with other things at the moment so I can’t devote a huge amount of time to fleshing out the rest of the client, and any extra hands on the Python client would be really appreciated! Just an invitation