# Server API Reference

### How to Use Server Side Functions

{% embed url="<https://youtu.be/HC1IH8ralxA>" %}

### Preparing to use BrixxServerApi &#x20;

Install from npm. This will give your project access to the BrixxServerApi.

```
npm i @brixxbox/brixx-server-api
```

Reference the Class BrixxServerApi from your function source.

```javascript
const BrixxServerApi = require('@brixxbox/brixx-server-api');
```

Create an instance from BrixxServerApi to access the avialable methods.

```javascript
//Note: the constructor will always get the 2. parameter from 
//the functions call as parameter. This parameter expects the brixxboxMeta 
//as part of the body content (req.body.brixxboxMeta) 
const brixxServerApi = new BrixxServerApi(req);
```

Now the different methods from brixxServerApi can be called.&#x20;

#### Example

```javascript

const BrixxServerApi = require('@brixxbox/brixx-server-api');

module.exports = async function (context, req) {
    const brixxServerApi = new BrixxServerApi(req);
    currencyRate = await brixxServerApi.businessBrixx({
        functionName:"CurrencyConverter",
        methodName: "Convert",
        fromCurrencySymbol: "EUR",
        toCurrencySymbol: "USD"
    });

    //result back to caller (if needed)
    context.res = {
        status: 200,
        body: { 
            responseMessage: 'Rate EUR/USD: ' + currencyRate,
            currencyRate: currencyRate
        }
    };
}
```

### Server Side Api Function List

* [loadConfigRecordById](https://brixxbox.gitbook.io/brixxbox-documentation/server-api-reference/functions/loadconfigrecordbyid)
* [saveConfigRecordById](https://brixxbox.gitbook.io/brixxbox-documentation/server-api-reference/functions/saveconfigrecordbyid)
* [sqlWrite](https://brixxbox.gitbook.io/brixxbox-documentation/server-api-reference/functions/sqlwrite)
* [sqlRead](https://brixxbox.gitbook.io/brixxbox-documentation/server-api-reference/functions/sqlread)
* [sendEmail](https://brixxbox.gitbook.io/brixxbox-documentation/server-api-reference/functions/sendemail)
* [createReportPdfBlob](https://brixxbox.gitbook.io/brixxbox-documentation/server-api-reference/functions/createreportpdfblob)
* [cloudPrint](https://brixxbox.gitbook.io/brixxbox-documentation/server-api-reference/functions/cloudprint)
* [businesssBrixx](https://brixxbox.gitbook.io/brixxbox-documentation/server-api-reference/functions/businessbrixx)

#### To invoke a server function from the a brixxApi client please check [serverFunction](https://brixxbox.gitbook.io/brixxbox-documentation/client-api-reference/functions/serverfunction)


---

# 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://brixxbox.gitbook.io/brixxbox-documentation/server-api-reference.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.
