Skip to main content

English | 中文

APICORE娘-圆角图标

APICORE_Python

License Python Version Version

APICORE configuration file format specification access framework for Python

Main Repo

APICORE

High-performance APICORE parser and validator for APICORE v1, v2.0, and v2.1.

A collaboration by Little Tree Studio and SRON-org.

Features

  • Import name is apicore, while the published package name is APICORE_Python.
  • Uses orjson for fast JSON decoding.
  • Uses ruamel.yaml with ruamel.yaml.clib for YAML decoding.
  • Keeps msgspec for fast TOML decoding.
  • Supports APICORE v1, v2.0, and v2.1 with a single API.
  • Retains APICORE v2.0 semantics when APICORE_version is omitted, while inferring v2.1 when the document uses v2.1-only fields or localized values.
  • Preserves custom v2 parameter fields in Parameter.extra.
  • Supports v2.1 metadata, $schema, i18n UI strings, request body types, polling, and conditional parameters.
  • Supports v2.1 enum options with a scalar default while retaining the v2.0 friendly_value form.
  • Supports image, audio, video, text, Markdown, and file outputs through response.media.
  • Exposes response.preferred_media, which prefers v2.1 media and adapts legacy image automatically.
  • Keeps the published package focused on parsing and validation; no CLI or GUI modules are installed.
  • Provides repository-only CLI and desktop validator tools under tools/.
  • Exposes typed document models plus APICoreError, ParseError, and ValidationError for precise error handling.

Install

uv add APICORE_Python

or

pip install APICORE_Python

Installation provides the apicore Python library only. It does not install apicore-validate or apicore-gui commands.

Quick Start

from apicore import __version__, load, loads

print(__version__)

document = load("example.api.yaml")
print(document.apicore_version)

inline = loads(
    """
friendly_name: Demo
link: https://api.example.com/v2/generate
func: POST
APICORE_version: '2.1'
parameters:
  - name: style
    type: enum
    friendly_name:
      zh-CN: 风格
      en-US: Style
    options: [realistic, anime]
    friendly_options: [Realistic, Anime]
    value: realistic
response:
  media:
    type: image
    content_type: URL
    path: data.output.url
""",
    format="yaml",
)

forced_v1 = loads(
    """
{
	"friendly_name": "Legacy",
	"link": "https://api.example.com/legacy",
	"func": "POST",
	"APICORE_version": "1.0",
	"parameters": [],
	"response": {
		"image": {
			"content_type": "URL",
			"path": "data.image.url"
		}
	}
}
""",
    version="v1",
)

Repository CLI Tool

From a repository checkout:

uv sync
uv run python tools/cli.py path/to/config.api.yaml
uv run python tools/cli.py path/to/config.api.json --version v1
uv run python tools/cli.py path/to/config.api.toml --version 2.1

Repository Desktop Tool

uv sync
uv run python tools/gui.py

On Windows, start it without a console after synchronization with .venv\Scripts\pythonw.exe tools\gui.py. Some Linux distributions require the system python3-tk package.

The GUI validates multiple APICORE documents and displays v2.1 metadata, localized parameters, media mappings, request bodies, polling, configs, and handlers. Secret values are masked, and run handlers are marked as high risk.

Error Handling

from apicore import load
from apicore.errors import APICoreError, ParseError, ValidationError

try:
    doc = load("example.api.yaml")
except ParseError as exc:
    print(f"Syntax error: {exc}")
except ValidationError as exc:
    print(f"Schema error: {exc}")
except APICoreError as exc:
    print(f"APICORE error: {exc}")

Benchmark

uv run python benchmarks/parse_benchmark.py

Release Workflow

uv sync --all-groups
uv run pytest -q
uv build
uv run --with twine twine check dist/*

Detailed release steps are in RELEASING.md.

Contribution setup, coding expectations, validation commands, and pull request requirements are documented in CONTRIBUTING.md.

Documentation

Wiki documentation is published manually to the GitHub Wiki. The local docs/ upload sources are intentionally ignored by Git. The APICORE v2.1 specification and JSON Schema are maintained in APICORE-2.

See SECURITY.md for the run action trust boundary, safe host integration guidance, and dependency security practices. See DISCLAIMER.md for execution responsibility and liability information.

Release files for APICORE_Python 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for APICORE_Python 2.1.0
File Size Uploaded
apicore_python-2.1.0.tar.gz 14.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for APICORE_Python 2.1.0
File Interpreter ABI Platform
apicore_python-2.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 31.0 kB

Release files / apicore_python-2.1.0.tar.gz

Download URL apicore_python-2.1.0.tar.gz
Size 14.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b0db4a672382c227d0e94e2cf1332964318b97cdc90d324ff8a84bf0aa0a3b74
BLAKE2b-256 checksum
How to use checksums
171a52d8b0922c6ab40c6e3346c6cf7e0ea820f46baf58650ecb9a002b5947f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / apicore_python-2.1.0-py3-none-any.whl

Download URL apicore_python-2.1.0-py3-none-any.whl
Size 16.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3483afc3a45b59b9fc6c33cf0db1542132e9a69788843af96eb7ab3389d2da29
BLAKE2b-256 checksum
How to use checksums
722a867a2d4900c94854c8d9d4b72c5284be4abd2c1f0bfcac2dbb989c4c23a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page