# How to determine whether a principal is a canister

**URL:** <https://forum.dfinity.org/t/how-to-determine-whether-a-principal-is-a-canister/10894>\
**Category:** Developers\
**Tags:** Functional-Programming\
**Created:** [February 15, 2022, 5:32am UTC](https://forum.dfinity.org/t/how-to-determine-whether-a-principal-is-a-canister/10894 "2022-02-15T05:32:01Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![0x000000000000000](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/0x000000000000000/32/6292_2.png) [@0x000000000000000](https://forum.dfinity.org/u/0x000000000000000)\
**Post date:** [February 15, 2022, 5:32am UTC](https://forum.dfinity.org/t/how-to-determine-whether-a-principal-is-a-canister/10894/1 "2022-02-15T05:32:01Z")

</div>

How to determine whether the principal is a canister or an identity account

---

<div class="post-metadata">

**Author:** ![faraz.shaikh](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/faraz.shaikh/32/4005_2.png) [@faraz.shaikh](https://forum.dfinity.org/u/faraz.shaikh)\
**Post date:** [February 15, 2022, 5:42am UTC](https://forum.dfinity.org/t/how-to-determine-whether-a-principal-is-a-canister/10894/2 "2022-02-15T05:42:15Z")

</div>

> **[Internet Computer | Documentation](https://smartcontracts.org/docs/interface-spec/index.html#principal)**
>
> Documentation for the internet computer.

“ and there is intentionally no mechanism to tell canister ids and user ids apart”

---

<div class="post-metadata">

**Author:** ![0x000000000000000](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/0x000000000000000/32/6292_2.png) [@0x000000000000000](https://forum.dfinity.org/u/0x000000000000000)\
**Post date:** [February 15, 2022, 6:08am UTC](https://forum.dfinity.org/t/how-to-determine-whether-a-principal-is-a-canister/10894/3 "2022-02-15T06:08:30Z")

</div>

How to get canisters code

---

<div class="post-metadata">

**Author:** ![heyuanxun](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/heyuanxun/32/4695_2.png) [@heyuanxun](https://forum.dfinity.org/u/heyuanxun)\
**Post date:** [February 17, 2022, 2:50am UTC](https://forum.dfinity.org/t/how-to-determine-whether-a-principal-is-a-canister/10894/4 "2022-02-17T02:50:33Z")

</div>

you can not get the canister code,but you can get the candid on ic.rocks through the canisterId

---

<div class="post-metadata">

**Author:** ![0x000000000000000](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/0x000000000000000/32/6292_2.png) [@0x000000000000000](https://forum.dfinity.org/u/0x000000000000000)\
**Post date:** [February 17, 2022, 5:30am UTC](https://forum.dfinity.org/t/how-to-determine-whether-a-principal-is-a-canister/10894/5 "2022-02-17T05:30:27Z")

</div>

How to get the interfaces of canisters

---

<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 17, 2022, 2:07pm UTC](https://forum.dfinity.org/t/how-to-determine-whether-a-principal-is-a-canister/10894/6 "2022-02-17T14:07:47Z")

</div>

If it’s a Motoko canister you can search by canister id here to get the interface: [https://k7gat-daaaa-aaaae-qaahq-cai.ic0.app](https://k7gat-daaaa-aaaae-qaahq-cai.ic0.app/)

If it’s not available there you check the project GitHub repo or contact the developer (maybe also ask them to [serve the candid from their canister](https://github.com/dfinity/ic/blob/c48280bbeec347a6b73160199566c612bd8ccbf7/rs/nns/governance/canister/canister.rs#L944) or create a listing above).

---

<div class="post-metadata">

**Author:** ![heyuanxun](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/heyuanxun/32/4695_2.png) [@heyuanxun](https://forum.dfinity.org/u/heyuanxun)\
**Post date:** [February 18, 2022, 2:46am UTC](https://forum.dfinity.org/t/how-to-determine-whether-a-principal-is-a-canister/10894/7 "2022-02-18T02:46:56Z")

</div>

[the dfinity UI candid canister also work](https://a4gq6-oaaaa-aaaab-qaa4q-cai.raw.ic0.app/),just put the canister ID and you will get the candid
