Using the REST API

Hi all,

Is it possible to make REST API calls without having a local node [fully synced] on my machine?

In other words, would it be possible to get the same functionality of the Algorand block explorer for my python app, but without the need to depend on a local node; which I fear may become an issue in regards to taking up too much space.

Thanks!

1 Like

Dave, yes. Just sign up and use purestake api. https://www.purestake.com/technology/algorand-api/

1 Like

Hi Dave,

AlgoExplorer has a full API. We will release it publicly very soon but if you want to start playing with it you can get full documentation here:
https://api.algoexplorer.io/v1/doc/swagger.yml, you can open this file with https://editor.swagger.io/ to read it fully formatted.

Get 10 latest transactions of Binance hot wallet:
https://api.algoexplorer.io/v1/account/SP745JJR4KPRQEXJZHVIEN736LYTL2T2DFMG3OIIFJBV66K73PHNMDCZVM/transactions/latest/10

Get transactions of block 2783757:
https://api.algoexplorer.io/v1/block/2783757/transactions

Get block count on Testnet:
https://api.testnet.algoexplorer.io/v1/block/count

It supports Mainnet / Testnet / Betanet.

Best,
Pablo

3 Likes

Hey Dave - Sorry for the delay here. As Visybl said, you can just sign up for an account on PureStake.com We’ve got a few different levels depending on what you’re looking for. Feel free to reach out if you need a hand nateATpurestakeDOTcom

1 Like

Hi, @NHamilton!
How can the PureStake POST API used?
Namely, in what binary format shoud be the transaction?
After using base 64 encoding, the result is:

Error: Bad Request

can't parse JSON. Raw result: msgpack decode error [pos 1]: only encoded map or array can be decoded into a struct

Can you give a specific example of using the POST API?

At present time, the POST transaction requires an additional header containing the content-type of application/x-binary and in JavaScript in particular one client for the GETs and one for the POST.

PureStake is working with Algorand to try to bake the header directly into the SDK’s for this call and barring that a simplified version where only a single client is created - but for now here is a complete example at https://github.com/PureStake/api-examples/blob/master/javascript-examples/submit_tx.js

PureStake has examples in all the SDK supported languages here - https://github.com/PureStake/api-examples

2 Likes

To @NHamilton

Using PureStake API with cURL, post signed transaction (on Testnet):

$ curl -X POST "https://testnet-algorand.api.purestake.io/ps1/v1/transactions" -H  "accept: application/json" -H  "Content-Type: application/x-binary" -H  "x-api-key: (api_key)" --data-binary @tx1.tx
{"txId":"BLNQO3NTHPW3GPXHGI3P7OXDFJED2PJ4J6XVZAZJ7T5ITCXDWHFQ"}

Note, that the signed transation can be included in the POST request with

--data-binary @filename

Note also, that fv (firstvalid) in the transaction must be less equal that that the actual block number.

1 Like

Great to see. Let us know if you need a hand with anything.

Hello Maugli, can you please show me what’s inside of the tx1.tx file? I am trying to run the same curl you posted but I am always getting this error message:

msgpack decode error [pos 1]: only encoded map or array can be decoded into a struct

Thanks

Did you try to generate the transaction following this tutorial?

https://developer.algorand.org/docs/build-apps/hello_world/

Yes, I have no issues getting the proper response using JavaScript, but it is failing when I try to do the same using cUrl or PureStake.

Thanks

How are you generating the file? From the developer site, creating and signing using goal looks like:

$ goal clerk send --from=<my-account> --to=GD64YIY3TWGDMCNPP553DZPPR6LDUSFQOIJVFDPPXWEG3FVOJCCDBBHU5A --fee=1000 --amount=1000000 --note="Hello World" --out="hello-world.txn"

$ goal clerk sign --infile="hello-world.txn" --outfile="hello-world.stxn"

Also, in the cUrl, note the inclusion of the header object denoting the ‘Content-type’ as ‘application/x-binary’ - this carries over in the JavaScript w/PureStake as a requirement to include the content type with the transaction submission.