You can access and edit tags without operators, using the asset meta data from any ID type :
import bpy
obj = bpy.data.objects["Suzanne"] # Object name, case-sensitive !
asset_data = obj.asset_data
new_tag = asset_data.tags.new("Awesome Tag Name") # Add a new tag
new_tag.name = "Other Tag Name" # Change tag name
asset_data.tags[-1].name = "Yet Another Tag Name" # Change last tag you added
asset_data.tags[0].name = "One Last Tag Name" # Change tag #0
It's a bit harder to access and edit catalogs. Since different catalogs can share the same name, you have to access them by their UUID (unique identifier).
They are saved to disk on another file in the same folder as your blend file, or in the root folder of your asset library.
Let's say for simplicity that you want to add an asset to the first catalog named "Catalog" it finds in the file :
from pathlib import Path
import bpy
folder = Path(bpy.data.filepath).parent
target_catalog = "Catalog"
with (folder / "blender_assets.cats.txt").open() as f:
for line in f.readlines():
if line.startswith(("#", "VERSION", "\n")):
continue
# Each line contains : 'uuid:catalog_tree:catalog_name' + eol ('\n')
name = line.split(":")[2].split("\n")[0]
if name == target_catalog:
uuid = line.split(":")[0]
obj = bpy.data.objects["Suzanne"] # Object name, case-sensitive !
asset_data = obj.asset_data
asset_data.catalog_id = uuid
Another alternative method to retrieve specific catalog information, if you already have an asset in your file in the catalog you're looking for. This doesn't require you to locate the catalog definition file. It uses bpy.types.AssetMetaData.catalog_id.
import bpy
obj = bpy.data.objects["Suzanne"] # Object name, case-sensitive !
asset_data = obj.asset_data
other_asset = bpy.data.objects["OtherAsset"]
other_asset_data = other_asset.asset_data
asset_data.catalog_id = other_asset_data.catalog_id