# Getting started with audiencemanager python module

In order to use the audience manager API python wrapper, you can follow the below instructions:

## 1. Create a JWT integration

You would need to create a JWT integration in console.adobe.io in order use this module.\
Once you have created the connection, please note down the different required for API calls:

* Organization ID
* Technical Account ID
* Client ID
* secret

These information will be required later in the process, at the same time than the "private.key" used for the connection.

## 2. Install the module

You can install the module with the following command line:

```shell
pip install audiencemanager
```

## 3. Generate a config file

Once you have the module install, you can instantiate it and generate a configuration file.\
You can follow the following commands:

```python
import audiencemanager as aam

aam.createConfigFile()
```

**Note**: I am using an alias "aam" for shorting the name called.

This will generate a "`config_aam.json`" file within your working directory.\
The config file content would look like something like this:

```JSON
{
    "org_id": "<orgID>",
    "client_id": "<client_id>",
    "tech_id": "<something>@techacct.adobe.com",
    "secret": "<YourSecret>",
    "pathToKey": "<path/to/your/privatekey.key>"
}
```

Replace the value with the ones you have for your configuration.

## 4. Import the configuration

Once you have your configuration file ingested, you can generate an instance of the `AudienceManager class.

This instance will have all of the endpoints and methods attached.
You can instantiate the class by doing the following command:

```python

myCompany = aam.AudienceManager()

```

## 5. Use the different methods available

Once the instantiation has been realized, you can use the different methods in such manners:

```python

myTraits = myCompany.getTraits()

newTrait = myCompany.createTrait(name='something', traitType="RULE_BASED_TRAIT", dataSourceId=666,folderId=123)

result = myCompany.deleteSegment('123456')
```

### 5.1 tipps

* I would recommend to discover the API usage with a Jupyter Notebook.
* The main GET methods have a save parameter. This will create a file from the response.
* The GET methods have a format paramater where you can choose between "df", for dataframe output, and "raw", for JSON output. \
Note that this will impact the output file as well.
* You can see the header generated by doing `myCompany.header`
* The modules used within this API are accessibles through the `modules` name.
  * pandas can be access by `audiencemanager.modules.pd`