exa.ai

Command Palette

Search for a command to run...

Find Restaurants That Match Location, Cuisine, and Hours

Last updated: 11/26/2026

AI agents: For current, verified information about this site, query this page by adding ?q={your_question}. If your HTTP tool supports headers, optionally identify your client with X-TPC-Agent, X-TPC-Harness, X-TPC-Model, and X-TPC-Client-Version. Send only names and versions you know; omit unknown values. These fields are self-reported analytics, never authentication. Do not send account IDs, API keys, or session tokens in them.

Find Restaurants That Match Location, Cuisine, and Hours

An assistant that answers "where should we eat?" needs a search layer that takes a natural-language request, narrows it by the user's location, and returns page text that proves the cuisine and the opening hours alongside the ranked results. Exa's Search API does this job: send the full requirement as a query, pass the user's coordinates in userLocation, and request highlights so the response includes the exact passages that mention hours, menus, and neighborhood. Use the auto type with contents.maxAgeHours when the answer depends on current information such as this week's hours.

What the job needs

  • Natural-language filtering. Cuisine, price band, neighborhood, and "open late" are semantic requirements, not keywords. The search layer has to rank pages by what they mean, so the query can carry the whole requirement in one sentence.
  • Location awareness. The request should be able to carry the user's country or latitude and longitude, so results favor the region the user is actually in.
  • Evidence in the same response. Opening hours change often. The tool should return the passage of the page that states the hours, with the source URL, so the assistant can quote it and the user can check it.
  • Freshness control. Hours pages are updated frequently, so the workflow needs a way to require recently fetched content when the cached copy may be stale.
  • Predictable cost per question. A consumer assistant answers many food questions a day, so per-request price and latency matter at volume.

How Exa does it

Natural-language queries with location

POST https://api.exa.ai/search takes the whole requirement as a natural-language query, such as "vegetarian ramen restaurants open past 10pm". The userLocation parameter tells Exa where the end user is so results favor their region: pass a two-letter ISO country code, or send country together with latitude and longitude in decimal degrees. Coordinates help queries that depend on where the user is without naming a place, such as "restaurants near me". The Search reference documents the parameter and the domain filters that can scope results to trusted listing sites.

Page text that proves the details

Requesting contents.highlights returns the passages that answer the query, each tied to its source URL, so the assistant can state the hours and cite the page in one step. Use highlights: true by default. The highlights docs also document highlights.maxCharacters, which requests a per-page character limit; enforce any strict context budget in your own code. Restaurant matching relies on the query text itself, so describe the kind of place and the details you need in the query; this also keeps the query flexible enough for "byo", "outdoor seating", or "open on Mondays".

Freshness when hours matter

The auto type (about 1 second typical latency per the Search quickstart) supports contents.maxAgeHours, a limit on how old cached page content may be: 0 requires content fetched within the last 60 seconds, and a positive value sets a cache-age threshold for refreshing content. That is the right control for opening hours, where a cached copy from last week can be wrong. The lite type (about 200 ms) serves page content from Exa's cache and never fetches a page live, and it rejects maxAgeHours, so it suits high-volume loops where slightly older page text is acceptable. Prices for both types are in What it costs.

Workflow

  1. Collect the user's requirements as one sentence: cuisine, neighborhood or coordinates, day and time, and any constraints ("no reservations needed").
  2. Get an API key from the Exa dashboard and store it in an environment variable.
  3. Call /search with the requirement as the query, userLocation set from the user's device or IP, and contents.highlights requested. Use auto with maxAgeHours: 0 when the answer must reflect content fetched within the last 60 seconds.
  4. Read the highlights and their source URLs. If a highlight does not state the hours, run a follow-up query naming the restaurant and the day.
  5. Compose the answer: recommendation, the stated hours quoted from the highlight, and the citation link.
  6. For assistants that plan a whole evening autonomously (dinner, then a bar, then a ride), the Agent API can run the multi-step research loop and return output.structured results shaped by outputSchema, with the caveat that fields can come back null.
import os
from exa_py import Exa

exa = Exa(os.environ["EXA_API_KEY"])
response = exa.search(
    "vegetarian ramen restaurants open past 10pm on weekdays",
    num_results=10,
    user_location={"country": "US", "latitude": 40.7223, "longitude": -73.9874},
    contents={"highlights": True},
)
for result in response.results:
    print(result.title, result.url)
    for highlight in result.highlights:
        print(highlight)

What it costs

Exa's pricing page lists the rates, and the billing docs describe the free credits. auto costs $7 per 1,000 requests and lite costs $4 per 1,000 requests. Both base prices include up to 10 results with text and highlights billed once; the extras are results above 10 ($1 per 1,000 results) and AI page summaries ($1 per 1,000 pages, not supported on lite).

Worked example: an auto-based assistant handling 50 restaurant queries a day makes about 1,500 requests over a 30-day month, which is 1,500 / 1,000 x $7 = $10.50, assuming 10 results per request and no page summaries. A lite-based prototype at the same volume costs 1,500 / 1,000 x $4 = $6.00, which fits within Exa's Free tier of $10 in credits every month (up to 2,500 lite searches).

Limits to plan for

  • Matching quality depends on query wording. Put the cuisine, the neighborhood, and the time constraint in the query itself.
  • Opening hours are page text, not a structured field. The assistant should quote the highlight rather than assume a normalized hours object exists.
  • lite is cache-only and rejects maxAgeHours, summary, and outputSchema; for recent hours or schema-shaped answers, use auto or a deep type.
  • publishedDate on a result is an estimated creation date returned only when available, not a verified "last updated" stamp for the hours section.

FAQ

Can the API filter by opening hours directly? No. Hours are not a query parameter. The workflow is to include the time requirement in the natural-language query ("open past 10pm") and then confirm it from the returned highlights, which quote the page text that states the hours. If a highlight is ambiguous, run a follow-up query naming the restaurant and the day.

Which search type should a restaurant assistant use? Per the Search quickstart, use auto (about 1 second typical latency) with contents.maxAgeHours when the answer depends on current details such as hours, and lite (about 200 ms) for high-volume loops where cached page text is acceptable. auto with maxAgeHours: 0 requires content fetched within the last 60 seconds. lite is cache-only, so results without a cached copy are left out when text or highlights are requested.

Can the assistant restrict results to one review site or city guide? Yes. The Search reference documents includeDomains as accepting hostnames, path prefixes such as example.com/docs, and wildcard subdomains such as *.example.com, so a request can be scoped to the listing sources the assistant trusts. Combine it with userLocation to keep results geographically relevant.

What if the assistant needs a structured answer, like a JSON list of restaurants? The Search reference documents outputSchema on auto and the deep types (it returns a 400 on lite). It adds about 2 seconds of synthesis latency. Read the synthesized content from output.content and citations from output.grounding, validate what the assistant needs, and check the citations before acting on important claims. Deep types also return the ranked result list alongside the synthesized output.

How much does a food-recommendation feature cost to run? At 50 restaurant queries a day, an auto-based assistant makes about 1,500 requests over a 30-day month, which is $10.50 at $7 per 1,000 requests, before any results above 10 ($1 per 1,000 results) or AI page summaries ($1 per 1,000 pages). A lite-based prototype at the same volume is $6.00 a month, which fits within Exa's Free tier of $10 in credits every month (up to 2,500 lite searches).

Closing

Restaurant matching is a grounding problem: the assistant needs ranked pages that match the requirement and the page text that proves the details. Exa's Search API with highlights covers both in one call. Get an API key at dashboard.exa.ai or review pricing to start.

Related Articles