Your character

inventory and Item

Bags, the bank, equipment and the items in them.

inventory lists the items in your bags, shared slots, bank and equipment as Item handles. An Item is tied to its slot and the item that was in it: once the item is used up or moved, item:valid() is false and its other methods return nil.

for _, item in ipairs(inventory.items()) do
    if item:rarity() == inventory.RARITY_JUNK then
        print("junk:", item:name(), item:quantity())
    end
end

local kit = inventory.find("Basic Salvage Kit")
local loot = inventory.find(19721)
if kit and loot then loot:salvage(kit) end

A container is one of "items" (what's in your bags, the default), "bags" (the bags themselves), "shared" (shared inventory slots), "bank" or "equipment".

inventory

Every item in a container.
The item in one slot.
The first item in your bags or shared slots with this item id or name.
Every such item.
The total quantity of an item in your bags and shared slots.
Whether you have the item.
How many slots a container has.
How many of them are used.
Free slots in your bags.
The weapon set in use.
The land weapon set in use.
Whether an equipment slot is hidden (like a helmet).
Shows or hides an equipment slot.
Puts a bag Item into a bag slot.
Takes a bag out and puts it in another slot.
A chat link for an item, like [&AgH...].

Item

What the item is:

Whether the item is still in its slot.
item:id()integer
The item id.
Its slot.
Its container, such as "items".
Its name.
Its icon, for ui.image.
One of the inventory.RARITY_* constants.
One of the inventory.ITEM_TYPE_* constants.
How many are in the stack.
Charges left, for tools and kits.
Whether it stacks.
Whether it can be sold on the trading post.
Whether it can be salvaged.
Whether it can be used.
Whether using it uses it up.
What a vendor pays for it, in copper.
item:def()ItemDef?
Its definition. See ItemDef.
Everything at once: {id, slot, container, name, icon, rarity, item_type, quantity, charges, stackable, tradeable, salvageable, skin, stats, upgrades, infusions, dyes, def}.

What you can do with it. The ones that return a boolean return false when the item is gone.

Uses (or opens) the item.
Uses the whole stack, for items that allow it.
Picks a choice from a container that offers several.
Destroys the item, or part of the stack.
Equips it in an equipment slot (inventory.SLOT_*).
Moves it, or part of the stack. slot_type is one of the inventory.SLOT_TYPE_* constants.
Salvages it with a salvage kit Item.
Deposits it in material storage.
Dyes it with four dye ids.

Constants

Rarities
RARITY_JUNKRARITY_BASICRARITY_FINERARITY_MASTERWORKRARITY_RARERARITY_EXOTICRARITY_ASCENDEDRARITY_LEGENDARY

inventory.RARITY_COLORS maps each rarity's name (junk, basic, fine, masterwork, rare, exotic, ascended, legendary) to the color the game uses for it.

Slot types
SLOT_TYPE_INVENTORYSLOT_TYPE_BANKSLOT_TYPE_SHARED
Equipment slots
SLOT_HEADSLOT_SHOULDERSLOT_CHESTSLOT_GLOVESSLOT_LEGSSLOT_BOOTSSLOT_AQUATIC_HEADGEARSLOT_WEAPON_1SLOT_WEAPON_2SLOT_WEAPON_3SLOT_WEAPON_4SLOT_AQUATIC_WEAPON_1SLOT_AQUATIC_WEAPON_2SLOT_BACK_ITEMSLOT_ACCESSORY_1SLOT_ACCESSORY_2SLOT_RING_1SLOT_RING_2SLOT_AMULETSLOT_RELIC
Item types
ITEM_TYPE_ARMORITEM_TYPE_BACK_ITEMITEM_TYPE_BAGITEM_TYPE_CONSUMABLEITEM_TYPE_CONTAINERITEM_TYPE_MATERIALITEM_TYPE_GATHERINGITEM_TYPE_GIZMOITEM_TYPE_MINIITEM_TYPE_JADE_BOT_MODULEITEM_TYPE_RELICITEM_TYPE_TRINKETITEM_TYPE_TROPHYITEM_TYPE_UPGRADE_COMPONENTITEM_TYPE_WEAPON
Weapon types
WEAPON_TYPE_SWORDWEAPON_TYPE_HAMMERWEAPON_TYPE_LONG_BOWWEAPON_TYPE_SHORT_BOWWEAPON_TYPE_AXEWEAPON_TYPE_DAGGERWEAPON_TYPE_GREATSWORDWEAPON_TYPE_MACEWEAPON_TYPE_PISTOLWEAPON_TYPE_POLEARMWEAPON_TYPE_RIFLEWEAPON_TYPE_SCEPTERWEAPON_TYPE_STAFFWEAPON_TYPE_FOCUSWEAPON_TYPE_TORCHWEAPON_TYPE_WARHORNWEAPON_TYPE_SHIELDWEAPON_TYPE_SMALL_BUNDLEWEAPON_TYPE_LARGE_BUNDLEWEAPON_TYPE_SPEARWEAPON_TYPE_HARPOON_GUNWEAPON_TYPE_TRIDENTWEAPON_TYPE_TOY
Armor
ARMOR_TYPE_HEADARMOR_TYPE_HEAD_AQUATICARMOR_TYPE_SHOULDERARMOR_TYPE_CHESTARMOR_TYPE_HANDARMOR_TYPE_LEGARMOR_TYPE_FOOTARMOR_WEIGHT_CLASS_LIGHTARMOR_WEIGHT_CLASS_MEDIUMARMOR_WEIGHT_CLASS_HEAVY
Trinkets and upgrades
TRINKET_TYPE_ACCESSORYTRINKET_TYPE_AMULETTRINKET_TYPE_RINGUPGRADE_COMPONENT_TYPE_DEFAULTUPGRADE_COMPONENT_TYPE_GEMUPGRADE_COMPONENT_TYPE_RUNEUPGRADE_COMPONENT_TYPE_SIGIL