Celestia-Node RPC API with cURL

Can I interact with a Celestia node’s RPC API without using the provided CLI tool (celestia)?

For example, I tried:

curl -X GET -H ‘Content-Type: application/json’ -d ‘{“jsonrpc”:“2.0”,“id”:“1”,“method”:“header.SyncState”,“params”:}’ http://rpc.celestia.pops.one:26657

But I got back {"jsonrpc":"2.0","id":"1","error":{"code":-32601,"message":"Method not found"}}.

Try using the Node API page for reference Celestia Node API

That’s the API I want to use, but I want to use cURL (or any tool other than celestia) to interact with it. In the example above I’m trying to call the header.SyncState method using the sample request provided in the reference but it fails with Method not found. I’m wondering what I might be missing.

1 Like

gm @harrigan - I recall answering a similar question in Discord so will provide that as an example. Hopefully this helps and please let me know if you still have open questions.

  1. Run a light node with --core.ip endpoint access.

  2. Set the auth token as described in documentation with:

export CELESTIA_NODE_AUTH_TOKEN=$(celestia light auth admin)
  1. Post your PFB with:
curl -H "Content-Type: application/json" -H "Authorization: Bearer $CELESTIA_NODE_AUTH_TOKEN" -X POST --data '{"id": 1,
  "jsonrpc": "2.0",
  "method": "blob.Submit",
  "params": [
    [
      {
        "namespace": "AAAAAAAAAAAAAAAAAAAAAAAAAAECAwQFBgcICRA=",
        "data": "VGhpcyBpcyBhbiBleGFtcGxlIG9mIHNvbWUgYmxvYiBkYXRh",
        "share_version": 0,
        "commitment": "AD5EzbG0/EMvpw0p8NIjMVnoCP4Bv6K+V6gjmwdXUKU="
      }
    ],
    {
      "Fee": 10000,
      "GasLimit": 100000
    }
  ]
}' 127.0.0.1:26658
  1. Upon posting a successful PFB, this will result in the block height:
{"jsonrpc":"2.0","result":362101,"id":1}

The transaction can be found on Celenium.

1 Like

Thanks, that’s exactly what I was looking for!

1 Like