Articles¶
Articles are scientific publications and similar long-form sources in the WiseFood
catalog. They are URN-backed (urn:article:<slug>) and reached through
client.articles.
What it is¶
Entity class |
|
Collection |
|
Endpoint |
|
Identifier |
URN ( |
Quick example¶
import os
from wisefood import DataClient, Credentials
client = DataClient(
os.environ["WISEFOOD_API_URL"],
Credentials(username=os.environ["WISEFOOD_USERNAME"],
password=os.environ["WISEFOOD_PASSWORD"]),
)
article = client.articles["mediterranean-diet-review-2021"]
print(article.title)
print(article.doi, "·", article.publication_year)
for t in article.key_takeaways:
print("-", t)
Field reference¶
Commonly used fields (all are accessors over entity.data; read-only ones are managed by
the server):
Field |
Type |
Notes |
|---|---|---|
|
|
Read-only. |
|
|
|
|
|
|
|
|
Defaults to |
|
|
Defaults to |
|
|
|
|
|
|
|
|
Digital Object Identifier. |
|
|
|
|
|
|
|
|
|
|
|
Full text, when available. |
|
|
Journal / conference. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Machine-generated. |
|
|
|
|
|
|
|
|
|
|
|
Machine-generated. |
|
|
|
|
|
|
|
|
Read-only. |
|
|
Free-form extra metadata. |
There are additional annotation/targeting fields (reader_group, age_group,
population_group, geographic_context, biological_model, study_type,
hard_exclusion_flags, annotation_confidence, category, ai_category,
embedded_at) — inspect any record with article.show() to see everything present.
CRUD walkthrough¶
# Create
article = client.articles.create(
title="A randomized trial of the Mediterranean diet",
doi="10.1234/example",
authors=["A. Researcher", "B. Scientist"],
publication_year=2021,
)
# Update — auto-syncs immediately (sync=True by default)
article.status = "active"
article.tags = ["cardiology", "nutrition"]
# Batch several edits into one request
article.sync = False
article.abstract = "We compared ..."
article.open_access = True
article.save(only_dirty=True)
# Reload from the server
article.refresh()
# Delete
article.delete()
Search¶
hits = client.articles.search(
"mediterranean diet cardiovascular",
fq=['open_access:true'],
sort="citation_count desc",
limit=10,
highlight=True,
highlight_fields=["abstract"],
)
for a in hits:
print(a.citation_count, a.title)
See Search for the full parameter list.
AI enhancement¶
Ask a server-side agent to enrich an article (e.g. generate takeaways or tags). The updated entity is returned:
enhanced = client.articles.enhance("summarizer", identifier="a-randomized-trial-...")
print(enhanced.ai_key_takeaways)
# Or in place, on a loaded entity:
article.enhance_self(agent="summarizer")
Attached files¶
Articles can carry artifacts (e.g. the source PDF):
for art in article.artifacts:
art.download_to(f"./downloads/{art.title}.pdf")
See Artifacts.
Gotchas¶
id,creator,created_at,updated_atare read-only — assigning raisesAttributeError.With the default
sync=True, every attribute assignment is a separate PATCH. Setsync=Falseand callsave(only_dirty=True)to batch related edits.keywords,topics,authors,tagsdefault to empty lists — reassign the whole list to change them.