API Reference¶
Auto-generated from the package docstrings.
Clients¶
A compact, robust HTTP client for the Wisefood Data API.
- class wisefood.client.Credentials(username=None, password=None, client_id=None, client_secret=None)[source]¶
Bases:
objectEither user credentials (username & password) OR client credentials (client_id & client_secret) must be provided. They are mutually exclusive.
- Parameters:
- class wisefood.client.DataClient(base_url, credentials, *, api_prefix='/api/v1', verify_tls=True, default_timeout=30.0, pool_connections=3, pool_maxsize=3)[source]¶
Bases:
objectHTTP client for the Wisefood Data API with automatic authentication and resource proxies.
This client handles all communication with the Wisefood Data API, providing: - Automatic authentication using username/password or client credentials - Token refresh when expired - Connection pooling and retry logic - Clean endpoint URL construction - Resource-specific proxies (articles, artifacts, guides, guidelines, textbooks, textbook passages, fctables) for convenient data access
- Parameters:
base_url (str) – Base URL of the Wisefood Data API (e.g., ‘https://data.wisefood.com’)
credentials (Credentials) – Credentials object containing either username/password or client_id/client_secret
api_prefix (str) – API version prefix (default: ‘/api/v1’)
verify_tls (bool) – Whether to verify SSL/TLS certificates (default: True)
default_timeout (float) – Default request timeout in seconds (default: 30.0)
pool_connections (int) – Number of connection pools to cache (default: 3)
pool_maxsize (int) – Maximum number of connections to save in the pool (default: 3)
- articles¶
ArticlesProxy for accessing scientific articles
- artifacts¶
ArtifactsProxy for accessing artifact files and metadata
- guides¶
GuidesProxy for accessing dietary guides
- guidelines¶
GuidelinesProxy for accessing extracted guide rules
- textbooks¶
TextbooksProxy for accessing textbooks
- textbook_passages¶
TextbookPassagesProxy for accessing extracted textbook passages
- fctables¶
FCTablesProxy for accessing food composition tables
Example
>>> creds = Credentials(username='user@example.com', password='secret') >>> client = DataClient('https://data.wisefood.com', creds) >>> # Access resources through proxies >>> article = client.articles.get(123) >>> # Or make direct API calls >>> response = client.GET('articles', 'search', q='nutrition')
- DELETE(*parts, **params)[source]¶
Convenient DELETE request with path parts as separate arguments.
- Parameters:
*parts – URL path segments that will be joined with ‘/’
**params – Query parameters as keyword arguments
- Returns:
requests.Response object
- Return type:
Example
>>> response = client.DELETE('articles', '123') # Equivalent to: DELETE /api/v1/articles/123
- GET(*parts, **params)[source]¶
Convenient GET request with path parts as separate arguments.
- Parameters:
*parts – URL path segments that will be joined with ‘/’
**params – Query parameters as keyword arguments
- Returns:
requests.Response object
- Return type:
Example
>>> response = client.GET('articles', 'search', q='nutrition', limit=10) # Equivalent to: GET /api/v1/articles/search?q=nutrition&limit=10
- PATCH(*parts, params=None, **json)[source]¶
Convenient PATCH request with path parts and JSON body.
- Parameters:
*parts – URL path segments that will be joined with ‘/’
params – Optional query parameters
**json – JSON body fields as keyword arguments
- Returns:
requests.Response object
- Return type:
Example
>>> response = client.PATCH('articles', '123', status='published') # Equivalent to: PATCH /api/v1/articles/123 with JSON body
- POST(*parts, params=None, **json)[source]¶
Convenient POST request with path parts and JSON body.
- Parameters:
*parts – URL path segments that will be joined with ‘/’
params – Optional query parameters
**json – JSON body fields as keyword arguments
- Returns:
requests.Response object
- Return type:
Example
>>> response = client.POST('articles', title='Study', doi='10.1234/example') # Equivalent to: POST /api/v1/articles with JSON body
- PUT(*parts, params=None, **json)[source]¶
Convenient PUT request with path parts and JSON body.
- Parameters:
*parts – URL path segments that will be joined with ‘/’
params – Optional query parameters
**json – JSON body fields as keyword arguments
- Returns:
requests.Response object
- Return type:
Example
>>> response = client.PUT('articles', '123', title='Updated Study') # Equivalent to: PUT /api/v1/articles/123 with JSON body
- property api_base: str¶
Get the full API base URL combining base_url and api_prefix.
- Returns:
//data.wisefood.com/api/v1’)
- Return type:
Complete API base URL (e.g., ‘https
- authenticate()[source]¶
Authenticate with the API and store bearer token with expiry timestamp.
Uses either username/password (user credentials) or client_id/client_secret (machine-to-machine credentials) depending on the credentials type.
The token is stored internally with an automatic safety margin before expiry to ensure requests don’t fail due to token expiration.
- Raises:
WisefoodError – If authentication fails or response is invalid
- Return type:
None
- delete(endpoint, **kwargs)[source]¶
Perform a DELETE request to the specified endpoint.
- Parameters:
- Returns:
requests.Response object
- Return type:
Example
>>> response = client.delete('articles/123')
- endpoint(endpoint)[source]¶
Construct absolute URL for an API endpoint.
- Parameters:
endpoint (str) – Relative endpoint path (e.g., ‘articles/123’ or ‘/articles/123’)
- Returns:
//data.wisefood.com/api/v1/articles/123’)
- Return type:
Complete URL (e.g., ‘https
- get(endpoint, **params)[source]¶
Perform a GET request to the specified endpoint.
- Parameters:
- Returns:
requests.Response object
- Return type:
Example
>>> response = client.get('articles/search', q='nutrition', limit=10)
- patch(endpoint, **kwargs)[source]¶
Perform a PATCH request to the specified endpoint.
- Parameters:
- Returns:
requests.Response object
- Return type:
Example
>>> response = client.patch('articles/123', json={'status': 'published'})
- ping()[source]¶
Check authentication status and get user/client information.
- Returns:
Dictionary containing authentication status and user/client details
- Return type:
Example
>>> status = client.ping() >>> print(status.get('username'))
- post(endpoint, **kwargs)[source]¶
Perform a POST request to the specified endpoint.
- Parameters:
- Returns:
requests.Response object
- Return type:
Example
>>> response = client.post('articles', json={'title': 'Study', 'doi': '10.1234/example'})
- put(endpoint, **kwargs)[source]¶
Perform a PUT request to the specified endpoint.
- Parameters:
- Returns:
requests.Response object
- Return type:
Example
>>> response = client.put('articles/123', json={'title': 'Updated Study'})
- request(method, endpoint, *, auth=True, timeout=None, headers=None, params=None, **kwargs)[source]¶
Low-level HTTP request method with automatic authentication.
- Parameters:
method (str) – HTTP method (GET, POST, PUT, PATCH, DELETE)
endpoint (str) – API endpoint path relative to api_base
auth – Whether to include authentication token (default: True)
timeout – Request timeout in seconds (uses default_timeout if None)
headers – Additional HTTP headers to include
params – Query parameters for the request
**kwargs – Additional arguments passed to requests (e.g., json, data)
- Returns:
requests.Response object
- Raises:
ValueError – If GET/DELETE request includes a request body
WisefoodError – If the API returns an error response
Example
>>> response = client.request('GET', 'articles/123') >>> response = client.request('POST', 'articles', json={'title': 'Study'})
- exception wisefood.client.WisefoodError[source]¶
Bases:
RuntimeError
A compact, robust HTTP client for the Wisefood API (systemic operations).
- class wisefood.api_client.Client(base_url, credentials, *, api_prefix='/api/v1', verify_tls=True, default_timeout=30.0, pool_connections=3, pool_maxsize=10)[source]¶
Bases:
objectHTTP client for the Wisefood API with automatic authentication and token management.
This client handles all communication with the Wisefood API, including: - Automatic authentication using username/password or client credentials - Token refresh when expired - Connection pooling and retry logic - Clean endpoint URL construction
- Parameters:
base_url (str) – Base URL of the Wisefood API (e.g., ‘https://api.wisefood.com’)
credentials (Credentials) – Credentials object containing either username/password or client_id/client_secret
api_prefix (str) – API version prefix (default: ‘/api/v1’)
verify_tls (bool) – Whether to verify SSL/TLS certificates (default: True)
default_timeout (float) – Default request timeout in seconds (default: 30.0)
pool_connections (int) – Number of connection pools to cache (default: 3)
pool_maxsize (int) – Maximum number of connections to save in the pool (default: 10)
Example
>>> creds = Credentials(username='user@example.com', password='secret') >>> client = Client('https://api.wisefood.com', creds) >>> response = client.GET('foods', 'search', q='apple') >>> foods = response.json()
- DELETE(*parts, **params)[source]¶
Convenient DELETE request with path parts as separate arguments.
- Parameters:
*parts – URL path segments that will be joined with ‘/’
**params – Query parameters as keyword arguments
- Returns:
requests.Response object
- Return type:
Example
>>> response = client.DELETE('foods', '123') # Equivalent to: DELETE /api/v1/foods/123
- GET(*parts, **params)[source]¶
Convenient GET request with path parts as separate arguments.
- Parameters:
*parts – URL path segments that will be joined with ‘/’
**params – Query parameters as keyword arguments
- Returns:
requests.Response object
- Return type:
Example
>>> response = client.GET('foods', 'search', q='apple', limit=10) # Equivalent to: GET /api/v1/foods/search?q=apple&limit=10
- PATCH(*parts, params=None, **json)[source]¶
Convenient PATCH request with path parts and JSON body.
- Parameters:
*parts – URL path segments that will be joined with ‘/’
params – Optional query parameters
**json – JSON body fields as keyword arguments
- Returns:
requests.Response object
- Return type:
Example
>>> response = client.PATCH('foods', '123', calories=100) # Equivalent to: PATCH /api/v1/foods/123 with JSON body
- POST(*parts, params=None, **json)[source]¶
Convenient POST request with path parts and JSON body.
- Parameters:
*parts – URL path segments that will be joined with ‘/’
params – Optional query parameters
**json – JSON body fields as keyword arguments
- Returns:
requests.Response object
- Return type:
Example
>>> response = client.POST('foods', name='Apple', calories=95) # Equivalent to: POST /api/v1/foods with JSON body
- PUT(*parts, params=None, **json)[source]¶
Convenient PUT request with path parts and JSON body.
- Parameters:
*parts – URL path segments that will be joined with ‘/’
params – Optional query parameters
**json – JSON body fields as keyword arguments
- Returns:
requests.Response object
- Return type:
Example
>>> response = client.PUT('foods', '123', name='Green Apple') # Equivalent to: PUT /api/v1/foods/123 with JSON body
- property api_base: str¶
Get the full API base URL combining base_url and api_prefix.
- Returns:
//api.wisefood.com/api/v1’)
- Return type:
Complete API base URL (e.g., ‘https
- authenticate()[source]¶
Authenticate with the API and store bearer token with expiry timestamp.
Uses either username/password (user credentials) or client_id/client_secret (machine-to-machine credentials) depending on the credentials type.
The token is stored internally with an automatic safety margin before expiry to ensure requests don’t fail due to token expiration.
- Raises:
WisefoodError – If authentication fails or response is invalid
- Return type:
None
- delete(endpoint, **kwargs)[source]¶
Perform a DELETE request to the specified endpoint.
- Parameters:
- Returns:
requests.Response object
- Return type:
Example
>>> response = client.delete('foods/123')
- endpoint(endpoint)[source]¶
Construct absolute URL for an API endpoint.
- Parameters:
endpoint (str) – Relative endpoint path (e.g., ‘foods/123’ or ‘/foods/123’)
- Returns:
//api.wisefood.com/api/v1/foods/123’)
- Return type:
Complete URL (e.g., ‘https
- get(endpoint, **params)[source]¶
Perform a GET request to the specified endpoint.
- Parameters:
- Returns:
requests.Response object
- Return type:
Example
>>> response = client.get('foods/search', q='apple', limit=10)
- patch(endpoint, **kwargs)[source]¶
Perform a PATCH request to the specified endpoint.
- Parameters:
- Returns:
requests.Response object
- Return type:
Example
>>> response = client.patch('foods/123', json={'calories': 100})
- ping()[source]¶
Check authentication status and get user/client information.
- Returns:
Dictionary containing authentication status and user/client details
- Return type:
Example
>>> status = client.ping() >>> print(status.get('username'))
- post(endpoint, **kwargs)[source]¶
Perform a POST request to the specified endpoint.
- Parameters:
- Returns:
requests.Response object
- Return type:
Example
>>> response = client.post('foods', json={'name': 'Apple', 'calories': 95})
- put(endpoint, **kwargs)[source]¶
Perform a PUT request to the specified endpoint.
- Parameters:
- Returns:
requests.Response object
- Return type:
Example
>>> response = client.put('foods/123', json={'name': 'Green Apple'})
- request(method, endpoint, *, auth=True, timeout=None, headers=None, params=None, **kwargs)[source]¶
Low-level HTTP request method with automatic authentication.
- Parameters:
method (str) – HTTP method (GET, POST, PUT, PATCH, DELETE)
endpoint (str) – API endpoint path relative to api_base
auth – Whether to include authentication token (default: True)
timeout – Request timeout in seconds (uses default_timeout if None)
headers – Additional HTTP headers to include
params – Query parameters for the request
**kwargs – Additional arguments passed to requests (e.g., json, data)
- Returns:
requests.Response object
- Raises:
ValueError – If GET/DELETE request includes a body
WisefoodError – If the API returns an error response
Example
>>> response = client.request('GET', 'foods/123') >>> response = client.request('POST', 'foods', json={'name': 'Apple'})
- class wisefood.api_client.Credentials(username=None, password=None, client_id=None, client_secret=None)[source]¶
Bases:
objectEither user credentials (username & password) OR client credentials (client_id & client_secret) must be provided. They are mutually exclusive.
- Parameters:
- exception wisefood.api_client.WisefoodError[source]¶
Bases:
RuntimeError
Entities & Proxies¶
- class wisefood.entities.base.BaseCollectionProxy(client)[source]¶
Bases:
objectIndexable / sliceable view over a collection of entities.
- The list endpoint is expected to return either:
{“result”: [“urn:…”,”urn:…”, …]}
{“result”: [“uuid-…”,”uuid-…”, …]}
{“result”: [{“urn”: “…”, …}, …]}
{“result”: [{“id”: “…”, …}, …]}
- Parameters:
client (DataClient)
- ENTITY_CLS¶
alias of
BaseEntity
- create(*, urn=None, identifier=None, **fields)[source]¶
Create a new entity through the proxy and return its proxy object.
Keeps the cached index in sync when it has already been populated.
- Parameters:
- Return type:
- enhance(agent, *, urn=None, identifier=None, **fields)[source]¶
Enhance an existing entity through the proxy and return its proxy object.
Keeps the cached index in sync when it has already been populated.
- Parameters:
- Return type:
- get(identifier, *, lazy=False)[source]¶
Fetch a single entity by identifier.
- Parameters:
- Return type:
- class wisefood.entities.base.BaseEntity(client, data=<factory>, sync=True, _dirty_fields=<factory>)[source]¶
Bases:
objectLightweight proxy for a single API entity.
- Subclasses must define:
ENDPOINT (e.g. “articles”)
IDENTIFIER_FIELD (e.g. “urn” or “id”)
URN_PREFIX / IDENTIFIER_PREFIX for URN-backed entities
- Parameters:
client (DataClient)
data (Dict[str, Any])
sync (bool)
_dirty_fields (Set[str])
- property artifacts¶
Return a parent-bound artifacts proxy for URN-backed entities.
- client: DataClient¶
- classmethod create(client, *, urn=None, identifier=None, **fields)[source]¶
Create a new entity and return a proxy for it.
- Parameters:
client (DataClient)
urn (Optional[str])
identifier (Optional[str])
fields (Any)
- Return type:
- classmethod enhance(client, *, urn=None, identifier=None, agent, **fields)[source]¶
Enhance an existing entity and return a proxy for it.
- Parameters:
client (DataClient)
urn (Optional[str])
identifier (Optional[str])
agent (str)
fields (Any)
- Return type:
- enhance_self(*, agent, **fields)[source]¶
Enhance this entity using an AI agent and update its data.
- classmethod get(client, identifier)[source]¶
Fetch a single entity by identifier and return a proxy.
- Parameters:
client (DataClient)
identifier (str)
- Return type:
- class wisefood.entities.base.Field(key=None, *, default=None, default_factory=None, read_only=False)[source]¶
Bases:
Generic[T]Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- Parameters:
- class wisefood.entities.articles.Article(client, data=<factory>, sync=True, _dirty_fields=<factory>)[source]¶
Bases:
BaseEntitySchema for /articles entities.
All attributes here are thin accessors over self.data.
- Parameters:
client (DataClient)
data (Dict[str, Any])
sync (bool)
_dirty_fields (Set[str])
- ENDPOINT = 'articles'¶
- URN_PREFIX = 'urn:article:'¶
- abstract: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- age_group: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- ai_category: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- ai_key_takeaways: List[str]¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- ai_tags: List[str]¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- annotation_confidence: int | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- authors: List[str]¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- biological_model: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- category: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- citation_count: int | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- content: str¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- created_at: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- creator: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- description: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- doi: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- embedded_at: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- external_id: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- extras: Dict[str, Any]¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- geographic_context: Dict[str, Any] | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- hard_exclusion_flags: List[str]¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- id: str¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- influential_citation_count: int | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- key_takeaways: List[str]¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- keywords: List[str]¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- language: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- license: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- open_access: bool | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- organization_urn: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- population_group: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- publication_year: int | str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- reader_group: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- reference_count: int | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- region: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- status: str¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- study_type: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- tags: List[str]¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- title: str¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- topics: List[str]¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- type: str¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- updated_at: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- class wisefood.entities.articles.ArticlesProxy(client)[source]¶
Bases:
BaseCollectionProxy- Parameters:
client (DataClient)
- class wisefood.entities.guides.Guide(client, data=<factory>, sync=True, _dirty_fields=<factory>)[source]¶
Bases:
BaseEntity- Parameters:
client (DataClient)
data (Dict[str, Any])
sync (bool)
_dirty_fields (Set[str])
- ENDPOINT = 'guides'¶
- IMMUTABLE_FIELDS = {'created_at', 'creator', 'id', 'type', 'updated_at', 'urn'}¶
- URN_PREFIX = 'urn:guide:'¶
- applicability_end_date: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- applicability_start_date: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- applicability_status: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- artifact_records: List[Dict[str, Any]]¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- audience: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- content: str¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- created_at: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- creator: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- description: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- document_type: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- evidence_basis: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- graphical_model: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- guideline_ids: List[str]¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- property guidelines¶
- id: str¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- identifiers: List[Dict[str, Any]]¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- issuing_authority: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- language: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- legal_status: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- license: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- notes: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- organization_urn: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- property page¶
- page_count: int | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- publication_date: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- publication_year: int | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- region: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- responsible_ministry: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- review_status: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- revision: Dict[str, Any] | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- short_title: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- status: str¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- tags: List[str]¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- target_audiences: List[str]¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- title: str¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- topic: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- type: str¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- updated_at: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- url: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- class wisefood.entities.guides.GuideGuidelinesProxy(client, guide_urn)[source]¶
Bases:
GuidelinesProxy- Parameters:
guide_urn (str)
- create(*, urn=None, identifier=None, **fields)[source]¶
Create a new entity through the proxy and return its proxy object.
Keeps the cached index in sync when it has already been populated.
- Parameters:
- Return type:
- class wisefood.entities.guides.GuidePageProxy(guidelines)[source]¶
Bases:
object- Parameters:
guidelines (GuideGuidelinesProxy)
- class wisefood.entities.guides.Guideline(client, data=<factory>, sync=True, _dirty_fields=<factory>)[source]¶
Bases:
BaseEntity- Parameters:
client (DataClient)
data (Dict[str, Any])
sync (bool)
_dirty_fields (Set[str])
- ENDPOINT = 'guidelines'¶
- IDENTIFIER_FIELD = 'id'¶
- IMMUTABLE_FIELDS = {'created_at', 'creator', 'guide_region', 'guide_urn', 'id', 'updated_at'}¶
- action_type: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- applicability_end_date: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- applicability_start_date: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- applicability_status: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- created_at: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- creator: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- food_groups: List[Any]¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- frequency: Any | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- guide_region: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- guide_urn: str¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- id: str¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- notes: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- page_no: int | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- quantity: Dict[str, Any] | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- review_status: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- rule_text: str¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- sequence_no: int | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- source_refs: List[Dict[str, Any]]¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- status: str¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- target_populations: List[Any]¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- title: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- updated_at: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- class wisefood.entities.guides.GuidelinesProxy(client)[source]¶
Bases:
BaseCollectionProxy- Parameters:
client (DataClient)
- class wisefood.entities.guides.GuidesProxy(client)[source]¶
Bases:
BaseCollectionProxy- Parameters:
client (DataClient)
- class wisefood.entities.textbooks.BoundTextbookPassagesProxy(client, textbook_urn, textbook=None)[source]¶
Bases:
TextbookPassagesProxy- bulk_replace(*, artifact_id=None, passages=None, page_count=None, structure_tree=None, extractor_name=None, extractor_run_id=None)[source]¶
- create(*, urn=None, identifier=None, **fields)[source]¶
Create a new entity through the proxy and return its proxy object.
Keeps the cached index in sync when it has already been populated.
- Parameters:
- Return type:
- class wisefood.entities.textbooks.Textbook(client, data=<factory>, sync=True, _dirty_fields=<factory>)[source]¶
Bases:
BaseEntity- Parameters:
client (DataClient)
data (Dict[str, Any])
sync (bool)
_dirty_fields (Set[str])
- ENDPOINT = 'textbooks'¶
- IMMUTABLE_FIELDS = {'created_at', 'creator', 'id', 'type', 'updated_at', 'urn'}¶
- URN_PREFIX = 'urn:textbook:'¶
- applicability_end_date: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- applicability_start_date: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- applicability_status: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- artifact_records: List[Dict[str, Any]]¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- audience: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- authors: List[str]¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- created_at: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- creator: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- description: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- doi: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- edition: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- editors: List[str]¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- id: str¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- isbn10: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- isbn13: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- keywords: List[str]¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- language: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- license: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- organization_urn: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- property page¶
- page_count: int | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- property passages¶
- publication_date: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- publication_year: int | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- publisher: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- region: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- review_status: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- status: str¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- property structure_tree: TextbookStructureTree¶
- structure_tree_payload: Dict[str, Any] | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- subtitle: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- tags: List[str]¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- title: str¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- topics: List[str]¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- type: str¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- updated_at: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- url: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- class wisefood.entities.textbooks.TextbookPageProxy(passages)[source]¶
Bases:
object- Parameters:
passages (BoundTextbookPassagesProxy)
- class wisefood.entities.textbooks.TextbookPassage(client, data=<factory>, sync=True, _dirty_fields=<factory>)[source]¶
Bases:
BaseEntity- Parameters:
client (DataClient)
data (Dict[str, Any])
sync (bool)
_dirty_fields (Set[str])
- ENDPOINT = 'textbook-passages'¶
- IDENTIFIER_FIELD = 'id'¶
- IMMUTABLE_FIELDS = {'artifact_id', 'created_at', 'creator', 'id', 'structure_node_id', 'structure_path', 'textbook_urn', 'updated_at'}¶
- artifact_id: str¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- char_end: int | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- char_start: int | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- created_at: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- creator: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- extractor_name: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- extractor_run_id: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- id: str¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- page_no: int | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- sequence_no: int | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- structure_node_id: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- structure_path: List[str]¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- text: str¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- class wisefood.entities.textbooks.TextbookPassagesProxy(client)[source]¶
Bases:
BaseCollectionProxy- Parameters:
client (DataClient)
- ENTITY_CLS¶
alias of
TextbookPassage
- class wisefood.entities.textbooks.TextbookStructureNode(textbook, payload)[source]¶
Bases:
object- add_chapter(*, id, title, page_start=None, page_end=None, artifact_id=None, children=None, **fields)[source]¶
- add_child(*, id, title, kind, page_start=None, page_end=None, artifact_id=None, children=None, **fields)[source]¶
- add_section(*, id, title, page_start=None, page_end=None, artifact_id=None, children=None, **fields)[source]¶
- property children: List[TextbookStructureNode]¶
- find(node_id)[source]¶
- Parameters:
node_id (str)
- Return type:
TextbookStructureNode | None
- class wisefood.entities.textbooks.TextbookStructureTree(textbook)[source]¶
Bases:
MutableMapping[str,Any]- Parameters:
textbook (Textbook)
- add_chapter(*, id, title, page_start=None, page_end=None, artifact_id=None, children=None, **fields)[source]¶
- add_root(*, id, title, kind, page_start=None, page_end=None, artifact_id=None, children=None, **fields)[source]¶
- find(node_id)[source]¶
- Parameters:
node_id (str)
- Return type:
TextbookStructureNode | None
- property root: TextbookStructureNode¶
- property roots: List[TextbookStructureNode]¶
- class wisefood.entities.textbooks.TextbooksProxy(client)[source]¶
Bases:
BaseCollectionProxy- Parameters:
client (DataClient)
- class wisefood.entities.artifacts.Artifact(client, data=<factory>, sync=True, _dirty_fields=<factory>)[source]¶
Bases:
BaseEntitySchema-backed entity for /artifacts.
Artifacts are addressed by UUIDs instead of URNs and are bound to a parent entity via parent_urn.
- Parameters:
client (DataClient)
data (Dict[str, Any])
sync (bool)
_dirty_fields (Set[str])
- ENDPOINT = 'artifacts'¶
- IDENTIFIER_FIELD = 'id'¶
- IMMUTABLE_FIELDS = {'created_at', 'creator', 'id', 'parent_urn', 'type', 'updated_at'}¶
- created_at: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- creator: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- description: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- download(*, stream=False, **kwargs)[source]¶
Download the file associated with this artifact.
- Parameters:
stream (bool)
- download_to(path, *, chunk_size=8192, **kwargs)[source]¶
Download the file associated with this artifact to a local path.
- file_s3_url: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- file_size: int | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- file_type: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- file_url: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- id: str¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- language: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- parent_urn: str¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- save(*, only_dirty=False)[source]¶
Persist local changes.
The server-side update schema requires file_type, so we include it whenever we are sending a partial artifact update.
- Parameters:
only_dirty (bool)
- Return type:
None
- title: str¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- class wisefood.entities.artifacts.ArtifactsProxy(client)[source]¶
Bases:
BaseCollectionProxy- Parameters:
client (DataClient)
- download(identifier, *, stream=False, **kwargs)[source]¶
Download the file associated with an artifact.
- class wisefood.entities.artifacts.ParentArtifactsProxy(client, parent_urn, *, parent_entity=None, embedded_records=None)[source]¶
Bases:
ArtifactsProxy
- class wisefood.entities.fctables.FCTable(client, data=<factory>, sync=True, _dirty_fields=<factory>)[source]¶
Bases:
BaseEntitySchema-backed entity for /fctables. Thin accessors over self.data. Adapted to represent a Food Composition Table (FCT).
- Parameters:
client (DataClient)
data (Dict[str, Any])
sync (bool)
_dirty_fields (Set[str])
- ENDPOINT = 'fctables'¶
- URN_PREFIX = 'urn:fctable:'¶
- abstract: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- artifact_records: List[dict]¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- authors: List[str]¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- category: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- classification_schemes: List[str]¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- compiling_institution: str¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- completeness_description: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- completeness_percent: float | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- content: str¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- created_at: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- creator: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- data_formats: List[str]¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- database_name: str¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- description: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- external_id: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- id: str¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- language: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- license: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- max_nutrients_per_item: int | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- measurement_units: List[str]¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- min_nutrients_per_item: int | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- number_of_entries: int | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- nutrient_coverage: List[str]¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- organization_urn: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- reference_portions: List[str]¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- region: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- standardization_schemes: List[str]¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- status: str¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- tags: List[str]¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- tasks_supported: List[str]¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- title: str¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- type: str¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- updated_at: str | None¶
Descriptor mapping an attribute to a key in entity.data.
Example
title: str = Field(“title”, default=””)
- class wisefood.entities.fctables.FCTablesProxy(client)[source]¶
Bases:
BaseCollectionProxy- Parameters:
client (DataClient)
Household and HouseholdMember entities and proxies for the WiseFood API.
- class wisefood.entities.households.Household(client=None, data=None)[source]¶
Bases:
objectA household in the WiseFood system.
Example
>>> household = client.households.me() >>> household.name = "New Family Name" # auto-syncs >>> members = household.members
- add_member(name, age_group, **kwargs)[source]¶
Add a new member to this household.
- Parameters:
- Return type:
- property members: List[HouseholdMember]¶
Get all members of this household.
- class wisefood.entities.households.HouseholdMember(client=None, data=None)[source]¶
Bases:
objectA member of a household.
Access the profile via the profile property which auto-fetches if needed.
Example
>>> member = client.members.get("member-id") >>> member.profile.dietary_groups = ["vegan"]
- property profile: HouseholdMemberProfile¶
Get the member’s profile, fetching from API if not loaded.
Returns a profile object where setting properties auto-syncs to API.
Example
>>> member.profile.dietary_groups = ["vegetarian"] >>> member.profile.nutritional_preferences = {"protein": 50}
- class wisefood.entities.households.HouseholdMemberProfile(client=None, member_id=None, data=None, sync=True)[source]¶
Bases:
objectProfile information for a household member.
Setting properties automatically syncs to the API when sync=True.
Example
>>> member.profile.dietary_groups = ["vegetarian", "gluten_free"] >>> member.profile.nutritional_preferences = {"calories": 2000}
- class wisefood.entities.households.HouseholdsProxy(client)[source]¶
Bases:
objectProxy for household operations.
Provides convenient access to household CRUD operations through the Client.
Example
>>> client.households.me() # Get current user's household >>> client.households.get("household-id-123") >>> client.households.create(name="My Family")
- Parameters:
client (Client)
- create(name, region=None, metadata=None, members=None)[source]¶
Create a new household.
- Parameters:
- Returns:
Created Household object
- Return type:
Example
>>> household = client.households.create( ... name="My Family", ... region="US-CA", ... members=[{"name": "John", "age_group": "adult"}] ... )
- delete(household_id)[source]¶
Delete a household.
- Parameters:
household_id (str) – The household’s unique identifier
- Return type:
None
Example
>>> client.households.delete("abc123")
- get(household_id)[source]¶
Get a household by ID.
- Parameters:
household_id (str) – The household’s unique identifier
- Returns:
Household object
- Return type:
Example
>>> household = client.households.get("abc123")
- list(limit=100, offset=0)[source]¶
List all households (admin only).
- Parameters:
- Returns:
List of Household objects
- Return type:
Example
>>> households = client.households.list(limit=50)
- me()[source]¶
Get the household owned by the authenticated user.
- Returns:
Household object for the current user
- Return type:
Example
>>> household = client.households.me() >>> print(household.name)
- update(household_id, **kwargs)[source]¶
Update a household.
- Parameters:
household_id (str) – The household’s unique identifier
**kwargs – Fields to update (name, region, metadata)
- Returns:
Updated Household object
- Return type:
Example
>>> household = client.households.update("abc123", name="New Name")
- class wisefood.entities.households.MembersProxy(client)[source]¶
Bases:
objectProxy for household member operations.
Provides convenient access to member CRUD operations through the Client.
Example
>>> member = client.members.get("member-id-123") >>> member.profile.dietary_groups = ["vegetarian"] # auto-syncs
- Parameters:
client (Client)
- create(household_id, name, age_group, image_url=None)[source]¶
Create a new household member.
- Parameters:
- Returns:
Created HouseholdMember object
- Return type:
Example
>>> member = client.members.create( ... household_id="abc123", ... name="John", ... age_group="adult" ... ) >>> member.profile.dietary_groups = ["vegetarian"]
- delete(member_id)[source]¶
Delete a household member.
- Parameters:
member_id (str) – The member’s unique identifier
- Return type:
None
Example
>>> client.members.delete("member123")
- get(member_id)[source]¶
Get a household member by ID.
- Parameters:
member_id (str) – The member’s unique identifier
- Returns:
HouseholdMember object with auto-syncing profile
- Return type:
Example
>>> member = client.members.get("member123") >>> member.profile.dietary_groups = ["vegan"]
Exceptions¶
- exception wisefood.exceptions.APIError(status_code, detail='', code=None, title=None, errors=None, extra=None, help_url=None, response_body=None)[source]¶
Bases:
ExceptionBase client-side API error.
Mirrors the server-side structure:
{ "success": false, "error": { "title": "...", "detail": "...", "code": "resource/not_found", ... }, "help": "http://.../api/v1/articles/hello" }
- Parameters:
- Return type:
None
- exception wisefood.exceptions.AuthenticationError(status_code, detail='', code=None, title=None, errors=None, extra=None, help_url=None, response_body=None)[source]¶
Bases:
APIError
- exception wisefood.exceptions.AuthorizationError(status_code, detail='', code=None, title=None, errors=None, extra=None, help_url=None, response_body=None)[source]¶
Bases:
APIError
- exception wisefood.exceptions.BadGatewayError(status_code, detail='', code=None, title=None, errors=None, extra=None, help_url=None, response_body=None)[source]¶
Bases:
APIError
- exception wisefood.exceptions.ConflictError(status_code, detail='', code=None, title=None, errors=None, extra=None, help_url=None, response_body=None)[source]¶
Bases:
APIError
- exception wisefood.exceptions.DataError(status_code, detail='', code=None, title=None, errors=None, extra=None, help_url=None, response_body=None)[source]¶
Bases:
APIError
- exception wisefood.exceptions.GatewayTimeoutError(status_code, detail='', code=None, title=None, errors=None, extra=None, help_url=None, response_body=None)[source]¶
Bases:
APIError
- exception wisefood.exceptions.InternalError(status_code, detail='', code=None, title=None, errors=None, extra=None, help_url=None, response_body=None)[source]¶
Bases:
APIError
- exception wisefood.exceptions.InvalidError(status_code, detail='', code=None, title=None, errors=None, extra=None, help_url=None, response_body=None)[source]¶
Bases:
APIError
- exception wisefood.exceptions.NotAllowedError(status_code, detail='', code=None, title=None, errors=None, extra=None, help_url=None, response_body=None)[source]¶
Bases:
APIError
- exception wisefood.exceptions.NotFoundError(status_code, detail='', code=None, title=None, errors=None, extra=None, help_url=None, response_body=None)[source]¶
Bases:
APIError
- exception wisefood.exceptions.RateLimitError(status_code, detail='', code=None, title=None, errors=None, extra=None, help_url=None, response_body=None)[source]¶
Bases:
APIError
Bases:
APIError
- wisefood.exceptions.error_from_response(response)[source]¶
Build a concrete APIError subclass from a requests.Response.
Expected Wisefood error payload shape:
{ "success": false, "error": { "title": "NotFoundError", "detail": "Article with URN urn:article:hello not found.", "code": "resource/not_found", ... maybe other keys ... }, "help": "http://.../api/v1/articles/hello" }
If the body is not JSON or doesn’t match the envelope, we still build a generic APIError with whatever information we can.
- Return type:
- wisefood.exceptions.raise_for_api_error(response)[source]¶
Inspect a requests.Response and raise a suitable APIError subclass if the Wisefood API indicates failure.
Usage in your client:
resp = self.get("articles/hello") raise_for_api_error(resp) data = resp.json()["result"]
Behavior: - If HTTP status is 2xx and success is True → returns silently. - If HTTP status >= 400 or success is False → raises APIError subclass.
- Return type:
None