Skip to content

Example: Creating the Server Connection

Patrick Boucher edited this page Jun 27, 2013 · 2 revisions

Here is example code to show how to establish your initial connection that you will use to interact with the Shotgun server.

Prior, you should have set up Shotgun for API access. This will provide you with a script name and script key to use when establishing your connection.

import pprint # Useful for debugging

from shotgun_api3 import Shotgun

SERVER_PATH = "https://your_site.shotgunstudio.com"
SCRIPT_NAME = 'my_script'     
SCRIPT_KEY = '27b65d7063f46b82e670fe807bd2b6f3fd1676c1'

sg = Shotgun(SERVER_PATH, SCRIPT_NAME, SCRIPT_KEY)

# This, for demo purposes will print property and method names available on the sg connection object
pprint.pprint([symbol for symbol in sorted(dir(sg)) if not symbol.startswith('_')])

For further information on what you can do with this Shotgun object you can read our methods reference documentation.

Clone this wiki locally