Skip to main content

pyMetadataEditor

A Python client for Metadata Editor: create, edit, and manage metadata for microdata, indicators, geospatial data, documents, scripts, images, and videos.

Installation

This project uses Poetry:

pip install poetry
cd pymetadataeditor
poetry install

The LLM-assisted metadata features (OpenAI, tiktoken, markitdown) are optional: poetry install --extras llm, or pip install "pymetadataeditor[llm]".

For development (pytest, pre-commit):

poetry install --with dev
poetry run pre-commit install

Quick start

from pymetadataeditor import MetadataEditor
import os

me = MetadataEditor(
    api_url=os.getenv("METADATA_API_URL"),   # e.g. https://host/index.php/api
    api_key=os.getenv("METADATA_API_KEY"),
    verify_ssl=False,  # set True when SSL is verified on your server
)

List projects

list returns one page (summary fields, no metadata) plus the server total:

response = me.projects.list(limit=10, metadata_type="indicator", keywords="literacy rate")
print(response["total"])
for project in response["projects"]:
    print(project["id"], project["type"], project["title"])

Filters: keywords, metadata_type, collection (+ exclude_collections=True), tag, ownership, users, created_by, changed_by, date_start / date_end (last changed), sort_by. List filters accept Python lists. me.projects.facets() returns the available types, collections and their counts.

To go through every matching project, iterate instead of loading everything at once:

for project in me.projects.iter_all(metadata_type="indicator", page_size=500):
    ...

me.projects.count(collection=12)                # just the number
me.projects.list_all(metadata_type="table")     # everything in memory: {"projects": [...], "total": n}

iter_all pages in id order, so projects edited while you iterate are neither skipped nor repeated. Other large listings have the same pattern: me.collections.iter_projects, me.jobs.iter_all, me.codelists.iter_all, me.codelists.iter_codes, me.data_structures.iter_all, me.indicators.iter_data_rows.

Create a project (template-aware)

demo_name = "my_indicator_demo"
metadata = {
    "idno": demo_name,
    "series_description": {
        "idno": demo_name,
        "name": "Version 1",
    },
}

project_id = me.metadata.create(
    metadata,
    metadata_type_or_template_uid="indicator",
)

Read metadata back

model = me.metadata.get(project_id, output_mode="pydantic")
model.pretty_print()

API overview (v2)

Thin clients return raw API JSON (dict). Workflow helpers on me.metadata handle validation and Pydantic/Excel conversion.

Client Role
me.projects List, get, create, update, patch, delete projects
me.metadata Template-aware create, update, get (dict / pydantic / excel)
me.collections Collections and membership
me.templates Template CRUD
me.resources External resources (reports, questionnaires, files)
me.jobs Background jobs (publish to NADA, indicator data import, poll, list)
me.publish Publish metadata and indicator DSD/data to NADA (synchronous)
me.uploads Resumable (chunked) file uploads
me.data_structures Data structure (DSD) registry: structures, components, CSV/JSON/SDMX import, export
me.codelists Codelist registry: codelists, codes, translations, import/export
me.indicators Indicator projects: bind a DSD, load/export data, chart data, notes, publish
me.api Generic get / post / put / delete for any path

API errors raise ApiError (status_code, message, errors), a subclass of requests HTTPError.

Methods still on me directly include make_metadata_outline, read_metadata_from_excel, draft_metadata_from_files, and related helpers.

Breaking change: v1 flat methods (list_projects, create_project_log, …) were removed. See legacy-migration.MD.

Direct HTTP (me.api)

For endpoints without a typed wrapper yet:

me.api.get("/editor", params={"limit": 5})
me.api.post("/collections/add_projects", json={"collections": [1], "id_format": "id", "projects": [101]})

POST body styles:

  • json={...} — JSON API payloads
  • data={...} — form fields
  • data={...} + files={...} — multipart uploads

Many deletes use POST in restricted networks (e.g. me.projects.delete, me.collections.delete), not HTTP DELETE.

Publish to NADA

me.publish.* publishes now and returns NADA's answers; me.jobs.queue_* methods queue a job on the editor's worker and return its uuid (pass wait=True to block until it finishes). Both take the same steps:

options = {"overwrite": "yes", "published": 1, "access_policy": "licensed", "repositoryid": "MY_COLLECTION"}

# now: {"results": {...}, "errors": {...}} per step
me.publish.project(123, catalog_connection_id=1, publish_thumbnail=False, options=options)

# background job
job = me.jobs.queue_publish_to_nada(123, catalog_connection_id=1, publish_thumbnail=False, options=options)
result = me.jobs.wait(job["uuid"], timeout_seconds=3600)

Single steps: me.publish.metadata, indicator_data, thumbnail, resources, resource, delete_nada_resources.

Step-by-step notebook: demo/publish_to_nada_jobs.ipynb.

Guides

Contributing

Poetry troubleshooting (Windows)

If NumPy or path-length errors occur:

  1. Enable long paths in Windows, or
  2. Run poetry config virtualenvs.in-project true then poetry install

Tests

poetry run pytest tests/test_interface.py -q

API documentation

python make_docs.py             # demo notebooks -> docs/*.md, and docs/API_Reference.md
python make_docs.py --api-only  # only docs/API_Reference.md

Notes

Parts of this codebase were written with the assistance of ChatGPT, in keeping with World Bank Group practice.

Metadata

Release files for pymetadataeditor 0.5.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 pymetadataeditor 0.5.0
File Size Uploaded Provenance Actions
pymetadataeditor-0.5.0.tar.gz 60.3 kB With provenance Details for pymetadataeditor-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pymetadataeditor 0.5.0
File Interpreter ABI Platform Actions
pymetadataeditor-0.5.0-py3-none-any.whl Python 3 none any Details for pymetadataeditor-0.5.0-py3-none-any.whl

Total release size: 129.7 kB

Release files / pymetadataeditor-0.5.0.tar.gz

Download URL pymetadataeditor-0.5.0.tar.gz
Size 60.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d1868861ad5c7b2bbe5bb53c6b595956e164d3ad4235a1211e33bd2b435421d1
BLAKE2b-256 checksum
How to use checksums
17d1e2dd6905bd6f158acfcd48c1da97ffd55a527894e7f394678d4152129b8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / pymetadataeditor-0.5.0-py3-none-any.whl

Download URL pymetadataeditor-0.5.0-py3-none-any.whl
Size 69.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3ba9e340e5dce49ea6797cc29aa7c9097847054ca33056739506a298cfc93f40
BLAKE2b-256 checksum
How to use checksums
6e8715bbb0c4068449a3c6f1ddb93fcf2fe81ecbdf00cec14a446dc6ea98b159
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Security for pymetadataeditor 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pymetadataeditor-0.5.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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