SpaceTraders API Blocks

These blocks are for playing the SpaceTraders API!
You can use these blocks in your projects with credit.

Version 1.0 released!


Version 1.0 has been released!
You can find it at Snap! 7.0.2 - Build Your Own Blocks.
Please report any bugs to me.

@programmer_user I need your help with something.

I created a new block in the project for people to generate a token.
https://snap.berkeley.edu/snap/snap.html#present:Username=ego-lay_atman-bay&ProjectName=SpaceTraders%20API%20blocks%20v1.0
You do need to remove the block before sharing the project because the block saves the last used username and its token in a block variable in case you accidentally run the block without saving the token.

Edit: jut modified the block so you can reset it without deleting the block.

I'm going to try to make my own. This seems like a pretty cool idea. Thanks!

Version 1.1 released!


Version 1.1 has been released!
You can find it at Snap! 7.0.2 - Build Your Own Blocks.


This version adds a block for creating a token!
Thanks to @ego-lay_atman-bay for this!
Please report any bugs to me.

How do I send payloads in requests?

The get token block is broken. If you see how I made me block, you'd see how I did it. It really pays off to actually read the code before removing a bunch of stuff, and not even testing to see if your modification works. First, you set a nonexistent variable to the api request, then you just report another nonexistent variable. You do realize the api request also returns a lot more than just the token.

Fixed.

I didn't want to test that one because it would create unnecessary SpaceTraders account.
(I tested all the others)

You still need to get just the token

Try it now.

Yeah, it works

How do I send parameters in web services library?

I don't know.

untitled script pic - 2022-01-01T045607.989
Response
{"error":{"message":"User has insufficient funds to purchase ship.","code":400}}

I'll post my project from yesterday. It works. Snap! 7.0.2 - Build Your Own Blocks

Cool project. But the only problem is, you can't login with your api key. The only block that sets the auth variable is the one that creates an account.

Also, I can't finish this project until this question is answered, so...

What do you mean?