Candid UI API call to get json file

hi,

i just want to be able to call “getNeurons” from a google appscript i have and get back a json file with the relevant data.

i see it works in the UI, but I see no documentation on how I could just fetch the json data file

any ideas what I should do?

You probably want to run dfx canistre call <canister> getNeurons <argument>. And to convert candid to json, you can use the idl2json utility.

i was a bit tired and didn’t elaborate.

i was hoping that there would just be some way to scrape/obtain the json data of off https://a4gq6-oaaaa-aaaab-qaa4q-cai.raw.ic0.app/?id=vq3jg-tiaaa-aaaao-ag2uq-cai since it’s a once a day operation and setting up a sever for that is a bit of overkill

is there no way to interact with that “Candid UI” system to do that?

No, I don’t think it has an API. But I’m sure with Selenium or something like this you could use that canister. Is there any other scripting language you can use? I know there’s ic-py for python, JS/TS has ic-agent, and I think there’s even already a Java agent available

(An agent is what we call any system connecting to a canister from the outside of the IC)

hmm ok thanks for the info. i was really hoping not to have to go into installing some server environment just to pull down 1 json file lol

this is super complicated just for trying to get 1 json file off a basic query, but i’ll have a poke around, i think we will just end up paying someone to write some sort of web scraper for this lol

as a side note it just seems a bit odd that there is no way to just query a canister with like
https://a4gq6-oaaaa-aaaab-qaa4q-cai.raw.ic0.app/?id=vq3jg-tiaaa-aaaao-ag2uq-cai&getNeurons={some_number}

and get a result, and the only alternative is to spend a bunch of time setting up a server with an “Agent” to basically do what can be done with a few lines on most websites that provide data

seems google workspaces can work with typescript so i’ll see if i can hire someone to create something with this ic-agent and see if it they can interact with that canister to get that info. Phát triển Apps Script bằng TypeScript  |  Google for Developers

is there some documentation somewhere that describes how to use one of these agents to make a call to a canister to get some data? even a sample script

https://agent-js.icp.xyz/agent/index.html i found this but it’s pretty basic, i don’t want to pay someone just for spending days figuring out how to do this

i found this here

are these Candid UI queries do they qualify for a “query call” to the canister or am i misunderstanding and we would need to use a “call” ?

The interface spec is too low level if you have access to JS or TS. I would recommend you read through the JS intro and then have a look at the hello world example how to use agent-js. The line that actually performs the call is this one.

The dev discord is also very helpful if you have any further questions. I’m not a JS guy myself, so I think people on the discord are better at helping you from here

1 Like

Is the issue that you just want the response in json format? If so you could call the method from the dashboard UI here, select JSON in the output, then copy-paste to a file:
https://dashboard.internetcomputer.org/canister/vq3jg-tiaaa-aaaao-ag2uq-cai

so i don’t want to be copy/pasting every 24 hours lol. the issue is how to programmatically request the json output via another computer (in this case google workspaces), so that this is automated.

cool thanks i’ll take a look at that.