# Fetch candid from canister?

**URL:** <https://forum.dfinity.org/t/fetch-candid-from-canister/5261>\
**Category:** Developers\
**Created:** [June 16, 2021, 9:14pm UTC](https://forum.dfinity.org/t/fetch-candid-from-canister/5261 "2021-06-16T21:14:15Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![shalexbas](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/shalexbas/32/2139_2.png) [@shalexbas](https://forum.dfinity.org/u/shalexbas)\
**Post date:** [June 16, 2021, 9:14pm UTC](https://forum.dfinity.org/t/fetch-candid-from-canister/5261/1 "2021-06-16T21:14:15Z")

</div>

Hey, is it possible to fetch the candid file of a remote (running) canister A (different project) so I can import it somehow in my own motoko project and the appropriate actor for canister A will be generated with all the methods/types from the imported candid file in my project?

Thanks

---

<div class="post-metadata">

**Author:** ![wang](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/wang/32/446_2.png) [@wang](https://forum.dfinity.org/u/wang)\
**Post date:** [June 17, 2021, 2:33am UTC](https://forum.dfinity.org/t/fetch-candid-from-canister/5261/2 "2021-06-17T02:33:10Z")

</div>

You can either grab it from [https://www.ic.rocks/](https://www.ic.rocks/) or call the [\_\_get\_candid\_interface\_tmp\_hack](https://github.com/dfinity/candid/blob/a4dc06c2f35852a1a019a0b4650b901aeb547502/tools/ui/src/candid.ts#L70-L77) function yourself.

Feature request for dfx: a fetch/install command that downloads candid files for remote canisters and generates bindings.

---

<div class="post-metadata">

**Author:** ![Dustin](https://avatars.discourse-cdn.com/v4/letter/d/5daacb/32.png) [@Dustin](https://forum.dfinity.org/u/Dustin)\
**Post date:** [January 19, 2022, 10:07am UTC](https://forum.dfinity.org/t/fetch-candid-from-canister/5261/3 "2022-01-19T10:07:10Z")

</div>

Is using [\_\_get\_candid\_interface\_tmp\_hack](https://github.com/dfinity/candid/blob/a4dc06c2f35852a1a019a0b4650b901aeb547502/tools/ui/src/candid.ts#L70-L77) still the recommended way to get the candid of a public canister?

---

<div class="post-metadata">

**Author:** ![quint](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/quint/32/40449_2.png) [@quint](https://forum.dfinity.org/u/quint)\
**Post date:** [January 19, 2022, 2:18pm UTC](https://forum.dfinity.org/t/fetch-candid-from-canister/5261/4 "2022-01-19T14:18:19Z")

</div>

At this point in time, yes…

---

<div class="post-metadata">

**Author:** ![dpdp](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/dpdp/32/1143_2.png) [@dpdp](https://forum.dfinity.org/u/dpdp)\
**Post date:** [January 19, 2022, 2:52pm UTC](https://forum.dfinity.org/t/fetch-candid-from-canister/5261/5 "2022-01-19T14:52:34Z")

</div>

Note this function is only there for Motoko-based canister; for Rust canister; this function won’t be returned;

---

<div class="post-metadata">

**Author:** ![nomeata](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/nomeata/32/733_2.png) [@nomeata](https://forum.dfinity.org/u/nomeata)\
**Post date:** [January 19, 2022, 9:03pm UTC](https://forum.dfinity.org/t/fetch-candid-from-canister/5261/6 "2022-01-19T21:03:20Z")

</div>

> [@dpdp](#):
>
> for Rust canister; this function won’t be returned;

Unless [they choose to do so](https://github.com/dfinity/internet-identity/blob/d0babbab9e14b23bd7d626c01db04e0dfd45424e/src/internet_identity/src/main.rs#L608-L614).

---

<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 20, 2022, 12:36pm UTC](https://forum.dfinity.org/t/fetch-candid-from-canister/5261/7 "2022-01-20T12:36:39Z")

</div>

The governance canister also does this:  
[https://github.com/dfinity/ic/blob/c48280bbeec347a6b73160199566c612bd8ccbf7/rs/nns/governance/canister/canister.rs#L944](https://github.com/dfinity/ic/blob/c48280bbeec347a6b73160199566c612bd8ccbf7/rs/nns/governance/canister/canister.rs#L944)  
And see this thread for more:  
[https://forum.dfinity.org/t/automatically-generate-candid-from-rust-sources/5924/5?u=ori](https://forum.dfinity.org/t/automatically-generate-candid-from-rust-sources/5924/5)

---

<div class="post-metadata">

**Author:** ![Dustin](https://avatars.discourse-cdn.com/v4/letter/d/5daacb/32.png) [@Dustin](https://forum.dfinity.org/u/Dustin)\
**Post date:** [February 21, 2022, 1:04pm UTC](https://forum.dfinity.org/t/fetch-candid-from-canister/5261/8 "2022-02-21T13:04:28Z")

</div>

Is there a way to get candid from a Rust canister?

---

<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:** [February 21, 2022, 1:12pm UTC](https://forum.dfinity.org/t/fetch-candid-from-canister/5261/9 "2022-02-21T13:12:56Z")

</div>

@Dustin To get the candid directly from the canister the rust canister developer currently has to provide a \_\_get\_candid\_interface\_tmp\_hack method that serves the did file themselves. See the repo links in the last couple of posts above. (Motoko canisters do this by default.)

---

<div class="post-metadata">

**Author:** ![Dustin](https://avatars.discourse-cdn.com/v4/letter/d/5daacb/32.png) [@Dustin](https://forum.dfinity.org/u/Dustin)\
**Post date:** [February 21, 2022, 1:27pm UTC](https://forum.dfinity.org/t/fetch-candid-from-canister/5261/10 "2022-02-21T13:27:10Z")

</div>

Thanks @Ori. Just to make sure I understand correctly: Motoko canisters by default have their did available via ` __get_candid_interface_tmp_hack`. Rust canisters have to explicitly make it available via adding a `__ get_candid_interface_tmp_hack`. So if the owner of a Rust canister doesn’t declare the method, there is no way to get the candid directly from the canister?

---

<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:** [February 21, 2022, 3:25pm UTC](https://forum.dfinity.org/t/fetch-candid-from-canister/5261/11 "2022-02-21T15:25:28Z")

</div>

Correct. There are other ways for rust developers to provide the candid (see [GitHub - chenyan2002/ic-repl](https://github.com/chenyan2002/ic-repl#notes-for-rust-canisters)) but again they’d have to do this on their end.

At some point rust canisters could have this by default too, but there isn’t a direct binding for rust types so assumptions have to be made on how to map them. The didc command line tool [https://github.com/dfinity/candid/tree/master/tools/didc](https://github.com/dfinity/candid/tree/master/tools/didc) now provides a binding this way though so it may be a step toward that default being enabled. @chenyan may have more info on this.

You could also check the canister directory here, where you can search by any canister id, did files are under the Canisters tab: [https://k7gat-daaaa-aaaae-qaahq-cai.ic0.app](https://k7gat-daaaa-aaaae-qaahq-cai.ic0.app/)  
It’ll pick up the candid as above alongside candid provided in listings, so rust devs can add candid manually to a listing here if they prefer.
