Leveraging AEPP Python Wrapper to connect to AEP using Jupyter Lab

This article is the first one where we would explore how to use Jupyter Lab and the amazing python wrapper written by Julien Piccini available here: https://github.com/adobe/aepp

Most of what is provided in these articles is something which is available on the github repository on different places. This is more of an attempt from my end to explore the wrapper and share my own results from playing around with it.

Let’s get started !

If you are new to python, first step would be to go about installing python from here: https://www.python.org/downloads/

Make sure to check the box to add python.exe into the Path

Once installed, open command prompt and install jupyter lab.

pip install jupyterlab

Once jupyterlab is installed, launch it using the cmd

jupyter-lab

If the setup is working fine, jupyter lab should start up on localhost and you should be able to setup a python notebook like below.

Install aepp package using the below command (below command would need to be executed only the first time we install the package).

pip install aepp - upgrade

I have used the JWT token approach as I already had a project configured but you can use OAuth for the same.

Create a configuration file using the command below:

aepp.createConfigFile(destination='template_config.json',auth_type='jwt')

Once created, you would get a file where you would need to feed in the following values. In the next step, I will tell you how to grab those values from the Adobe developer console.

Open developer console in Adobe. Add the Experience Platform API as shown below:

Now save the private key locally on the system. Note the path to the key. You would need to put that in the configuration file.

Next, grab the rest of the details from the below screen to feed into the configuration file:

Once you’ve put in those details, execute the below:

config1=aepp.importConfigFile('template_config.json',connectInstance=True)

Now, depending on the use case you are trying to solve for, you can import different modules like schema, segmentation etc.

Below, I would show how to retrieve a list of segments

from aepp import segmentation
mySegs = segmentation.Segmentation()
mySegments = mySegs.getSegments()
## The above gives us a list of segments stored in a dictionary

## Print the first segment in the dictionary just to test out
mySegments[0]

This is how the output looks like for a segment payload.

This is just an example but I would be adding more posts around playing around with it.

That’s it for now !


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *