# How to load and render a vtk file via visualizer API

**URL:** https://discourse.paraview.org/t/how-to-load-and-render-a-vtk-file-via-visualizer-api/15699
**Category:** Web Support
**Created:** [November 7, 2024, 11:36pm UTC](https://discourse.paraview.org/t/how-to-load-and-render-a-vtk-file-via-visualizer-api/15699 "2024-11-07T23:36:33Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![roka2024](https://discourse.paraview.org/user_avatar/discourse.paraview.org/roka2024/32/15513_2.png) [@roka2024](https://discourse.paraview.org/u/roka2024)
#### Post date: [November 7, 2024, 11:36pm UTC](https://discourse.paraview.org/t/how-to-load-and-render-a-vtk-file-via-visualizer-api/15699/1 "2024-11-07T23:36:33Z")

</div>

Hi All,  
I want to use the REST API of visualizer to load and render a certain vtk file in the data directory it’s connected to.

The following code returns 200 but there’s nothing happening in visualizer. Can you help?

mheaders = {  
“Content-Type”: “application/json”  
}

def load\_file\_into\_pv():  
url = “visURL”  
payload = {  
“method”: “openFile”,  
“args”: {  
“file”: “/tmp/pv/file.vtk”  
}  
}

```
response = requests.get(url, json=payload, headers=mheaders)

if response.status_code == 200:
    print("File loaded successfully!")
else:
    print("Failed to load file:", response.text)

```

def render\_display():  
render\_url = “visURL”  
payload = {“method”: “render”}  
response = requests.get(render\_url, json=payload, headers=mheaders)  
if response.status\_code == 200:  
print(“Render triggered successfully!”)  
else:  
print(“Failed to trigger render:”, response.text)

---

<div class="post-metadata">

### Author: ![jourdain](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jourdain/32/11_2.png) [@jourdain](https://discourse.paraview.org/u/jourdain)
#### Post date: [November 8, 2024, 1:08am UTC](https://discourse.paraview.org/t/how-to-load-and-render-a-vtk-file-via-visualizer-api/15699/2 "2024-11-08T01:08:36Z")

</div>

Visualizer don’t have a REST API.

---

<div class="post-metadata">

### Author: ![roka2024](https://discourse.paraview.org/user_avatar/discourse.paraview.org/roka2024/32/15513_2.png) [@roka2024](https://discourse.paraview.org/u/roka2024)
#### Post date: [November 8, 2024, 1:12am UTC](https://discourse.paraview.org/t/how-to-load-and-render-a-vtk-file-via-visualizer-api/15699/3 "2024-11-08T01:12:40Z")

</div>

Is there another way that would achieve that?  
i.e. load and render a file, and set certain options like color map as default?

---

<div class="post-metadata">

### Author: ![jourdain](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jourdain/32/11_2.png) [@jourdain](https://discourse.paraview.org/u/jourdain)
#### Post date: [November 8, 2024, 1:18am UTC](https://discourse.paraview.org/t/how-to-load-and-render-a-vtk-file-via-visualizer-api/15699/4 "2024-11-08T01:18:30Z")

</div>

Command line arguments when you start visualizer. Or change the client code to process some URL and make RPC call to the server.

---

<div class="post-metadata">

### Author: ![jourdain](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jourdain/32/11_2.png) [@jourdain](https://discourse.paraview.org/u/jourdain)
#### Post date: [November 8, 2024, 1:20am UTC](https://discourse.paraview.org/t/how-to-load-and-render-a-vtk-file-via-visualizer-api/15699/5 "2024-11-08T01:20:37Z")

</div>

Or change the server code to create a REST endpoint.
