> ## Documentation Index
> Fetch the complete documentation index at: https://ugcore.urging.ch/llms.txt
> Use this file to discover all available pages before exploring further.

# Shops: client and security

> Client functions and what the server checks on every purchase.

<Badge color="green">Client</Badge> Part of [Shops](/api/shops).

## Client

```lua theme={"dark"}
UgCore.Shops.GetAll() -> table<string, { label, coords }>
UgCore.Shops.Open(name) -> ok, errorCode, listing
UgCore.Shops.Buy(name, index, count) -> ok, errorCode
```

`GetAll` reads positions from `GlobalState[UgCore.Enums.GlobalState.Shops]`, for blips and markers. `Open` and `Buy` **MUST run in a thread**.

<ResponseField name="listing" type="table">
  <Expandable title="fields">
    <ResponseField name="label" type="string" />

    <ResponseField name="account" type="string" />

    <ResponseField name="items" type="{ index, name, price, stock? }[]">`stock` is missing for items that never run out.</ResponseField>
  </Expandable>
</ResponseField>

```lua client.lua theme={"dark"}
CreateThread(function()
    local ok, err, listing = UgCore.Shops.Open('general_store')

    if ok then
        -- show listing.items with labels from UgCore.Items.Get(item.name)
    end
end)
```

## Security

| Callback | Rate | Checks |
| - | - | - |
| `ug-core:ShopOpen` | 3 per second | Loaded, alive, range and access. Replies the listing. |
| `ug-core:ShopBuy` | 4 per second | Loaded, alive, then every [purchase](/api/shops#how-a-purchase-works) step. |


## Related topics

- [Weapons: client and security](/api/weapons-client.md)
- [UgCore.Shops](/api/shops.md)
- [Security model](/concepts/security.md)
- [Security](/ug-lib/security.md)
- [Inventory: client and ui](/api/inventory-client.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.