# Candid UI API call to get json file

**URL:** <https://forum.dfinity.org/t/candid-ui-api-call-to-get-json-file/18247>\
**Category:** Getting Started\
**Created:** [January 28, 2023, 11:34pm UTC](https://forum.dfinity.org/t/candid-ui-api-call-to-get-json-file/18247 "2023-01-28T23:34:57Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![superduper](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@superduper](https://forum.dfinity.org/u/superduper)\
**Post date:** [January 28, 2023, 11:34pm UTC](https://forum.dfinity.org/t/candid-ui-api-call-to-get-json-file/18247/1 "2023-01-28T23:34:57Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Vivienne](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/vivienne/32/29170_2.png) [@Vivienne](https://forum.dfinity.org/u/Vivienne)\
**Post date:** [January 30, 2023, 10:26am UTC](https://forum.dfinity.org/t/candid-ui-api-call-to-get-json-file/18247/2 "2023-01-30T10:26:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![superduper](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@superduper](https://forum.dfinity.org/u/superduper)\
**Post date:** [January 31, 2023, 12:13am UTC](https://forum.dfinity.org/t/candid-ui-api-call-to-get-json-file/18247/3 "2023-01-31T00:13:43Z")

</div>

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](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?

---

<div class="post-metadata">

**Author:** ![Vivienne](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/vivienne/32/29170_2.png) [@Vivienne](https://forum.dfinity.org/u/Vivienne)\
**Post date:** [January 31, 2023, 7:58am UTC](https://forum.dfinity.org/t/candid-ui-api-call-to-get-json-file/18247/4 "2023-01-31T07:58:45Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![superduper](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@superduper](https://forum.dfinity.org/u/superduper)\
**Post date:** [January 31, 2023, 11:47am UTC](https://forum.dfinity.org/t/candid-ui-api-call-to-get-json-file/18247/5 "2023-01-31T11:47:53Z")

</div>

> [@Vivienne](#):
>
> 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

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}](https://a4gq6-oaaaa-aaaab-qaa4q-cai.raw.ic0.app/?id=vq3jg-tiaaa-aaaao-ag2uq-cai&getNeurons=%7Bsome_number%7D)

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

---

<div class="post-metadata">

**Author:** ![superduper](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@superduper](https://forum.dfinity.org/u/superduper)\
**Post date:** [January 31, 2023, 12:06pm UTC](https://forum.dfinity.org/t/candid-ui-api-call-to-get-json-file/18247/6 "2023-01-31T12:06:31Z")

</div>

> [@Vivienne](#):
>
> JS/TS has `ic-agent`

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. [Develop Apps Script using TypeScript &nbsp;|&nbsp; Google for Developers](https://developers.google.com/apps-script/guides/typescript)

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](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

---

<div class="post-metadata">

**Author:** ![superduper](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@superduper](https://forum.dfinity.org/u/superduper)\
**Post date:** [January 31, 2023, 12:17pm UTC](https://forum.dfinity.org/t/candid-ui-api-call-to-get-json-file/18247/7 "2023-01-31T12:17:54Z")

</div>

i found this here

> **[The Internet Computer Interface Specification | Internet Computer Home](https://internetcomputer.org/docs/current/references/ic-interface-spec#http-query)**
>
> theinternetcomputerinterfacespecification}

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” ?

---

<div class="post-metadata">

**Author:** ![Vivienne](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/vivienne/32/29170_2.png) [@Vivienne](https://forum.dfinity.org/u/Vivienne)\
**Post date:** [January 31, 2023, 1:34pm UTC](https://forum.dfinity.org/t/candid-ui-api-call-to-get-json-file/18247/8 "2023-01-31T13:34:04Z")

</div>

The interface spec is too low level if you have access to JS or TS. I would recommend you read through the [JS intro](https://internetcomputer.org/docs/current/developer-docs/build/agents/javascript/javascript-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](https://github.com/dfinity/examples/blob/master/motoko/hello/src/hello_assets/src/index.js#L17).

The [dev discord](https://discord.com/invite/jnjVVQaE2C) 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

---

<div class="post-metadata">

**Author:** ![Ori](https://avatars.discourse-cdn.com/v4/letter/o/ecae2f/32.png) [@Ori](https://forum.dfinity.org/u/Ori)\
**Post date:** [January 31, 2023, 10:26pm UTC](https://forum.dfinity.org/t/candid-ui-api-call-to-get-json-file/18247/9 "2023-01-31T22:26:00Z")

</div>

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](https://dashboard.internetcomputer.org/canister/vq3jg-tiaaa-aaaao-ag2uq-cai)

---

<div class="post-metadata">

**Author:** ![superduper](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@superduper](https://forum.dfinity.org/u/superduper)\
**Post date:** [January 31, 2023, 11:50pm UTC](https://forum.dfinity.org/t/candid-ui-api-call-to-get-json-file/18247/10 "2023-01-31T23:50:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![superduper](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@superduper](https://forum.dfinity.org/u/superduper)\
**Post date:** [January 31, 2023, 11:51pm UTC](https://forum.dfinity.org/t/candid-ui-api-call-to-get-json-file/18247/11 "2023-01-31T23:51:03Z")

</div>

cool thanks i’ll take a look at that.
