---
title: "Connect a Python client to Shogun Live"
canonical: "https://help.vicon.com/space/ShogunLive121/1253212240/Connect%20a%20Python%20client%20to%20Shogun%20Live"
format: markdown
---
For information related to connecting a Python client to Live, see the following topics.

> Macro (toc)

## Create a client and check the connection

1. Start Shogun Live. It is now ready to be interacted with via the Python API.
2. To connect to the terminal server, import the Vicon Core API module.
3. Create a client. This automatically tries to connect to the specific host address on the default port (52800). In this example, the object is named `shogun_client`:
  Where:
  - `shogun_client` is the name of the object, which can be any name you want
  - `localhost` can be replaced with an IP address or hostname running Shogun Live.
4. Check that the client is connected:
  This returns True if connected, and False if not.
  If the response is `False`, ensure that you have the following in place before creating a new client:
  - An instance of Shogun is open and running
  - The specified host address is on port 52800
  - Your firewall is not blocking traffic on port 52800.

When you have successfully connected, you can access the services provided by the Shogun Live terminal server, such as CaptureServices, and interact with Shogun Live.

> Macro (scroll-pagebreak)

## Example: Set the capture name

In Shogun Live, towards the top of the Capture panel, the default capture name is **Take**.

> ![defaultCaptureName.png](media://09e3e0e5-0d90-4d4a-8309-67169ab1a2d3)

You can change the name of the take using the Python API and CaptureServices (which provides most of the functionality available in the GUI).

> ⚠️ **Note**  
> ⚠️ Both `CaptureServices` and `SubjectServices` require a connected client on construction.

The following example shows you how to retrieve and change the capture name using the Python API.

> Macro (scroll-pagebreak)

### Get the capture name

1. Import the relevant class for interacting with capture:
2. Create an object for the capture services. In this example, the object is named `capture`, but you can enter any name you like.
  This name references the object used for the shogun client that was created:
3. `CaptureServices` provides access to most of the functionality available in the GUI. We can use one of the functions in this class to look at the capture name. First, check the name of the capture to be retrieved.
4. Check that the result is a success.
  :warning: **Note**: All API calls return a result code (which are described in *vicon_core_api/result.py* files). For more information, run `help(vicon_core_api)`.   
If the connection to the terminal server is lost, you may instead receive the failure code `Result.RPCNotConnected`.
5. Print the name of the take:

### Change the capture name

1. Use the `set_capture_name` method to set the capture name to `'MyTake001'`:
2. Enter `result`, to check the return value to make sure that this succeeded.   
The following is an example of the terminal and result:
3. Enter `print(capture_name)` to check the name has been changed.
4. In Shogun Live, check that the capture name has changed.

For further information, see:

- The readme file: *C:\Program Files\Vicon\ShogunLive#.#\SDK\Python\readme.txt*
- Sample scripts: *C:\Program Files\Vicon\ShogunLive#.#\SDK\Python\sample_scripts*

To display a list of all available functions and documentation:

- Enter the following:

> Macro (scroll-pagebreak)

## Explore using Python

Run the Python `dir()` command on objects created, to show the methods that can be called:

For example, `dir(shogun_client)` or `dir(services)`

> ![image](media://d3402acf-dece-40ba-a30f-6db04829e4e8)

Run `help()` on specific methods or classes.

For example, `help(services.set_capture_name)`

> ![image](media://436e33ee-3f1c-4758-952c-cd1a9f84f6d9)