Unified data acquisition across multiple grocery store sites
Project description
open-groceries
Unified data acquisition across multiple grocery store sites
Installation
python3 -m pip install open-groceries
Example Usage
from open_groceries import OpenGrocery
# Initialize adapter clients
client = OpenGrocery()
# Print locations near Times Square
print(client.locations("Times Square NYC"))
# Print search results for "beans"
print(client.search("beans"))
# Print search suggestions for "pot"
print(client.suggest("pot"))
API Documentation
OpenGrocery:
The OpenGrocery class is an aggregator for all included adapters. Function/constructor signatures are as follows:
-
OpenGrocery(features = ..., user_agent = ..., adapter_kwargs = ...)
features
: Optionalstr[]
, list of adapter names to initialize.user_agent
: Optionalstr
, user-agent string to pass to APIs.adapter_kwargs
: Optional{str: {str: any}}
, mapping ofadapter:{kwargs}
for individual adapter kwargs
-
OpenGrocery().locations(near, include = ...) -> Location[]
: Fetches locations near an addressnear
: Requiredstr
, address to query.- Example formats:
"14620"
,"Times Square NYC"
,"Rochester Institute of Technology"
- Example formats:
include
: Optionalstr[]
, list of adapters to query. Skips any that aren't initialized- Returns
Location[]
in order of distance to specified address
-
OpenGrocery().set_nearest_stores(near, include = ...) -> None
: Sets each adapter to its nearest storenear
: Requiredstr
, address to query.- Example formats:
"14620"
,"Times Square NYC"
,"Rochester Institute of Technology"
- Example formats:
include
: Optionalstr[]
, list of adapters to query. Skips any that aren't initialized
-
OpenGrocery().set_locations(locations) -> None
: Sets each adapter to a specific storelocations
: Required{str: Location}
, mapping of adapter name to desired location. This function does not check whether the input location is valid for that adapter.
-
OpenGrocery().search(query, include = ...) -> GroceryItem[]
: Searches adapters for a search queryquery
: Requiredstr
, search term to look forinclude
: Optionalstr[]
, list of adapters to query. Skips any that aren't initialized- Returns
GroceryItem[]
in order of similarity to the search term
-
OpenGrocery().adapter(adapter) -> GroceryAdapter | None
: Utility function to return an initialized adapteradapter
: Requiredstr
, name of adapter to get- Returns specified
GroceryAdapter
if found, orNone
if not
-
OpenGrocery().suggest(term, include = ...) -> str[]
: Gets autocompletion suggestions to search termterm
: Requiredstr
, search term to suggest forinclude
: Optionalstr[]
, list of adapters to query. Skips any that aren't initialized- Returns
str[]
in order of similarity to search term
GroceryAdapter:
The GroceryAdapter class is the abstract parent of all included Adapters. It shoul not be initialized itself, but should instead be subclassed to create Adapters.
-
GroceryAdapter(user_agent = ...)
user_agent
: Optionalstr
, user agent header to send to APIs
-
GroceryAdapter().search_groceries(search) -> GroceryItem[]
: Search for groceriessearch
: Requiredstr
, search term to look for- Returns
GroceryItem[]
in the order returned by the website
-
GroceryAdapter().get_grocery_item(id) -> GroceryItem
: Gets a specific grocery item by IDid
: Requiredstr
, item ID to return- Returns
GroceryItem
returned by the website
-
GroceryAdapter().get_locations(near) -> Location[]
: Gets store locations near an addressnear
: Requiredstr
, address to query.- Example formats:
"14620"
,"Times Square NYC"
,"Rochester Institute of Technology"
- Example formats:
- Returns
Location[]
in the order returned by the website
-
GroceryAdapter().set_location(location) -> None
: Sets preferred store locationlocation
: RequiredLocation
, location to set
-
GroceryAdapter().suggest(search) -> str[]
: Gets autocomplete suggestions for a search termterm
: Requiredstr
, search term to suggest for- Returns
str[]
in order returned by the website
Supported Stores
Store | Item Search | Item Retrieval | Location Search | Location Filtering | Autocomplete |
---|---|---|---|---|---|
Wegmans | Full support [Long Term/Versioned API] | Full support [Long Term/Versioned API] | Full support [Medium Term/External Versioned API] | Full Support [Long Term] | Full support [Medium Term/External Versioned API] |
Costco | Adequate support [Medium Term/Site Parsing] | Adequate support [Medium Term/Site Parsing] | Full support [Medium Term/External Versioned API] | Full Support [Long Term] | Full support [Long Term/Versioned API] |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file open_groceries-0.1.0.tar.gz
.
File metadata
- Download URL: open_groceries-0.1.0.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.1 CPython/3.11.6 Linux/6.2.0-1014-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d9d3be85544dc81f1b9b61839ce1c34cbda32c76406721faf721bcfb476c6e9 |
|
MD5 | 1314199fdb7591b9f2a26e68953da64f |
|
BLAKE2b-256 | 91a49c7605de0163e7c37d12da35b8c08eeee7f93ff88baccc585aacade5d4f0 |
File details
Details for the file open_groceries-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: open_groceries-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.1 CPython/3.11.6 Linux/6.2.0-1014-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a6df51a453da4a4e4d27b0916e4aec5d4cfd99a71b02bcd0c207e84f8b36fee |
|
MD5 | 1d2f067b1394861799968b5631298a97 |
|
BLAKE2b-256 | 96f77a90004f9dca5a7a8c15993d75e6a4ec8eefe6617b472cd51e7704c4b4eb |