# How to load/add data onto Slicer through its API?

**URL:** <https://discourse.slicer.org/t/how-to-load-add-data-onto-slicer-through-its-api/16198>\
**Category:** Development\
**Created:** [February 25, 2021, 3:04am UTC](https://discourse.slicer.org/t/how-to-load-add-data-onto-slicer-through-its-api/16198 "2021-02-25T03:04:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![will\_kim](https://avatars.discourse-cdn.com/v4/letter/w/779978/32.png) [@will\_kim](https://discourse.slicer.org/u/will_kim)\
**Post date:** [February 25, 2021, 3:04am UTC](https://discourse.slicer.org/t/how-to-load-add-data-onto-slicer-through-its-api/16198/1 "2021-02-25T03:04:33Z")

</div>

Hi is there a Slicer API that loads png, jpg, or any other common file format to Slicer. I know you can go to the ‘Add data into the scene’ to do it manually, but I want to try to include this to be automatic on my python script as well.

Thank you.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [February 25, 2021, 6:14am UTC](https://discourse.slicer.org/t/how-to-load-add-data-onto-slicer-through-its-api/16198/2 "2021-02-25T06:14:15Z")

</div>

You can use the `loadVolume` function - see [examples in the script repository](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Load_volume_from_file).

---

<div class="post-metadata">

**Author:** ![will\_kim](https://avatars.discourse-cdn.com/v4/letter/w/779978/32.png) [@will\_kim](https://discourse.slicer.org/u/will_kim)\
**Post date:** [February 26, 2021, 9:11pm UTC](https://discourse.slicer.org/t/how-to-load-add-data-onto-slicer-through-its-api/16198/3 "2021-02-26T21:11:11Z")

</div>

Thank you. Also is there a way you can automatically display only the 3D panel?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [February 26, 2021, 10:11pm UTC](https://discourse.slicer.org/t/how-to-load-add-data-onto-slicer-through-its-api/16198/4 "2021-02-26T22:11:07Z")

</div>

Yes, see examples how to switch layout in the [script repository](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository) (search for `setLayout`).
