Skip to content

Python API Documentation

This is automatically generated documentation for the Python API scripting.

Additional notes

This was generated on 8/1/25.

Type: ConcurrentQueue<JournalEntry>

Type: uint

Get the player’s backpack serial

Type: PlayerMobile

Returns the player character object

Type: uint

Return the player’s bank container serial if open, otherwise 0

Type: Random

Can be used for random numbers. API.Random.Next(1, 100) will return a number between 1 and 100. API.Random.Next(100) will return a number between 0 and 100.

Type: uint

The serial of the last target, if it has a serial.

Type: Vector3Int

The last target’s position

Type: ushort

The graphic of the last targeting object

Type: uint

The serial of the last item or mobile from the various findtype/mobile methods

Type: PyProfile

Access useful player settings.

Values:

  • Hostile
  • Party
  • Followers
  • Objects
  • Mobiles

Values:

  • Unknown
  • Innocent
  • Ally
  • Gray
  • Criminal
  • Enemy
  • Murderer
  • Invulnerable

Values:

  • Char
  • Account
  • Server
  • Global

Use this when you need to wait for players to click buttons. Example:

while True:
API.ProcessCallbacks()
API.Pause(0.1)

Return Type: void (Does not return anything)


(name, value) Set a variable that is shared between scripts. Example:

API.SetSharedVar("myVar", 10)

Parameters:

NameTypeOptionalDescription
namestring❌ NoName of the var
valueobject❌ NoValue, can be a number, text, or most other objects too.

Return Type: void (Does not return anything)


(name) Get the value of a shared variable. Example:

myVar = API.GetSharedVar("myVar")
if myVar:
API.SysMsg(f"myVar is {myVar}")

Parameters:

NameTypeOptionalDescription
namestring❌ NoName of the var

Return Type: object


(name) Try to remove a shared variable. Example:

API.RemoveSharedVar("myVar")

Parameters:

NameTypeOptionalDescription
namestring❌ NoName of the var

Return Type: void (Does not return anything)


Clear all shared vars. Example:

API.ClearSharedVars()

Return Type: void (Does not return anything)


Close all gumps created by the API unless marked to remain open.

Return Type: void (Does not return anything)


(serial) Attack a mobile Example:

enemy = API.NearestMobile([API.Notoriety.Gray, API.Notoriety.Criminal], 7)
if enemy:
API.Attack(enemy)

Parameters:

NameTypeOptionalDescription
serialuint❌ No

Return Type: void (Does not return anything)


Attempt to bandage yourself. Older clients this will not work, you will need to find a bandage, use it, and target yourself. Example:

if player.HitsMax - player.Hits > 10 or player.IsPoisoned:
if API.BandageSelf():
API.CreateCooldownBar(delay, "Bandaging...", 21)
API.Pause(8)
else:
API.SysMsg("WARNING: No bandages!", 32)
break

Return Type: bool


If you have an item in your left hand, move it to your backpack Sets API.Found to the item’s serial. Example:

leftHand = API.ClearLeftHand()
if leftHand:
API.SysMsg("Cleared left hand: " + leftHand.Name)

Return Type: PyItem


If you have an item in your right hand, move it to your backpack Sets API.Found to the item’s serial. Example:

rightHand = API.ClearRightHand()
if rightHand:
API.SysMsg("Cleared right hand: " + rightHand.Name)

Return Type: PyItem


(serial) Single click an object Example:

API.ClickObject(API.Player)

Parameters:

NameTypeOptionalDescription
serialuint❌ NoSerial, or item/mobile reference

Return Type: void (Does not return anything)


(serial, skipQueue) Attempt to use(double click) an object. Example:

API.UseObject(API.Backpack)

Parameters:

NameTypeOptionalDescription
serialuint❌ NoThe serial
skipQueuebool✅ YesDefaults true, set to false to use a double click queue

Return Type: void (Does not return anything)


(serial) Get an item count for the contents of a container Example:

count = API.Contents(API.Backpack)
if count > 0:
API.SysMsg(f"You have {count} items in your backpack")

Parameters:

NameTypeOptionalDescription
serialuint❌ No

Return Type: int


(serial, entry) Send a context menu(right click menu) response. This does not open the menu, you do not need to open the menu first. This handles both in one action. Example:

API.ContextMenu(API.Player, 1)

Parameters:

NameTypeOptionalDescription
serialuint❌ No
entryushort❌ NoEntries start at 0, the top entry will be 0, then 1, 2, etc. (Usually)

Return Type: void (Does not return anything)


(serial) Attempt to equip an item. Layer is automatically detected. Example:

lefthand = API.ClearLeftHand()
API.Pause(2)
API.EquipItem(lefthand)

Parameters:

NameTypeOptionalDescription
serialuint❌ No

Return Type: void (Does not return anything)


Clear the move item que of all items.

Return Type: void (Does not return anything)


(serial, destination, amt, x, y) Move an item to another container. Use x, and y if you don’t want items stacking in the desination container. Example:

items = API.ItemsInContainer(API.Backpack)
API.SysMsg("Target your fish barrel", 32)
barrel = API.RequestTarget()
if len(items) > 0 and barrel:
for item in items:
data = API.ItemNameAndProps(item)
if data and "An Exotic Fish" in data:
API.QueMoveItem(item, barrel)

Parameters:

NameTypeOptionalDescription
serialuint❌ No
destinationuint❌ No
amtushort✅ YesAmount to move
xint✅ YesX coordinate inside a container
yint✅ YesY coordinate inside a container

Return Type: void (Does not return anything)


(serial, destination, amt, x, y) Move an item to another container. Use x, and y if you don’t want items stacking in the desination container. Example:

items = API.ItemsInContainer(API.Backpack)
API.SysMsg("Target your fish barrel", 32)
barrel = API.RequestTarget()
if len(items) > 0 and barrel:
for item in items:
data = API.ItemNameAndProps(item)
if data and "An Exotic Fish" in data:
API.MoveItem(item, barrel)
API.Pause(0.75)

Parameters:

NameTypeOptionalDescription
serialuint❌ No
destinationuint❌ No
amtint✅ YesAmount to move
xint✅ YesX coordinate inside a container
yint✅ YesY coordinate inside a container

Return Type: void (Does not return anything)


(serial, amt, x, y, z, OSI) Move an item to the ground near you. Example:

items = API.ItemsInContainer(API.Backpack)
for item in items:
API.QueMoveItemOffset(item, 0, 1, 0, 0)

Parameters:

NameTypeOptionalDescription
serialuint❌ No
amtushort✅ Yes0 to grab entire stack
xint✅ YesOffset from your location
yint✅ YesOffset from your location
zint✅ YesOffset from your location. Leave blank in most cases
OSIbool✅ YesTrue if you are playing OSI

Return Type: void (Does not return anything)


(serial, amt, x, y, z, OSI) Move an item to the ground near you. Example:

items = API.ItemsInContainer(API.Backpack)
for item in items:
API.MoveItemOffset(item, 0, 1, 0, 0)
API.Pause(0.75)

Parameters:

NameTypeOptionalDescription
serialuint❌ No
amtint✅ Yes0 to grab entire stack
xint✅ YesOffset from your location
yint✅ YesOffset from your location
zint✅ YesOffset from your location. Leave blank in most cases
OSIbool✅ YesTrue if you are playing OSI

Return Type: void (Does not return anything)


(skillName) Use a skill. Example:

API.UseSkill("Hiding")
API.Pause(11)

Parameters:

NameTypeOptionalDescription
skillNamestring❌ NoCan be a partial match. Will match the first skill containing this text.

Return Type: void (Does not return anything)


(spellName) Attempt to cast a spell by its name. Example:

API.CastSpell("Fireball")
API.WaitForTarget()
API.Target(API.Player)

Parameters:

NameTypeOptionalDescription
spellNamestring❌ NoThis can be a partial match. Fireba will cast Fireball.

Return Type: void (Does not return anything)


(buffName) Check if a buff is active. Example:

if API.BuffExists("Bless"):
API.SysMsg("You are blessed!")

Parameters:

NameTypeOptionalDescription
buffNamestring❌ NoThe name/title of the buff

Return Type: bool


Get a list of all buffs that are active. See Buff to see what attributes are available. Buff does not get updated after you access it in python, you will need to call this again to get the latest buff data. Example:

buffs = API.ActiveBuffs()
for buff in buffs:
API.SysMsg(buff.Title)

Return Type: Buff[]


(message, hue) Show a system message(Left side of screen). Example:

API.SysMsg("Script started!")

Parameters:

NameTypeOptionalDescription
messagestring❌ NoMessage
hueushort✅ YesColor of the message

Return Type: void (Does not return anything)


(message) Say a message outloud. Example:

API.Say("Hello friend!")

Parameters:

NameTypeOptionalDescription
messagestring❌ NoThe message to say

Return Type: void (Does not return anything)


(message, serial, hue) Show a message above a mobile or item, this is only visible to you. Example:

API.HeadMsg("Only I can see this!", API.Player)

Parameters:

NameTypeOptionalDescription
messagestring❌ NoThe message
serialuint❌ NoThe item or mobile
hueushort✅ YesMessage hue

Return Type: void (Does not return anything)


(message) Send a message to your party. Example:

API.PartyMsg("The raid begins in 30 second! Wait... we don't have raids, wrong game..")

Parameters:

NameTypeOptionalDescription
messagestring❌ NoThe message

Return Type: void (Does not return anything)


(message) Send your guild a message. Example:

API.GuildMsg("Hey guildies, just restocked my vendor, fresh valorite suits available!")

Parameters:

NameTypeOptionalDescription
messagestring❌ No

Return Type: void (Does not return anything)


(message) Send a message to your alliance. Example:

API.AllyMsg("Hey allies, just restocked my vendor, fresh valorite suits available!")

Parameters:

NameTypeOptionalDescription
messagestring❌ No

Return Type: void (Does not return anything)


(message) Whisper a message. Example:

API.WhisperMsg("Psst, bet you didn't see me here..")

Parameters:

NameTypeOptionalDescription
messagestring❌ No

Return Type: void (Does not return anything)


(message) Yell a message. Example:

API.YellMsg("Vendor restocked, get your fresh feathers!")

Parameters:

NameTypeOptionalDescription
messagestring❌ No

Return Type: void (Does not return anything)


(message) Emote a message. Example:

API.EmoteMsg("laughing")

Parameters:

NameTypeOptionalDescription
messagestring❌ No

Return Type: void (Does not return anything)


(serial) Try to get an item by its serial. Sets API.Found to the serial of the item found. Example:

donkey = API.RequestTarget()
item = API.FindItem(donkey)
if item:
API.SysMsg("Found the donkey!")
API.UseObject(item)

Parameters:

NameTypeOptionalDescription
serialuint❌ NoThe serial

Return Type: PyItem


(graphic, container, range, hue, minamount) Attempt to find an item by type(graphic). Sets API.Found to the serial of the item found. Example:

item = API.FindType(0x0EED, API.Backpack)
if item:
API.SysMsg("Found the item!")
API.UseObject(item)

Parameters:

NameTypeOptionalDescription
graphicuint❌ NoGraphic/Type of item to find
containeruint✅ YesContainer to search
rangeushort✅ YesMax range of item
hueushort✅ YesHue of item
minamountushort✅ YesOnly match if item stack is at least this much

Return Type: PyItem


(graphic, container, range, hue, minamount) Return a list of items matching the parameters set. Example:

items = API.FindTypeAll(0x0EED, API.Backpack)
if items:
API.SysMsg("Found " + str(len(items)) + " items!")

Parameters:

NameTypeOptionalDescription
graphicuint❌ NoGraphic/Type of item to find
containeruint✅ YesContainer to search
rangeushort✅ YesMax range of item(if on ground)
hueushort✅ YesHue of item
minamountushort✅ YesOnly match if item stack is at least this much

Return Type: PyItem[]


(layer, serial) Attempt to find an item on a layer. Sets API.Found to the serial of the item found. Example:

item = API.FindLayer("Helmet")
if item:
API.SysMsg("Wearing a helmet!")

Parameters:

NameTypeOptionalDescription
layerstring❌ NoThe layer to check, see https://github.com/PlayTazUO/TazUO/blob/main/src/ClassicUO.Client/Game/Data/Layers.cs
serialuint✅ YesOptional, if not set it will check yourself, otherwise it will check the mobile requested

Return Type: PyItem


(container, recursive) Get all items in a container. Example:

items = API.ItemsInContainer(API.Backpack)
if items:
API.SysMsg("Found " + str(len(items)) + " items!")
for item in items:
API.SysMsg(item.Name)
API.Pause(0.5)

Parameters:

NameTypeOptionalDescription
containeruint❌ No
recursivebool✅ YesSearch sub containers also?

Return Type: PyItem[]


(graphic, hue, container, skipQueue) Attempt to use the first item found by graphic(type). Example:

API.UseType(0x3434, API.Backpack)
API.WaitForTarget()
API.Target(API.Player)

Parameters:

NameTypeOptionalDescription
graphicuint❌ NoGraphic/Type
hueushort✅ YesHue of item
containeruint✅ YesParent container
skipQueuebool✅ YesDefaults to true, set to false to queue the double click

Return Type: void (Does not return anything)


(seconds, text, hue) Create a cooldown bar. Example:

API.CreateCooldownBar(5, "Healing", 21)

Parameters:

NameTypeOptionalDescription
secondsdouble❌ NoDuration in seconds for the cooldown bar
textstring❌ NoText on the cooldown bar
hueushort❌ NoHue to color the cooldown bar

Return Type: void (Does not return anything)


(serial) Adds an item or mobile to your ignore list. These are unique lists per script. Ignoring an item in one script, will not affect other running scripts. Example:

for item in ItemsInContainer(API.Backpack):
if item.Name == "Dagger":
API.IgnoreObject(item)

Parameters:

NameTypeOptionalDescription
serialuint❌ NoThe item/mobile serial

Return Type: void (Does not return anything)


Clears the ignore list. Allowing functions to see those items again. Example:

API.ClearIgnoreList()

Return Type: void (Does not return anything)


(serial) Check if a serial is on the ignore list. Example:

if API.OnIgnoreList(API.Backpack):
API.SysMsg("Currently ignoring backpack")

Parameters:

NameTypeOptionalDescription
serialuint❌ No

Return Type: bool


(x, y, z, distance, wait, timeout) Attempt to pathfind to a location. This will fail with large distances. Example:

API.Pathfind(1414, 1515)

Parameters:

NameTypeOptionalDescription
xint❌ No
yint❌ No
zint✅ Yes
distanceint✅ YesDistance away from goal to stop.
waitbool✅ YesTrue/False if you want to wait for pathfinding to complete or time out
timeoutint✅ YesSeconds to wait before cancelling waiting

Return Type: bool


(entity, distance, wait, timeout) Attempt to pathfind to a mobile or item. Example:

mob = API.NearestMobile([API.Notoriety.Gray, API.Notoriety.Criminal], 7)
if mob:
API.PathfindEntity(mob)

Parameters:

NameTypeOptionalDescription
entityuint❌ NoThe mobile or item
distanceint✅ YesDistance to stop from goal
waitbool✅ YesTrue/False if you want to wait for pathfinding to complete or time out
timeoutint✅ YesSeconds to wait before cancelling waiting

Return Type: bool


Check if you are already pathfinding. Example:

if API.Pathfinding():
API.SysMsg("Pathfinding...!")
API.Pause(0.25)

Return Type: bool


Cancel pathfinding. Example:

if API.Pathfinding():
API.CancelPathfinding()

Return Type: void (Does not return anything)


(x, y, z, distance) Attempt to build a path to a location. This will fail with large distances. Example:

API.RequestTarget()
path = API.GetPath(int(API.LastTargetPos.X), int(API.LastTargetPos.Y))
if path is not None:
for x, y, z in path:
tile = API.GetTile(x, y)
tile.Hue = 53

Parameters:

NameTypeOptionalDescription
xint❌ No
yint❌ No
zint✅ Yes
distanceint✅ YesDistance away from goal to stop.

Return Type: PythonList


(mobile) Automatically follow a mobile. This is different than pathfinding. This will continune to follow the mobile. Example:

mob = API.NearestMobile([API.Notoriety.Gray, API.Notoriety.Criminal], 7)
if mob:
API.AutoFollow(mob)

Parameters:

NameTypeOptionalDescription
mobileuint❌ NoThe mobile

Return Type: void (Does not return anything)


Cancel auto follow mode. Example:

if API.Pathfinding():
API.CancelAutoFollow()

Return Type: void (Does not return anything)


(direction) Run in a direction. Example:

API.Run("north")

Parameters:

NameTypeOptionalDescription
directionstring❌ Nonorth/northeast/south/west/etc

Return Type: void (Does not return anything)


(direction) Walk in a direction. Example:

API.Walk("north")

Parameters:

NameTypeOptionalDescription
directionstring❌ Nonorth/northeast/south/west/etc

Return Type: void (Does not return anything)


(direction) Turn your character a specific direction. Example:

API.Turn("north")

Parameters:

NameTypeOptionalDescription
directionstring❌ Nonorth, northeast, etc

Return Type: void (Does not return anything)


(serial, name) Attempt to rename something like a pet. Example:

API.Rename(0x12345678, "My Handsome Pet")

Parameters:

NameTypeOptionalDescription
serialuint❌ NoSerial of the mobile to rename
namestring❌ NoThe new name

Return Type: void (Does not return anything)


(skipQueue) Attempt to dismount if mounted. Example:

API.Dismount()

Parameters:

NameTypeOptionalDescription
skipQueuebool✅ YesDefaults true, set to false to use a double click queue

Return Type: void (Does not return anything)


(serial, skipQueue) Attempt to mount(double click) Example:

API.Mount(0x12345678)

Parameters:

NameTypeOptionalDescription
serialuint❌ No
skipQueuebool✅ YesDefaults true, set to false to use a double click queue

Return Type: void (Does not return anything)


(targetType, timeout) Wait for a target cursor. Example:

API.WaitForTarget()

Parameters:

NameTypeOptionalDescription
targetTypestring✅ Yesneutral/harmful/beneficial/any/harm/ben
timeoutdouble✅ YesMax duration in seconds to wait

Return Type: bool


(serial) Target an item or mobile. Example:

if API.WaitForTarget():
API.Target(0x12345678)

Parameters:

NameTypeOptionalDescription
serialuint❌ NoSerial of the item/mobile to target

Return Type: void (Does not return anything)


(x, y, z, graphic) Target a location. Include graphic if targeting a static. Example:

if API.WaitForTarget():
API.Target(1243, 1337, 0)

Parameters:

NameTypeOptionalDescription
xushort❌ No
yushort❌ No
zshort❌ No
graphicushort✅ YesGraphic of the static to target

Return Type: void (Does not return anything)


(timeout) Request the player to target something. Example:

target = API.RequestTarget()
if target:
API.SysMsg("Targeted serial: " + str(target))

Parameters:

NameTypeOptionalDescription
timeoutdouble✅ YesMac duration to wait for them to target something.

Return Type: uint


(timeout) Prompts the player to target any object in the game world, including an Item , Mobile , Land tile, Static , or Multi . Waits for the player to select a target within a given timeout period.

Parameters:

NameTypeOptionalDescription
timeoutdouble✅ YesThe maximum time, in seconds, to wait for a valid target selection.
If the timeout expires without a selection, the method returns <c>null</c> . |

Return Type: PyGameObject


Target yourself. Example:

API.TargetSelf()

Return Type: void (Does not return anything)


(xOffset, yOffset) Target a land tile relative to your position. If this doesn’t work, try TargetTileRel instead. Example:

API.TargetLand(1, 1)

Parameters:

NameTypeOptionalDescription
xOffsetint❌ NoX from your position
yOffsetint❌ NoY from your position

Return Type: void (Does not return anything)


(xOffset, yOffset, graphic) Target a tile relative to your location. If this doesn’t work, try TargetLandRel instead.’ Example:

API.TargetTileRel(1, 1)

Parameters:

NameTypeOptionalDescription
xOffsetint❌ NoX Offset from your position
yOffsetint❌ NoY Offset from your position
graphicushort✅ YesOptional graphic, will try to use the graphic of the tile at that location if left empty.

Return Type: void (Does not return anything)


Cancel targeting. Example:

if API.WaitForTarget():
API.CancelTarget()
API.SysMsg("Targeting cancelled, april fools made you target something!")

Return Type: void (Does not return anything)


(targetType) Check if the player has a target cursor. Example:

if API.HasTarget():
API.CancelTarget()

Parameters:

NameTypeOptionalDescription
targetTypestring✅ Yesneutral/harmful/beneficial/any/harm/ben

Return Type: bool


Get the current map index. Standard maps are: 0 = Fel 1 = Tram 2 = Ilshenar 3 = Malas 4 = Tokuno 5 = TerMur

Return Type: int


(skill, up_down_locked) Set a skills lock status. Example:

API.SetSkillLock("Hiding", "locked")

Parameters:

NameTypeOptionalDescription
skillstring❌ NoThe skill name, can be partia;
up_down_lockedstring❌ Noup/down/locked

Return Type: void (Does not return anything)


(stat, up_down_locked) Set a skills lock status. Example:

API.SetStatLock("str", "locked")

Parameters:

NameTypeOptionalDescription
statstring❌ NoThe stat name, str, dex, int; Defaults to str.
up_down_lockedstring❌ Noup/down/locked

Return Type: void (Does not return anything)


Logout of the game. Example:

API.Logout()

Return Type: void (Does not return anything)


(serial, wait, timeout) Gets item name and properties. This returns the name and properties in a single string. You can split it by new line if you want to separate them. Example:

data = API.ItemNameAndProps(0x12345678, True)
if data:
API.SysMsg("Item data: " + data)
if "An Exotic Fish" in data:
API.SysMsg("Found an exotic fish!")

Parameters:

NameTypeOptionalDescription
serialuint❌ No
waitbool✅ YesTrue or false to wait for name and props
timeoutint✅ YesTimeout in seconds

Return Type: string


(ID) Check if a player has a server gump. Leave blank to check if they have any server gump. Example:

if API.HasGump(0x12345678):
API.SysMsg("Found a gump!")

Parameters:

NameTypeOptionalDescription
IDuint✅ YesSkip to check if player has any gump from server.

Return Type: uint


(button, gump) Reply to a gump. Example:

API.ReplyGump(21)

Parameters:

NameTypeOptionalDescription
buttonint❌ NoButton ID
gumpuint✅ YesGump ID, leave blank to reply to last gump

Return Type: bool


(ID) Close the last gump open, or a specific gump. Example:

API.CloseGump()

Parameters:

NameTypeOptionalDescription
IDuint✅ YesGump ID

Return Type: void (Does not return anything)


(text, ID) Check if a gump contains a specific text. Example:

if API.GumpContains("Hello"):
API.SysMsg("Found the text!")

Parameters:

NameTypeOptionalDescription
textstring❌ NoCan be regex if you start with $, otherwise it’s just regular search. Case Sensitive.
IDuint✅ YesGump ID, blank to use the last gump.

Return Type: bool


(ID) Get a gump by ID. Example:

gump = API.GetGump()
if gump:
API.SysMsg("Found the gump!")
API.CloseGump(gump)

Parameters:

NameTypeOptionalDescription
IDuint✅ YesLeabe blank to use last gump opened from server

Return Type: Gump


Toggle flying if you are a gargoyle. Example:

API.ToggleFly()

Return Type: void (Does not return anything)


(ability) Toggle an ability. Example:

if not API.PrimaryAbilityActive():
API.ToggleAbility("primary")

Parameters:

NameTypeOptionalDescription
abilitystring❌ Noprimary/secondary/stun/disarm

Return Type: void (Does not return anything)


Check if your primary ability is active. Example:

if API.PrimaryAbilityActive():
API.SysMsg("Primary ability is active!")

Return Type: bool


Check if your secondary ability is active. Example:

if API.SecondaryAbilityActive():
API.SysMsg("Secondary ability is active!")

Return Type: bool


(msg) Check if your journal contains a message. Example:

if API.InJournal("You have been slain"):
API.SysMsg("You have been slain!")

Parameters:

NameTypeOptionalDescription
msgstring❌ NoThe message to check for. Can be regex, prepend your msg with $

Return Type: bool


(msgs) Check if the journal contains any of the strings in this list. Can be regex, prepend your msgs with $ Example:

if API.InJournalAny(["You have been slain", "You are dead"]):
API.SysMsg("You have been slain or dead!")

Parameters:

NameTypeOptionalDescription
msgsIList<string>❌ No

Return Type: bool


Clear your journal(This is specific for each script). Example:

API.ClearJournal()

Return Type: void (Does not return anything)


(seconds) Pause the script. Example:

API.Pause(5)

Parameters:

NameTypeOptionalDescription
secondsdouble❌ No

Return Type: void (Does not return anything)


Stops the current script. Example:

API.Stop()

Return Type: void (Does not return anything)


Toggle autolooting on or off. Example:

API.ToggleAutoLoot()

Return Type: void (Does not return anything)


(container) Use autoloot on a specific container. Example:

targ = API.RequestTarget()
if targ:
API.AutoLootContainer(targ)

Parameters:

NameTypeOptionalDescription
containeruint❌ No

Return Type: void (Does not return anything)


(virtue) Use a virtue. Example:

API.Virtue("honor")

Parameters:

NameTypeOptionalDescription
virtuestring❌ Nohonor/sacrifice/valor

Return Type: void (Does not return anything)


(scanType, maxDistance) Find the nearest item/mobile based on scan type. Sets API.Found to the serial of the item/mobile. Example:

item = API.NearestEntity(API.ScanType.Item, 5)
if item:
API.SysMsg("Found an item!")
API.UseObject(item)
# You can use API.FindItem or API.FindMobile(item.Serial) to determine if it's an item or mobile

Parameters:

NameTypeOptionalDescription
scanTypeScanType❌ No
maxDistanceint✅ Yes

Return Type: PyEntity


(notoriety, maxDistance) Get the nearest mobile by Notoriety. Sets API.Found to the serial of the mobile. Example:

mob = API.NearestMobile([API.Notoriety.Murderer, API.Notoriety.Criminal], 7)
if mob:
API.SysMsg("Found a criminal!")
API.Msg("Guards!")
API.Attack(mob)

Parameters:

NameTypeOptionalDescription
notorietyIList<Notoriety>❌ NoList of notorieties
maxDistanceint✅ Yes

Return Type: PyMobile


(distance) Get the nearest corpse within a distance. Sets API.Found to the serial of the corpse. Example:

corpse = API.NearestCorpse()
if corpse:
API.SysMsg("Found a corpse!")
API.UseObject(corpse)

Parameters:

NameTypeOptionalDescription
distanceint✅ Yes

Return Type: PyItem


(notoriety, maxDistance) Get all mobiles matching Notoriety and distance. Example:

mob = API.NearestMobiles([API.Notoriety.Murderer, API.Notoriety.Criminal], 7)
if len(mob) > 0:
API.SysMsg("Found enemies!")
API.Msg("Guards!")
API.Attack(mob[0])

Parameters:

NameTypeOptionalDescription
notorietyIList<Notoriety>❌ NoList of notorieties
maxDistanceint✅ Yes

Return Type: PyMobile[]


(serial) Get a mobile from its serial. Sets API.Found to the serial of the mobile. Example:

mob = API.FindMobile(0x12345678)
if mob:
API.SysMsg("Found the mobile!")
API.UseObject(mob)

Parameters:

NameTypeOptionalDescription
serialuint❌ No

Return Type: PyMobile


Return a list of all mobiles the client is aware of. Example:

mobiles = API.GetAllMobiles()
if mobiles:
API.SysMsg("Found " + str(len(mobiles)) + " mobiles!")
for mob in mobiles:
API.SysMsg(mob.Name)
API.Pause(0.5)

Return Type: PyMobile[]


(x, y) Get the tile at a location. Example:

tile = API.GetTile(1414, 1515)
if tile:
API.SysMsg(f"Found a tile with graphic: {tile.Graphic}")

Parameters:

NameTypeOptionalDescription
xint❌ No
yint❌ No

Return Type: PyGameObject


(acceptMouseInput, canMove, keepOpen) Get a blank gump. Example:

g = API.CreateGump()
g.SetRect(100, 100, 200, 200)
g.Add(API.CreateGumpLabel("Hello World!"))
API.AddGump(g)

Parameters:

NameTypeOptionalDescription
acceptMouseInputbool✅ YesAllow clicking the gump
canMovebool✅ YesAllow the player to move this gump
keepOpenbool✅ YesIf true, the gump won’t be closed if the script stops. Otherwise, it will be closed when the script is stopped. Defaults to false.

Return Type: Gump


(g) Add a gump to the players screen. Example:

g = API.CreateGump()
g.SetRect(100, 100, 200, 200)
g.Add(API.CreateGumpLabel("Hello World!"))
API.AddGump(g)

Parameters:

NameTypeOptionalDescription
gGump❌ NoThe gump to add

Return Type: void (Does not return anything)


(text, hue, isChecked) Create a checkbox for gumps. Example:

g = API.CreateGump()
g.SetRect(100, 100, 200, 200)
cb = API.CreateGumpCheckbox("Check me?!")
g.Add(cb)
API.AddGump(g)
API.SysMsg("Checkbox checked: " + str(cb.IsChecked))

Parameters:

NameTypeOptionalDescription
textstring✅ YesOptional text label
hueushort✅ YesOptional hue
isCheckedbool✅ YesDefault false, set to true if you want this checkbox checked on creation

Return Type: Checkbox


(text, hue) Create a label for a gump. Example:

g = API.CreateGump()
g.SetRect(100, 100, 200, 200)
g.Add(API.CreateGumpLabel("Hello World!"))
API.AddGump(g)

Parameters:

NameTypeOptionalDescription
textstring❌ NoThe text
hueushort✅ YesThe hue of the text

Return Type: Label


(opacity, color) Get a transparent color box for gumps. Example:

g = API.CreateGump()
g.SetRect(100, 100, 200, 200)
cb = API.CreateGumpColorBox(0.5, "#000000")
cb.SetWidth(200)
cb.SetHeight(200)
g.Add(cb)
API.AddGump(g)

Parameters:

NameTypeOptionalDescription
opacityfloat✅ Yes0.5 = 50%
colorstring✅ YesHtml color code like #000000

Return Type: AlphaBlendControl


(graphic, width, height) Create a picture of an item. Example:

g = API.CreateGump()
g.SetRect(100, 100, 200, 200)
g.Add(API.CreateGumpItemPic(0x0E78, 50, 50))
API.AddGump(g)

Parameters:

NameTypeOptionalDescription
graphicuint❌ No
widthint❌ No
heightint❌ No

Return Type: ResizableStaticPic


(text, hue, normal, pressed, hover) Create a button for gumps. Example:

g = API.CreateGump()
g.SetRect(100, 100, 200, 200)
button = API.CreateGumpButton("Click Me!")
g.Add(button)
API.AddGump(g)
while True:
API.SysMsg("Button currently clicked?: " + str(button.IsClicked))
API.SysMsg("Button clicked since last check?: " + str(button.HasBeenClicked()))
API.Pause(0.2)

Parameters:

NameTypeOptionalDescription
textstring✅ Yes
hueushort✅ Yes
normalushort✅ YesGraphic when not clicked or hovering
pressedushort✅ YesGraphic when pressed
hoverushort✅ YesGraphic on hover

Return Type: Button


(text, width, height) Create a simple button, does not use graphics. Example:

g = API.CreateGump()
g.SetRect(100, 100, 200, 200)
button = API.CreateSimpleButton("Click Me!", 100, 20)
g.Add(button)
API.AddGump(g)

Parameters:

NameTypeOptionalDescription
textstring❌ No
widthint❌ No
heightint❌ No

Return Type: NiceButton


(text, group, inactive, active, hue, isChecked) Create a radio button for gumps, use group numbers to only allow one item to be checked at a time. Example:

g = API.CreateGump()
g.SetRect(100, 100, 200, 200)
rb = API.CreateGumpRadioButton("Click Me!", 1)
g.Add(rb)
API.AddGump(g)
API.SysMsg("Radio button checked?: " + str(rb.IsChecked))

Parameters:

NameTypeOptionalDescription
textstring✅ YesOptional text
groupint✅ YesGroup ID
inactiveushort✅ YesUnchecked graphic
activeushort✅ YesChecked graphic
hueushort✅ YesText color
isCheckedbool✅ YesDefaults false, set to true if you want this button checked by default.

Return Type: RadioButton


(text, width, height, multiline) Create a text area control. Example:

w = 500
h = 600
gump = API.CreateGump(True, True)
gump.SetWidth(w)
gump.SetHeight(h)
gump.CenterXInViewPort()
gump.CenterYInViewPort()
bg = API.CreateGumpColorBox(0.7, "#D4202020")
bg.SetWidth(w)
bg.SetHeight(h)
gump.Add(bg)
textbox = API.CreateGumpTextBox("Text example", w, h, True)
gump.Add(textbox)
API.AddGump(gump)

Parameters:

NameTypeOptionalDescription
textstring✅ Yes
widthint✅ Yes
heightint✅ Yes
multilinebool✅ Yes

Return Type: TTFTextInputField


(text, size, color, font, aligned, maxWidth, applyStroke) Create a TTF label with advanced options. Example:

gump = API.CreateGump()
gump.SetRect(100, 100, 200, 200)
ttflabel = API.CreateGumpTTFLabel("Example label", 25, "#F100DD", "alagard")
ttflabel.SetRect(10, 10, 180, 30)
gump.Add(ttflabel)
API.AddGump(gump) #Add the gump to the players screen

Parameters:

NameTypeOptionalDescription
textstring❌ No
sizefloat❌ NoFont size
colorstring✅ YesHex color: #FFFFFF. Must begin with #.
fontstring✅ YesMust have the font installed in TazUO
alignedstring✅ Yesleft/center/right. Must set a max width for this to work.
maxWidthint✅ YesMax width before going to the next line
applyStrokebool✅ YesUses players stroke settings, this turns it on or off

Return Type: TextBox


(width, height, backgroundColor, foregroundColor, value, max) Create a progress bar. Can be updated as needed with bar.SetProgress(current, max). Example:

gump = API.CreateGump()
gump.SetRect(100, 100, 400, 200)
pb = API.CreateGumpSimpleProgressBar(400, 200)
gump.Add(pb)
API.AddGump(gump)
cur = 0
max = 100
while True:
pb.SetProgress(cur, max)
if cur >= max:
break
cur += 1
API.Pause(0.5)

Parameters:

NameTypeOptionalDescription
widthint❌ NoThe width of the bar
heightint❌ NoThe height of the bar
backgroundColorstring✅ YesThe background color(Hex color like #616161)
foregroundColorstring✅ YesThe foreground color(Hex color like #212121)
valueint✅ YesThe current value, for example 70
maxint✅ YesThe max value(or what would be 100%), for example 100

Return Type: SimpleProgressBar


(x, y, width, height) Create a scrolling area, add and position controls to it directly. Example:

sa = API.CreateGumpScrollArea(0, 60, 200, 140)
gump.Add(sa)
for i in range(10):
label = API.CreateGumpTTFLabel(f"Label {i + 1}", 20, "#FFFFFF", "alagard")
label.SetRect(5, i * 20, 180, 20)
sa.Add(label)

Parameters:

NameTypeOptionalDescription
xint❌ No
yint❌ No
widthint❌ No
heightint❌ No

Return Type: ScrollArea


(graphic, x, y, hue) Create a gump pic(Use this for gump art, not item art) Example:

gumpPic = API.CreateGumpPic(0xafb)
gump.Add(gumpPic)
**Parameters:**
| Name | Type | Optional | Description |
| --- | --- | --- | --- |
| `graphic` | `ushort` | ❌ No | |
| `x` | `int` | ✅ Yes | |
| `y` | `int` | ✅ Yes | |
| `hue` | `ushort` | ✅ Yes | |
**Return Type:** `GumpPic`
---
### AddControlOnClick
`(control, onClick, leftOnly)`
Add an onClick callback to a control.
Example:
```py
def myfunc:
API.SysMsg("Something clicked!")
bg = API.CreateGumpColorBox(0.7, "#D4202020")
API.AddControlOnClick(bg, myfunc)
while True:
API.ProcessCallbacks()

Parameters:

NameTypeOptionalDescription
controlControl❌ NoThe control listening for clicks
onClickobject❌ NoThe callback function
leftOnlybool✅ YesOnly accept left mouse clicks?

Return Type: Control


(control, onDispose) Add onDispose(Closed) callback to a control. Example:

def onClose():
API.Stop()
gump = API.CreateGump()
gump.SetRect(100, 100, 200, 200)
bg = API.CreateGumpColorBox(opacity=0.7, color="#000000")
gump.Add(bg.SetRect(0, 0, 200, 200))
API.AddControlOnDisposed(gump, onClose)

Parameters:

NameTypeOptionalDescription
controlControl❌ No
onDisposeobject❌ No

Return Type: Control


(skill) Get a skill from the player. See the Skill class for what properties are available: https://github.com/PlayTazUO/TazUO/blob/main/src/ClassicUO.Client/Game/Data/Skill.cs Example:

skill = API.GetSkill("Hiding")
if skill:
API.SysMsg("Skill: " + skill.Name)
API.SysMsg("Skill Value: " + str(skill.Value))
API.SysMsg("Skill Cap: " + str(skill.Cap))
API.SysMsg("Skill Lock: " + str(skill.Lock))

Parameters:

NameTypeOptionalDescription
skillstring❌ NoSkill name, case-sensitive

Return Type: Skill


(distance, hue) Show a radius around the player. Example:

API.DisplayRange(7, 32)

Parameters:

NameTypeOptionalDescription
distanceushort❌ NoDistance from the player
hueushort✅ YesThe color to change the tiles at that distance

Return Type: void (Does not return anything)


(scriptName) Toggle another script on or off. Example:

API.ToggleScript("MyScript.py")

Parameters:

NameTypeOptionalDescription
scriptNamestring❌ NoFull name including extension. Can be .py or .lscript.

Return Type: void (Does not return anything)


(scriptName) Play a legion script.

Parameters:

NameTypeOptionalDescription
scriptNamestring❌ NoThis is the file name including extension.

Return Type: void (Does not return anything)


(scriptName) Stop a legion script.

Parameters:

NameTypeOptionalDescription
scriptNamestring❌ NoThis is the file name including extension.

Return Type: void (Does not return anything)


(name, x, y, map, color) Add a marker to the current World Map (If one is open) Example:

API.AddMapMarker("Death")

Parameters:

NameTypeOptionalDescription
namestring❌ No
xint✅ YesDefaults to current player X.
yint✅ YesDefaults to current player Y.
mapint✅ YesDefaults to current map.
colorstring✅ Yesred/green/blue/purple/black/yellow/white. Default purple.

Return Type: void (Does not return anything)


(name) Remove a marker from the world map. Example:

API.RemoveMapMarker("Death")

Parameters:

NameTypeOptionalDescription
namestring❌ No

Return Type: void (Does not return anything)


Check if the move item queue is being processed. You can use this to prevent actions if the queue is being processed. Example:

if API.IsProcessingMoveQue():
API.Pause(0.5)

Return Type: bool


Check if the use item queue is being processed. You can use this to prevent actions if the queue is being processed. Example:

if API.IsProcessingUseItemQueue():
API.Pause(0.5)

Return Type: bool


Check if the global cooldown is currently active. This applies to actions like moving or using items, and prevents new actions from executing until the cooldown has expired.

Example:

if API.IsGlobalCooldownActive():
API.Pause(0.5)

Return Type: bool


(name, value, scope) Save a variable that persists between sessions and scripts. Example:

API.SavePersistentVar("TotalKills", "5", API.PersistentVar.Char)

Parameters:

NameTypeOptionalDescription
namestring❌ No
valuestring❌ No
scopePersistentVar❌ No

Return Type: void (Does not return anything)


(name, scope) Delete/remove a persistent variable. Example:

API.RemovePersistentVar("TotalKills", API.PersistentVar.Char)

Parameters:

NameTypeOptionalDescription
namestring❌ No
scopePersistentVar❌ No

Return Type: void (Does not return anything)


(name, defaultValue, scope) Get a persistent variable. Example:

API.GetPersistentVar("TotalKills", "0", API.PersistentVar.Char)

Parameters:

NameTypeOptionalDescription
namestring❌ No
defaultValuestring❌ NoThe value returned if no value was saved
scopePersistentVar❌ No

Return Type: string


(x, y, hue, map) Mark a tile with a specific hue.

Parameters:

NameTypeOptionalDescription
xint❌ No
yint❌ No
hueushort❌ No
mapint✅ YesDefaults to current map

Return Type: void (Does not return anything)


(x, y, map) Remove a marked tile. See MarkTile for more info.

Parameters:

NameTypeOptionalDescription
xint❌ No
yint❌ No
mapint✅ Yes

Return Type: void (Does not return anything)