Perfect Corp Python API Docs | dltHub

Build a Perfect Corp-to-database pipeline in Python using dlt with AI Workbench support for Claude Code, Cursor, and Codex.

Last updated:

Perfect Corp AI (YouCam) API is a RESTful AI and image/video processing platform exposing endpoints for file uploads, asynchronous AI tasks, template listings and task status polling. The REST API base URL is https://yce-api-01.perfectcorp.com and All requests require a Bearer token (API key) in the Authorization header..

dlt is an open-source Python library that handles authentication, pagination, and schema evolution automatically. dlthub provides AI context files that enable code assistants to generate production-ready pipelines. Install with uv pip install "dlt[workspace]" and start loading Perfect Corp data in under 10 minutes.


What data can I load from Perfect Corp?

Here are some of the endpoints you can load from Perfect Corp:

ResourceEndpointMethodData selectorDescription
file_upload/s2s/v2.0/file/{feature}POSTresult.filesCreate file upload record; returns upload URL and file_id used by tasks
list_templates/s2s/v2.0/task/template/{feature}GETresultList available templates/style groups for template‑based features
start_task/s2s/v2.0/task/{feature}POSTresultStart an async AI task; returns task_id
get_task/s2s/v2.0/task/{feature} or /s2s/v2.0/task/{task_id}GETdataPoll task status and obtain results (results or result.url)
auth_token/s2s/v1.0/client/authPOSTresult.access_token(v1) exchange client_id + id_token for access_token
list_files/s2s/v2.0/file/listGETresult.filesList uploaded files and file metadata
list_styles/s2s/v2.0/task/template/hair-styleGETresult.stylesExample template‑specific listing endpoint returning styles
get_template/s2s/v2.0/task/template/{feature}/{template_id}GETresultGet template details
health/s2s/v2.0/healthGET(top‑level)Service health/status check

How do I authenticate with the Perfect Corp API?

Include Authorization: Bearer <API_KEY> in every request. For V1 S2S flows, use the /s2s/v1.0/client/auth endpoint to exchange client credentials for an access token; V2 uses the API key directly as a Bearer token.

1. Get your credentials

  1. Sign in or register at Perfect Console / API Console (https://business.perfectcorp.com/ or https://yce.makeupar.com/). 2) Open the API Console / API Keys page. 3) Create or generate a new API Key (and secret if shown); copy the key immediately. 4) For V1 S2S flows, use client_id and client_secret to construct an id_token and call POST /s2s/v1.0/client/auth to receive an access_token. For V2 simply use the API Key as a Bearer token.

2. Add them to .dlt/secrets.toml

[sources.perfect_corp_source] api_key = "YOUR_PERFECTCORP_API_KEY"

dlt reads this automatically at runtime — never hardcode tokens in your pipeline script. For production environments, see setting up credentials with dlt for environment variable and vault-based options.


How do I set up and run the pipeline?

Set up a virtual environment and install dlt:

uv venv && source .venv/bin/activate uv pip install "dlt[workspace]"

1. Install the dlt AI Workbench:

dlt ai init --agent <your-agent> # <agent>: claude | cursor | codex

This installs project rules, a secrets management skill, appropriate ignore files, and configures the dlt MCP server for your agent. Learn more →

2. Install the rest-api-pipeline toolkit:

dlt ai toolkit rest-api-pipeline install

This loads the skills and context about dlt the agent uses to build the pipeline iteratively, efficiently, and safely. The agent uses MCP tools to inspect credentials — it never needs to read your secrets.toml directly. Learn more →

3. Start LLM-assisted coding:

Use /find-source to load data from the Perfect Corp API into DuckDB.

The rest-api-pipeline toolkit takes over from here — it reads relevant API documentation, presents you with options for which endpoints to load, and follows a structured workflow to scaffold, debug, and validate the pipeline step by step.

4. Run the pipeline:

python perfect_corp_pipeline.py

If everything is configured correctly, you'll see output like this:

Pipeline perfect_corp_pipeline load step completed in 0.26 seconds 1 load package(s) were loaded to destination duckdb and into dataset perfect_corp_data The duckdb destination used duckdb:/perfect_corp.duckdb location to store data Load package 1749667187.541553 is LOADED and contains no failed jobs

Inspect your pipeline and data:

dlt pipeline perfect_corp_pipeline show

This opens the Pipeline Dashboard where you can verify pipeline state, load metrics, schema (tables, columns, types), and query the loaded data directly.


Python pipeline example

This example loads get_task and file_upload from the Perfect Corp API into DuckDB. It mirrors the endpoint and data selector configuration from the table above:

import dlt from dlt.sources.rest_api import RESTAPIConfig, rest_api_resources @dlt.source def perfect_corp_source(api_key=dlt.secrets.value): config: RESTAPIConfig = { "client": { "base_url": "https://yce-api-01.perfectcorp.com", "auth": { "type": "bearer", "token": api_key, }, }, "resources": [ {"name": "get_task", "endpoint": {"path": "s2s/v2.0/task/{feature}", "data_selector": "data"}}, {"name": "file_upload", "endpoint": {"path": "s2s/v2.0/file/{feature}", "data_selector": "result.files"}} ], } yield from rest_api_resources(config) def get_data() -> None: pipeline = dlt.pipeline( pipeline_name="perfect_corp_pipeline", destination="duckdb", dataset_name="perfect_corp_data", ) load_info = pipeline.run(perfect_corp_source()) print(load_info)

To add more endpoints, append entries from the resource table to the "resources" list using the same name, path, and data_selector pattern.


How do I query the loaded data?

Once the pipeline runs, dlt creates one table per resource. You can query with Python or SQL.

Python (pandas DataFrame):

import dlt data = dlt.pipeline("perfect_corp_pipeline").dataset() sessions_df = data.get_task.df() print(sessions_df.head())

SQL (DuckDB example):

SELECT * FROM perfect_corp_data.get_task LIMIT 10;

In a marimo or Jupyter notebook:

import dlt data = dlt.pipeline("perfect_corp_pipeline").dataset() data.get_task.df().head()

See how to explore your data in marimo Notebooks and how to query your data in Python with dataset.


What destinations can I load Perfect Corp data to?

dlt supports loading into any of these destinations — only the destination parameter changes:

DestinationExample value
DuckDB (local, default)"duckdb"
PostgreSQL"postgres"
BigQuery"bigquery"
Snowflake"snowflake"
Redshift"redshift"
Databricks"databricks"
Filesystem (S3, GCS, Azure)"filesystem"

Change the destination in dlt.pipeline(destination="snowflake") and add credentials in .dlt/secrets.toml. See the full destinations list.


Troubleshooting

Authentication failures

If you receive 401/InvalidAccessToken or "Bearer Authentication 400 Error", ensure the Authorization header is exactly: Authorization: Bearer YOUR_API_KEY (no angle brackets, include the "Bearer " prefix). For v1 server flows, ensure id_token is constructed correctly and exchange it for access_token; access_tokens expire (reported 2 hours). Save client_secret when generated — it cannot be shown again.

Rate limiting & credits

APIs are quota/credit‑based per account/plan. Requests that generate images consume credits when tasks complete successfully. If you hit limits, contact Perfect Corp customer success or upgrade plan. Monitor 4xx/429 responses for rate‑limit signals.

Task polling and async results

AI endpoints are asynchronous. POST returns a task_id; poll GET /s2s/v2.0/task/{feature} or GET /s2s/v2.0/task/{task_id} until data.task_status == "success" or "error". Successful responses include data.results (or result with url) containing download_url(s). Error responses keep HTTP 200 with data.task_status == "error" and error/error_message fields — handle these specially.

Pagination and large integers

List endpoints may return arrays under result.files or result; IDs can be very large — treat IDs as strings to avoid JS number precision loss.

Ensure that the API key is valid to avoid 401 Unauthorized errors. Also, verify endpoint paths and parameters to avoid 404 Not Found errors.


Next steps

Continue your data engineering journey with the other toolkits of the dltHub AI Workbench:

  • data-exploration — Build custom notebooks, charts, and dashboards for deeper analysis with marimo notebooks.
  • dlthub-runtime — Deploy, schedule, and monitor your pipeline in production.
dlt ai toolkit data-exploration install dlt ai toolkit dlthub-runtime install

Was this page helpful?

Community Hub

Need more dlt context for Perfect Corp?

Request dlt skills, commands, AGENT.md files, and AI-native context.