This repo contains examples of backend integration with Media Cloud REST API.
Please refer to src/index.ts
and src/index.py
files to see code integration examples for each corresponding language.
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.
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
, you need to install npm dependencies: npm i
.
After the configuration is done, you can run this script with npm run start:nodejs
.
Before running the npm run start:python
, 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
. Running this command instead of running a file directly with python3 src/index.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