This repo contains examples of backend integration with Media Cloud REST API.
The examples are provided for two use cases:
- using LeiaPix temporary storage API. Please refer to NodeJS and Python3 files to see the code integration examples for each corresponding language.
- using your own S3 storage. Please refer to NodeJS and Python3 files to see the code integration examples for each corresponding language.
In order to run this script, a set of credentials is used:
Leia Backend Client ID
and Leia Backend Client Secret
- to access Leia Media Cloud API. Can be acquired in Leia Account API Section.
Configuring Leia Media Cloud credentials and other parameters (required for both NodeJS and Python3 examples)
Rename .env.tmpl
into .env
. Put next env vars in .env
at root folder. The package.json start:<platform>
script will read these values to be used in the script.
ORIGINAL_IMAGE_URL=<image_url>
- URL of the image to convert to animation or to generate disparity map fromBACKEND_CLIENT_ID=<value>
- Leia Backend Client IDBACKEND_CLIENT_SECRET=<value>
- Leia Backend Client Secret
Before running the npm run start:nodejs-provided
, you need to install npm dependencies: npm i
.
After the configuration is done, you can run this script with npm run start:nodejs-provided
.
Before running the npm run start:python-provided
, you would want to configure virtualenv
for a python project:
- Make sure you have python3 installed
- Run
python3 -m venv demoenv
in the root directory of the demo project. This will create local virtual env for this project. - Run
source demoenv/bin/activate
from the root directory. This will make current virtual env an active virtual env, preventing polluting global dependencies space with this project dependencies. - Run
pip install -r requirements.txt
from the root directory. This will install all the project dependencies in the currently active virtual env.
After the configuration of virtual env is completed, you may run the python example script with npm run start:python-provided
. Running this command instead of running a file directly with python3 src/using-leiapix-storage.py
will read env values from .env
and make them available as ENV vars during script execution.
In order to run this script, two sets of credentials are used:
AWS Access Key ID
andAWS Secret Access Key
(so that script can generate AWS S3 pre-signed URLs)Leia Backend Client ID
andLeia Backend Client Secret
- to access Leia Media Cloud API. Can be acquired in Leia Account API Section.
These scripts are intended for demonstration purposes only. Because of this, they rely on a configured AWS CLI so that they can be run from a CLI. After this is done, the @aws-sdk/credential-provider-node
and boto3
packages used in these scripts will handle auth with AWS.
Real production integration should be done with secrets properly managed via CI/CD, and accessed in application environment instead.
Configuring Leia Media Cloud credentials and other parameters (required for both NodeJS and Python3 examples)
Rename .env.tmpl
into .env
. Put next env vars in .env
at root folder. The package.json start:<platform>
script will read these values to be used in the script.
ORIGINAL_IMAGE_URL=<image_url>
- URL of the image to convert to animation or to generate disparity map fromBACKEND_CLIENT_ID=<value>
- Leia Backend Client IDBACKEND_CLIENT_SECRET=<value>
- Leia Backend Client SecretS3_BUCKET_NAME=<value>
- AWS S3 bucket name to generate pre-signed URLs forS3_BUCKET_REGION=<value>
- AWS S3 bucket region to generate pre-signed URLs for (Recommended value isus-east-1
)
Before running the npm run start:nodejs-custom
, you need to install npm dependencies: npm i
.
After the configuration is done, you can run this script with npm run start:nodejs-custom
.
Before running the npm run start:python-custom
, you would want to configure virtualenv
for a python project:
- Make sure you have python3 installed
- Run
python3 -m venv demoenv
in the root directory of the demo project. This will create local virtual env for this project. - Run
source demoenv/bin/activate
from the root directory. This will make current virtual env an active virtual env, preventing polluting global dependencies space with this project dependencies. - Run
pip install -r requirements.txt
from the root directory. This will install all the project dependencies in the currently active virtual env.
After the configuration of virtual env is completed, you may run the python example script with npm run start:python-custom
. Running this command instead of running a file directly with python3 src/using-custom-storage.py
will read env values from .env
and make them available as ENV vars during script execution.
https://api.leiapix.com/api/v1/disparity
https://api.leiapix.com/api/v1/animation