Hi, you must obtain shotgun from sgtk. If you use that for example in Maya you can get it from current_engine:
current_engine = sgtk.platform.current_engine()
sg = current_engine.shotgun
In shotgun console just declare it by:
sg = shotgun
But if you use that in separate script which haven’t connection to shotgun. You must intiate it by:
import shotgun_api3
sg = shotgun_api3.Shotgun(sg_address, script_name=sg_script_name, api_key=sg_token)
sg_address = https address of you SG site
script_name = name of your script (declaret on “Scripts” page)
sg_token = key of yor script (declaret on “Scripts” page)