The PyEuropePMC QueryBuilder now uses a structured metadata dictionary (FIELD_METADATA) that maps user-friendly field names to their API field names and human-readable descriptions.
FIELD_METADATA: dict[str, tuple[str, str]] = {
"field_name": ("API_NAME", "Human-readable description"),
...
}
{
"title": ("TITLE", "Article or book title"),
"author": ("AUTH", "Author name (full or abbreviated form)"),
"auth": ("AUTH", "Author name (API abbreviated form)"),
"disease": ("DISEASE", "Disease or condition terms (text-mined)"),
"open_access": ("OPEN_ACCESS", "Open access status (y/n)"),
}
Each field is mapped to its uppercase API field name (as returned by the Europe PMC API).
Multiple user-friendly names can map to the same API field:
author and auth both map to AUTHaffiliation and aff both map to AFFlanguage and lang both map to LANGchemical and chem both map to CHEMEvery field includes a description explaining its purpose, making it easier for developers to understand what each field does.
Most API fields are uppercase (TITLE, ABSTRACT, AUTH), but three internal fields use lowercase:
_version_ - Document version (internal use)text_hl - Highlighted text snippets (internal use)text_synonyms - Text synonym expansion (internal use)get_field_info(field: str) -> tuple[str, str]Get API field name and description for a given field.
from pyeuropepmc.query_builder import get_field_info
# Get info for a field
api_name, description = get_field_info("author")
print(f"{api_name}: {description}")
# Output: AUTH: Author name (full or abbreviated form)
get_available_fields() -> list[str]Fetch the current list of searchable fields from the Europe PMC API.
from pyeuropepmc.query_builder import get_available_fields
fields = get_available_fields()
print(f"Available fields: {len(fields)}")
# Output: Available fields: 142
validate_field_coverage(verbose: bool = False) -> dictCheck if local field definitions cover all fields from the API.
from pyeuropepmc.query_builder import validate_field_coverage
result = validate_field_coverage(verbose=True)
if result['up_to_date']:
print("✅ All API fields are covered!")
The metadata includes fields across multiple categories:
The field metadata is validated against the live Europe PMC API to ensure:
To check field coverage:
# Quick check
python scripts/check_fields.py
# Verbose output
python scripts/check_fields.py --verbose
# Quiet mode (exit code only)
python scripts/check_fields.py --quiet
FieldType = Literal["title", "abstract", "author", ...]
FIELD_METADATA: dict[str, tuple[str, str]] = {
"title": ("TITLE", "Article or book title"),
"abstract": ("ABSTRACT", "Article abstract text"),
"author": ("AUTH", "Author name (full or abbreviated form)"),
...
}
# FieldType still exists for type hints
FieldType = Literal["title", "abstract", "author", ...]