Skip to main content

Build a food log and a holiday-aware date picker

Section: DOC-IN-data-providers#use-external-reference-data-in-your-application.

Help customers complete a task without manually searching another site. A food log can retrieve a product's nutrient record; a date picker can show public holidays beside candidate dates. These recipes use the data tools enabled for your Travila deployment. Your application owns the food entry or appointment being created.

Prepare the lookup for the feature you are building​

Section: DOC-IN-data-providers#choose-and-verify-a-result.

Use tool discovery to find the enabled source and inspect its input schema. Confirm that it supports the country, food type or date range your feature needs before offering the lookup to customers.

Keep the provider's returned identity with a selected result. This lets your application reopen the original record or explain which source was used when the customer corrects an entry. A tool lookup retrieves reference data; it does not save a food log or book an appointment for you.

Let a customer log a food without retyping its label​

Section: DOC-IN-data-providers#food-and-nutrient-records.

Build the interaction around choosing the right food and serving:

  1. Ask the customer to search for a food or enter a packaged product's barcode. The current tools support unified nutrition search, USDA search/detail/batch/list, and Open Food Facts search or barcode lookup.
  2. Show recognizable candidates with their source and product or preparation details. For a USDA result, use its FDC ID to retrieve the selected record. For a packaged product, retain its barcode identity. These are different identifiers and cannot be substituted for one another.
  3. Show the record's serving basis beside the amount the customer logs. Compare nutrient amounts only on a common basis, such as per 100 g or per labeled serving. Do not silently compare one product's serving with another's 100 g value.
  4. Save the chosen source record, serving basis and available nutrient values with the food entry in your application. Display missing values as unavailable, so an absent nutrient is not presented as zero.
  5. Let the customer review and correct the selection before relying on the entry. A successful result is a recognizable food with an explicit amount and source, not merely the first search hit.

Search results can be abridged; a detail lookup may be necessary before showing a complete entry. A batch can omit unavailable records. Scores from USDA and Open Food Facts are not directly comparable, so do not use a mixed score to claim one result is the best match.

Use USDA's data documentation and Open Food Facts' API documentation to interpret source formats and evidence. Reference data does not certify the contents or allergy safety of the physical product the customer has. Keep the actual label and customer correction available in the food-log experience.

Show public holidays while a customer chooses a date​

Section: DOC-IN-data-providers#holiday-calendars.

Add a holiday hint to a scheduling screen so customers can notice a date they may want to avoid:

  1. Let the customer select the relevant country and, where supported, subdivision. Use the year of the dates they are considering.
  2. Request the applicable holiday lookup through the discovered tool. Check the supported calendar coverage against the version enabled by your operator.
  3. Show returned holiday names beside the matching dates, with the selected region visible. Leave the appointment choice with the customer: a public holiday does not establish whether their workplace is closed or whether they personally observe it.
  4. Keep an unavailable state in the date picker. The current lookup can return empty or false when its provider fails, so an empty result cannot reliably certify that a date has no holiday. Confirm important dates against the relevant official calendar.

The completed feature helps the customer choose a date with context. It should not label a day “guaranteed working day” or automatically book an appointment based on an empty holiday result. Future dates may change with official announcements.

Let the customer finish when a lookup is unavailable​

Section: DOC-IN-data-providers#recover-without-inventing-data.

For the food log, offer manual entry or let the customer retry the selected lookup; keep an unavailable nutrient blank. For the date picker, let them choose a date while showing that holiday information could not be confirmed.

If a source is rate-limited, honor its retry guidance and bound retries. If only part of a multi-source result is available, show the sources that answered instead of presenting the partial list as complete. Keep source and retrieval dates where available so a cached value does not appear to be a fresh lookup.

Confirm enabled sources and update policy with your operator before shipping either feature. Provider data feeds have their own licensing, availability and freshness requirements even when the software that calls them is self-hosted.

Document ID: DOC-IN-data-providers. Section identities and revisions.