# API & Exports

The SRC Advanced Banking system provides a robust set of exports and events, allowing developers to integrate banking, loans, and credit scoring into their own resources.

## Client-Side Exports

### Open Bank UI

Opens the main banking tablet or teller interface.

```lua
-- mode: 'tablet' or 'atm'
-- atmId: 'teller' or a specific ATM ID (optional)
exports['src-bank']:OpenBank(mode, atmId)
```

### Open Teller

Quickly opens the bank teller interface.

```lua
exports['src-bank']:OpenTeller()
```

### Open ATM

Quickly opens the interface for a specific ATM.

```lua
exports['src-bank']:OpenATM(atmId)
```

### Close Bank UI

Forcefully closes the banking interface.

```lua
exports['src-bank']:CloseBank()
```

### Check if Bank is Open

Returns `true` if the banking UI is currently active.

```lua
local isOpen = exports['src-bank']:IsBankOpen()
```

### Get Closest ATM

Finds the ID of the ATM nearest to the player based on the configuration.

```lua
local atmId = exports['src-bank']:GetClosestAtmId()
```

***

## Server-Side Exports

### Get IBAN

Retrieves the IBAN associated with a player's citizen ID.

```lua
local iban = exports['src-bank']:GetIBAN("CITIZEN_ID")
```

### Get Credit Score

Retrieves the current credit score for a player.

```lua
local score = exports['src-bank']:GetCreditScore("CITIZEN_ID")
```

### Update Credit Score

Adjusts a player's credit score by adding or removing points.

```lua
-- points: can be positive or negative
exports['src-bank']:UpdateCreditScore("CITIZEN_ID", 10)
```

### Add Transaction

Manually inserts a custom transaction into a player's bank history.

```lua
-- citizenid: Target player
-- type: 'deposit', 'withdraw', 'transfer_in', 'transfer_out'
-- amount: Number
-- description: Text to display in the UI
exports['src-bank']:AddTransaction("CITIZEN_ID", "deposit", 500, "Quest Reward")
```

### Society Banking Exports

Manage organization and society bank accounts.

#### Get Society Balance

Retrieves the current balance of a society account.

```lua
-- job: Society job name (e.g., 'police')
local balance = exports['src-bank']:GetSocietyBalance("police")
```

#### Add Society Money

Adds money to a society bank account.

```lua
-- job: Society job name
-- amount: Number
-- description: Log entry for the society history
local success = exports['src-bank']:AddSocietyMoney("police", 5000, "Fine Revenue")
```

#### Remove Society Money

Removes money from a society bank account.

```lua
-- job: Society job name
-- amount: Number
-- description: Log entry for the society history
local success = exports['src-bank']:RemoveSocietyMoney("police", 1500, "Equipment Purchase")
```

#### Get or Generate Society Account

Retrieves IBAN and balance, or creates the account if it doesn't exist.

```lua
local iban, balance = exports['src-bank']:GetOrGenerateSocietyAccount("police")
```

***

### Programmatic Transfer

Performs a bank transfer between two players entirely via script.

```lua
-- senderCid: Citizen ID of the sender
-- receiverIbanOrCid: Target IBAN or Citizen ID
-- amount: Number
-- description: Custom log entry (optional)
local success, errorOrBalance = exports['src-bank']:ProgrammaticTransfer("SENDER_CID", "TARGET_CID", 1000, "Contract Payment")
```

### Check Blacklist

Checks if a player is blacklisted from taking out new loans.

```lua
local isBlacklisted = exports['src-bank']:IsBlacklisted("CITIZEN_ID")
```

***

## Events

### Client Events

#### `src-bank:client:bankRefresh`

Triggered whenever the bank data is updated (balance changes, loans paid, etc.). Use this to sync your UI if you have custom banking widgets.

```lua
RegisterNetEvent('src-bank:client:bankRefresh', function(data)
    -- data = { success, newBalance, transactions, chartData, message, ... }
end)
```

#### `src-bank:client:syncBalance`

Triggered for minor balance updates.

```lua
RegisterNetEvent('src-bank:client:syncBalance', function(balance, cash)
    -- handle balance update
end)
```

***

{% hint style="info" %}
**Developer Tip:** Use `ProgrammaticTransfer` when you want to ensure both players get a transaction log entry and the corresponding money is moved safely across frameworks (QBCore/ESX).
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sourcedev.pro/advanced-banking-system/api-exports.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
