yelpapi 2.6.0__tar.gz → 2.8.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- yelpapi-2.8.0/.github/workflows/publish.yml +52 -0
- yelpapi-2.8.0/.github/workflows/tests.yml +74 -0
- {yelpapi-2.6.0 → yelpapi-2.8.0}/.gitignore +1 -0
- yelpapi-2.8.0/AGENTS.md +84 -0
- {yelpapi-2.6.0 → yelpapi-2.8.0}/CHANGES.md +25 -0
- {yelpapi-2.6.0 → yelpapi-2.8.0}/PKG-INFO +29 -15
- {yelpapi-2.6.0 → yelpapi-2.8.0}/README.md +19 -9
- {yelpapi-2.6.0 → yelpapi-2.8.0}/examples/examples.py +108 -32
- yelpapi-2.8.0/pyproject.toml +89 -0
- yelpapi-2.8.0/release-notes.md +17 -0
- {yelpapi-2.6.0 → yelpapi-2.8.0}/tests/conftest.py +4 -1
- yelpapi-2.8.0/tests/test_yelpapi.py +539 -0
- {yelpapi-2.6.0 → yelpapi-2.8.0}/yelpapi/__init__.py +2 -0
- yelpapi-2.8.0/yelpapi/yelpapi.py +632 -0
- yelpapi-2.6.0/.github/workflows/publish.yml +0 -28
- yelpapi-2.6.0/.github/workflows/tests.yml +0 -29
- yelpapi-2.6.0/CLAUDE.md +0 -32
- yelpapi-2.6.0/pyproject.toml +0 -47
- yelpapi-2.6.0/tests/__init__.py +0 -0
- yelpapi-2.6.0/tests/test_yelpapi.py +0 -315
- yelpapi-2.6.0/yelpapi/yelpapi.py +0 -385
- {yelpapi-2.6.0 → yelpapi-2.8.0}/AUTHORS.md +0 -0
- {yelpapi-2.6.0 → yelpapi-2.8.0}/LICENSE +0 -0
- {yelpapi-2.6.0 → yelpapi-2.8.0}/yelpapi/py.typed +0 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
name: Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
publish:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
environment: pypi
|
|
12
|
+
permissions:
|
|
13
|
+
id-token: write
|
|
14
|
+
contents: write
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v7
|
|
18
|
+
|
|
19
|
+
- name: Set up Python
|
|
20
|
+
uses: actions/setup-python@v7
|
|
21
|
+
with:
|
|
22
|
+
python-version: '3.15'
|
|
23
|
+
|
|
24
|
+
- name: Verify tag matches package version
|
|
25
|
+
run: |
|
|
26
|
+
version="$(python -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')"
|
|
27
|
+
if [ "v${version}" != "${GITHUB_REF_NAME}" ]; then
|
|
28
|
+
echo "Tag ${GITHUB_REF_NAME} does not match pyproject.toml version ${version}" >&2
|
|
29
|
+
exit 1
|
|
30
|
+
fi
|
|
31
|
+
|
|
32
|
+
- name: Extract release notes from CHANGES.md
|
|
33
|
+
run: |
|
|
34
|
+
version="${GITHUB_REF_NAME#v}"
|
|
35
|
+
awk -v v="$version" '/^## /{if (f) exit; f = (index($0, "## " v " ") == 1); next} f' CHANGES.md > release-notes.md
|
|
36
|
+
if [ ! -s release-notes.md ]; then
|
|
37
|
+
echo "No CHANGES.md entry found for ${version}" >&2
|
|
38
|
+
exit 1
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
- name: Build
|
|
42
|
+
run: |
|
|
43
|
+
pip install build
|
|
44
|
+
python -m build
|
|
45
|
+
|
|
46
|
+
- name: Publish to PyPI
|
|
47
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
48
|
+
|
|
49
|
+
- name: Create GitHub release
|
|
50
|
+
env:
|
|
51
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
52
|
+
run: gh release create "${GITHUB_REF_NAME}" dist/* --title "YelpAPI ${GITHUB_REF_NAME}" --notes-file release-notes.md
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
name: Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [master]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
# Cancel an in-progress run when a newer commit is pushed to the same branch or pull request.
|
|
12
|
+
concurrency:
|
|
13
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
14
|
+
cancel-in-progress: true
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
lint:
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v7
|
|
22
|
+
|
|
23
|
+
# Ruff targets requires-python in pyproject.toml regardless of the interpreter it runs on.
|
|
24
|
+
- name: Set up Python
|
|
25
|
+
uses: actions/setup-python@v7
|
|
26
|
+
with:
|
|
27
|
+
python-version: '3.x'
|
|
28
|
+
|
|
29
|
+
- name: Install ruff
|
|
30
|
+
run: pip install ruff
|
|
31
|
+
|
|
32
|
+
- name: Lint with ruff
|
|
33
|
+
run: ruff check --output-format=github
|
|
34
|
+
|
|
35
|
+
typecheck:
|
|
36
|
+
runs-on: ubuntu-latest
|
|
37
|
+
|
|
38
|
+
steps:
|
|
39
|
+
- uses: actions/checkout@v7
|
|
40
|
+
|
|
41
|
+
# mypy targets python_version in pyproject.toml regardless of the interpreter it runs on, so a single job is
|
|
42
|
+
# sufficient. Run it on that same minimum version so installed dependencies and stubs match what users on the
|
|
43
|
+
# minimum get. Keep this equal to python_version.
|
|
44
|
+
- name: Set up Python
|
|
45
|
+
uses: actions/setup-python@v7
|
|
46
|
+
with:
|
|
47
|
+
python-version: '3.11'
|
|
48
|
+
|
|
49
|
+
- name: Install dependencies
|
|
50
|
+
run: pip install -e ".[dev]"
|
|
51
|
+
|
|
52
|
+
- name: Type-check with mypy
|
|
53
|
+
run: mypy
|
|
54
|
+
|
|
55
|
+
test:
|
|
56
|
+
runs-on: ubuntu-latest
|
|
57
|
+
strategy:
|
|
58
|
+
fail-fast: false
|
|
59
|
+
matrix:
|
|
60
|
+
python-version: ['3.11', '3.12', '3.13', '3.14', '3.15']
|
|
61
|
+
|
|
62
|
+
steps:
|
|
63
|
+
- uses: actions/checkout@v7
|
|
64
|
+
|
|
65
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
66
|
+
uses: actions/setup-python@v7
|
|
67
|
+
with:
|
|
68
|
+
python-version: ${{ matrix.python-version }}
|
|
69
|
+
|
|
70
|
+
- name: Install dependencies
|
|
71
|
+
run: pip install -e ".[dev]"
|
|
72
|
+
|
|
73
|
+
- name: Run tests
|
|
74
|
+
run: pytest
|
yelpapi-2.8.0/AGENTS.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to AI coding agents working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Commands
|
|
6
|
+
|
|
7
|
+
Install dependencies:
|
|
8
|
+
```
|
|
9
|
+
pip install -e ".[dev]"
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Run tests (coverage included by default via `pyproject.toml`):
|
|
13
|
+
```
|
|
14
|
+
pytest
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Run a single test:
|
|
18
|
+
```
|
|
19
|
+
pytest tests/test_yelpapi.py::TestYelpAPI::test_calls_api
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Type-check (strict; configured in `[tool.mypy]` in `pyproject.toml`, which sets the files to check and targets the minimum supported Python):
|
|
23
|
+
```
|
|
24
|
+
mypy
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Lint (configured in `[tool.ruff]` in `pyproject.toml`; `ruff check --fix` applies safe fixes):
|
|
28
|
+
```
|
|
29
|
+
ruff check
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
CI (`.github/workflows/tests.yml`) runs `pytest` on every supported Python version, plus `mypy` and `ruff check` once each in separate `typecheck` and `lint` jobs. All must pass.
|
|
33
|
+
|
|
34
|
+
## Architecture
|
|
35
|
+
|
|
36
|
+
This is a thin Python wrapper around Yelp's public REST APIs: the [Yelp Places API](https://docs.developer.yelp.com/docs/places-intro), the [Yelp AI API](https://docs.developer.yelp.com/docs/yelp-ai-api), [Yelp Insights](https://docs.developer.yelp.com/docs/yelp-insights), and the [Home Services API](https://docs.developer.yelp.com/docs/home-services-api). The entire implementation lives in `yelpapi/yelpapi.py` as a single `YelpAPI` class, re-exported from `yelpapi/__init__.py` via `__all__`.
|
|
37
|
+
|
|
38
|
+
**Design philosophy:** The wrapper is intentionally minimal and extensible — all API parameters are passed through `**kwargs` directly to the HTTP request, so it doesn't break when Yelp adds new parameters. The only thing that would break it is a URL scheme change. Public methods return `dict[str, Any]`; don't introduce `TypedDict`s or response models, since they would break this pass-through design.
|
|
39
|
+
|
|
40
|
+
**Request flow:** Each public method (e.g., `search_query`, `business_query`) validates required parameters, then delegates to `_get()` (GET; kwargs become query string parameters) or `_post()` (POST; kwargs become the JSON body). Both strip `None`-valued kwargs before issuing the request via a shared `requests.Session`, then hand the response to `_parse_response()`, which raises `requests.HTTPError` for HTTP error statuses, returns `{}` for empty `202`/`204` responses, and raises `YelpAPI.YelpAPIError` if the JSON body isn't an object or contains an `error` key. Methods that require a location share a `_require_location_or_lat_lng()` helper.
|
|
41
|
+
|
|
42
|
+
**Session management:** A single `requests.Session` is reused for all calls (performance benefit). Users should close it via context manager (`with YelpAPI(...) as api`) or explicitly via `api.close()`.
|
|
43
|
+
|
|
44
|
+
**Tests** use `requests-mock` (via the `mock_request` autouse fixture in `conftest.py`) to intercept HTTP calls, and a fixed-seed `Faker` for generating test data, so every run is deterministic. No real API calls are made in tests.
|
|
45
|
+
|
|
46
|
+
## Conventions
|
|
47
|
+
|
|
48
|
+
- **Typing:** The package ships `py.typed` and must pass strict `mypy`. All library code must be fully annotated. Tests and examples are type-checked but may omit annotations; see the `[[tool.mypy.overrides]]` section of `pyproject.toml`.
|
|
49
|
+
- **Coverage:** Line coverage of `yelpapi/` is 100%. Keep it there; new code paths need tests.
|
|
50
|
+
- **Style:** Use single quotes for strings, and 120-character lines.
|
|
51
|
+
- **Adding an endpoint** requires all of the following:
|
|
52
|
+
- a `*_API_URL` constant
|
|
53
|
+
- a method that validates required parameters and calls `_get()` (GET) or `_post()` (POST); path parameters are positional arguments inserted with `quote(value, safe='')`
|
|
54
|
+
- an entry in the `GET_ENDPOINTS` or `POST_ENDPOINTS` table in `tests/test_yelpapi.py` (use `PATH_PARAM` for path parameters)
|
|
55
|
+
- an entry in the `YelpAPI` class docstring's API list
|
|
56
|
+
- an entry in the README "METHODS" list
|
|
57
|
+
- tests covering both validation failures and success
|
|
58
|
+
|
|
59
|
+
## Supported Python versions
|
|
60
|
+
|
|
61
|
+
Support only Python versions that are currently maintained (not end-of-life); see https://devguide.python.org/versions/. The minimum is currently 3.11. When adding or dropping a version, update all of these together:
|
|
62
|
+
|
|
63
|
+
- `requires-python` and the `Programming Language :: Python :: 3.x` classifiers in `pyproject.toml`
|
|
64
|
+
- `python_version` in `[tool.mypy]` in `pyproject.toml` (keep it equal to the minimum)
|
|
65
|
+
- the `test` job's matrix in `.github/workflows/tests.yml`
|
|
66
|
+
- the Python version used by the `typecheck` job in `tests.yml` (keep it equal to the minimum, matching `python_version`)
|
|
67
|
+
- the Python version used by `publish.yml` (use the newest supported version)
|
|
68
|
+
- the "REQUIREMENTS" section of `README.md`
|
|
69
|
+
- `CHANGES.md`
|
|
70
|
+
|
|
71
|
+
Once the minimum is raised, newly available language and typing features (e.g., `typing.Self` with 3.11) may be used.
|
|
72
|
+
|
|
73
|
+
## Releasing
|
|
74
|
+
|
|
75
|
+
1. Bump `version` in `pyproject.toml`.
|
|
76
|
+
2. Add a `## X.Y.Z (YYYY-MM-DD)` entry at the top of `CHANGES.md`.
|
|
77
|
+
3. Commit, push, and make sure CI is green. The publish workflow does not run tests.
|
|
78
|
+
4. Push an annotated tag:
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
git tag -a vX.Y.Z -m "vX.Y.Z" && git push origin vX.Y.Z
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Pushing a `v*` tag triggers `.github/workflows/publish.yml`. Before publishing, it fails if the tag doesn't match the `pyproject.toml` version, or if `CHANGES.md` has no entry for that version. It then builds, publishes to PyPI, and creates a GitHub release whose notes are that version's `CHANGES.md` entry.
|
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2.8.0 (2026-10-28)
|
|
4
|
+
* **Heads up for subclassers:** the private request helper `YelpAPI._query()` has been renamed to `YelpAPI._get()`, and the new POST helper is `YelpAPI._post()`.
|
|
5
|
+
* If your subclass *calls* `self._query(...)` to reach endpoints this library doesn't wrap, switch to `self._get(...)`. `_query()` still works for this release but emits a `FutureWarning`.
|
|
6
|
+
* If your subclass *overrides* `_query()` (e.g., for caching, retries, or logging), override `_get()` (and `_post()` for POST endpoints) instead. Public methods no longer call `_query()`, so an override of it is no longer used. Defining such a subclass emits a `FutureWarning`.
|
|
7
|
+
* `_query()` will be removed in 2.9.0.
|
|
8
|
+
* Added 8 new API endpoints: AI Chat (`ai_chat_query`), Business Insights (`business_insights_query`), Business Food & Drinks Insights (`business_food_and_drinks_insights_query`), Business Risk Signal Insights (`business_risk_signals_insights_query`), Business Request a Phone Call (`business_rapc_enabledness_query`), Jobs (`jobs_query`), Job Survey (`job_survey_query`), and Request a Quote (`request_a_quote_query`).
|
|
9
|
+
* Added support for POST endpoints, which send `**kwargs` as the JSON request body (with `None` values removed). Successful responses with no body (e.g., `202 Accepted`) return an empty dict.
|
|
10
|
+
* `business_service_offerings_query` now emits a `DeprecationWarning`, because Yelp has deprecated the endpoint in favor of "Jobs offered" on the Business API.
|
|
11
|
+
* Fixed: a latitude or longitude of `0` (the equator or prime meridian) is now accepted by `search_query`, `featured_event_query`, and `transaction_search_query` instead of raising `ValueError`.
|
|
12
|
+
* Fixed: `business_match_query` now accepts an empty `address1`, which Yelp allows for service businesses with no street address.
|
|
13
|
+
* Fixed: a malformed `error` object in a response (e.g., a plain string, or one missing `code` or `description`) now raises `YelpAPI.YelpAPIError` instead of a `TypeError` or `KeyError`.
|
|
14
|
+
* Path parameters (business IDs, aliases, event IDs, job aliases, and transaction types) are now percent-encoded, so characters like `/`, `?`, and `#` can no longer change the URL that is requested.
|
|
15
|
+
* Clarified the `YelpAPI.YelpAPIError` docs: HTTP error statuses raise `requests.HTTPError`, while `YelpAPIError` covers error objects and non-object bodies in successful responses.
|
|
16
|
+
* Updated docstrings to match Yelp's current docs (plan and access requirements, `match_threshold`, the 20-ID limit for `business_ids`, and required fields for Request a Quote).
|
|
17
|
+
* Fixed the examples so they catch `requests.HTTPError` and keep going when an endpoint needs a paid plan or extra access.
|
|
18
|
+
* Strengthened the test suite: every endpoint's URL, HTTP method, and parameters are now checked, and test data is deterministic.
|
|
19
|
+
* Added [Ruff](https://docs.astral.sh/ruff/) linting, run in CI.
|
|
20
|
+
|
|
21
|
+
## 2.7.0 (2026-10-28)
|
|
22
|
+
* Dropped support for end-of-life Python 3.9 and 3.10; added Python 3.15. Minimum supported version is now 3.11.
|
|
23
|
+
* `YelpAPI.__enter__` now returns `Self`, so subclasses are typed correctly when used as context managers.
|
|
24
|
+
* Declared `__all__` in the `yelpapi` package so `from yelpapi import YelpAPI` passes `mypy --strict` (no implicit re-export) and Pyright's private-import checks.
|
|
25
|
+
* Added the `Typing :: Typed` classifier.
|
|
26
|
+
* A JSON response body that isn't an object (e.g., a string or list) now raises `YelpAPI.YelpAPIError` instead of an unhelpful `TypeError` or silently returning the wrong type.
|
|
27
|
+
|
|
3
28
|
## 2.6.0 (2026-03-17)
|
|
4
29
|
* Added 5 new API endpoints: Business Engagement Metrics (`business_engagement_query`), Business Service Offerings (`business_service_offerings_query`), Categories (`categories_query`), Category by Alias (`category_query`), and Review Highlights (`review_highlights_query`).
|
|
5
30
|
* Updated all documentation URLs to the current `docs.developer.yelp.com` reference format.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: yelpapi
|
|
3
|
-
Version: 2.
|
|
4
|
-
Summary: yelpapi is a pure Python implementation of
|
|
3
|
+
Version: 2.8.0
|
|
4
|
+
Summary: yelpapi is a pure Python implementation of Yelp's public REST APIs (Places, AI, Insights, and Home Services).
|
|
5
5
|
Project-URL: Homepage, https://github.com/lanl/yelpapi
|
|
6
6
|
Project-URL: Changelog, https://github.com/lanl/yelpapi/blob/master/CHANGES.md
|
|
7
7
|
Author-email: Geoffrey Fairchild <mail@gfairchild.com>
|
|
@@ -32,21 +32,25 @@ Classifier: Intended Audience :: Developers
|
|
|
32
32
|
Classifier: License :: OSI Approved :: BSD License
|
|
33
33
|
Classifier: Operating System :: OS Independent
|
|
34
34
|
Classifier: Programming Language :: Python :: 3
|
|
35
|
-
Classifier: Programming Language :: Python :: 3
|
|
36
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
35
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
37
36
|
Classifier: Programming Language :: Python :: 3.11
|
|
38
37
|
Classifier: Programming Language :: Python :: 3.12
|
|
39
38
|
Classifier: Programming Language :: Python :: 3.13
|
|
40
39
|
Classifier: Programming Language :: Python :: 3.14
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
41
41
|
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
|
42
42
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
43
|
-
|
|
43
|
+
Classifier: Typing :: Typed
|
|
44
|
+
Requires-Python: >=3.11
|
|
44
45
|
Requires-Dist: requests
|
|
45
46
|
Provides-Extra: dev
|
|
46
47
|
Requires-Dist: faker; extra == 'dev'
|
|
48
|
+
Requires-Dist: mypy; extra == 'dev'
|
|
47
49
|
Requires-Dist: pytest; extra == 'dev'
|
|
48
50
|
Requires-Dist: pytest-cov; extra == 'dev'
|
|
49
51
|
Requires-Dist: requests-mock; extra == 'dev'
|
|
52
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
53
|
+
Requires-Dist: types-requests; extra == 'dev'
|
|
50
54
|
Description-Content-Type: text/markdown
|
|
51
55
|
|
|
52
56
|
# yelpapi
|
|
@@ -54,18 +58,18 @@ Description-Content-Type: text/markdown
|
|
|
54
58
|
[](https://github.com/lanl/yelpapi/actions/workflows/tests.yml)
|
|
55
59
|
|
|
56
60
|
## LICENSE
|
|
57
|
-
This software is licensed under the [BSD 3-Clause License](
|
|
61
|
+
This software is licensed under the [BSD 3-Clause License](https://opensource.org/licenses/BSD-3-Clause). Please refer to the separate [LICENSE](LICENSE) file for the exact text of the license. You are obligated to give attribution if you use this code.
|
|
58
62
|
|
|
59
63
|
## ABOUT
|
|
60
|
-
yelpapi is a pure Python implementation of the [Yelp
|
|
64
|
+
yelpapi is a pure Python implementation of Yelp's public REST APIs, including the [Yelp Places API](https://docs.developer.yelp.com/docs/places-intro), the [Yelp AI API](https://docs.developer.yelp.com/docs/yelp-ai-api), [Yelp Insights](https://docs.developer.yelp.com/docs/yelp-insights), and the [Home Services API](https://docs.developer.yelp.com/docs/home-services-api). It is simple, fast, and robust to any changes Yelp may make to its APIs in the future.
|
|
61
65
|
|
|
62
66
|
## REQUIREMENTS
|
|
63
|
-
This code requires Python 3.
|
|
67
|
+
This code requires Python 3.11 or higher and [requests](https://github.com/psf/requests).
|
|
64
68
|
|
|
65
69
|
## INSTALL
|
|
66
70
|
yelpapi is available on PyPI at https://pypi.org/project/yelpapi/.
|
|
67
71
|
|
|
68
|
-
Install using [pip](
|
|
72
|
+
Install using [pip](https://pip.pypa.io/):
|
|
69
73
|
|
|
70
74
|
pip install yelpapi
|
|
71
75
|
|
|
@@ -75,7 +79,7 @@ This API is demonstrated more thoroughly in [examples.py](examples/examples.py),
|
|
|
75
79
|
```python
|
|
76
80
|
from yelpapi import YelpAPI
|
|
77
81
|
with YelpAPI(api_key) as yelp_api:
|
|
78
|
-
search_results = yelp_api.search_query(
|
|
82
|
+
search_results = yelp_api.search_query(term='ice cream', location='austin, tx')
|
|
79
83
|
```
|
|
80
84
|
|
|
81
85
|
You can also set timeouts so API calls do not block indefinitely in degraded network conditions:
|
|
@@ -83,33 +87,43 @@ You can also set timeouts so API calls do not block indefinitely in degraded net
|
|
|
83
87
|
```python
|
|
84
88
|
from yelpapi import YelpAPI
|
|
85
89
|
with YelpAPI(api_key, timeout_s=3.0) as yelp_api:
|
|
86
|
-
search_results = yelp_api.search_query(
|
|
90
|
+
search_results = yelp_api.search_query(term='ice cream', location='austin, tx')
|
|
87
91
|
```
|
|
88
92
|
|
|
89
93
|
Under the covers, this module uses a [`requests.Session`](https://requests.readthedocs.io/en/latest/user/advanced/#session-objects) object for issuing all API calls, which offers potentially significant performance benefits over issuing separate API calls outside of a session. You should be sure to close the underlying session when all API interactions are complete. The above examples demonstrate using the class as a context manager, which will automatically close the connection when you're done and is the preferred way of using the class, but you can also manually close it like this if a context manager won't work for your use case:
|
|
90
94
|
|
|
91
95
|
```python
|
|
92
96
|
from yelpapi import YelpAPI
|
|
97
|
+
yelp_api = YelpAPI(api_key)
|
|
93
98
|
try:
|
|
94
|
-
yelp_api =
|
|
95
|
-
search_results = yelp_api.search_query(args)
|
|
99
|
+
search_results = yelp_api.search_query(term='ice cream', location='austin, tx')
|
|
96
100
|
finally:
|
|
97
101
|
yelp_api.close()
|
|
98
102
|
```
|
|
99
103
|
|
|
100
104
|
## METHODS
|
|
105
|
+
* [AI Chat API](https://docs.developer.yelp.com/reference/v2_ai_chat) - `ai_chat_query(...)`
|
|
101
106
|
* [Autocomplete API](https://docs.developer.yelp.com/reference/v3_autocomplete) - `autocomplete_query(...)`
|
|
102
107
|
* [Business API](https://docs.developer.yelp.com/reference/v3_business_info) - `business_query(...)`
|
|
103
108
|
* [Business Engagement Metrics API](https://docs.developer.yelp.com/reference/v3_get_businesses_engagement) - `business_engagement_query(...)`
|
|
109
|
+
* [Business Food & Drinks Insights API](https://docs.developer.yelp.com/reference/v3_get_business_food_and_drinks_insights) - `business_food_and_drinks_insights_query(...)`
|
|
110
|
+
* [Business Insights API](https://docs.developer.yelp.com/reference/v3_businesses_insights) - `business_insights_query(...)`
|
|
104
111
|
* [Business Match API](https://docs.developer.yelp.com/reference/v3_business_match) - `business_match_query(...)`
|
|
105
|
-
* [Business
|
|
112
|
+
* [Business Request a Phone Call API](https://docs.developer.yelp.com/reference/v3_business_rapc_enabledness) - `business_rapc_enabledness_query(...)`
|
|
113
|
+
* [Business Risk Signal Insights API](https://docs.developer.yelp.com/reference/v3_get_business_risk_signals_insights) - `business_risk_signals_insights_query(...)`
|
|
114
|
+
* [Business Service Offerings API](https://docs.developer.yelp.com/reference/v3_business_service_offerings) - `business_service_offerings_query(...)` (deprecated by Yelp in favor of "Jobs offered" on the Business API)
|
|
106
115
|
* [Categories API](https://docs.developer.yelp.com/reference/v3_all_categories) - `categories_query(...)`
|
|
107
116
|
* [Category API](https://docs.developer.yelp.com/reference/v3_categories) - `category_query(...)`
|
|
108
117
|
* [Event Lookup API](https://docs.developer.yelp.com/reference/v3_event) - `event_lookup_query(...)`
|
|
109
118
|
* [Event Search API](https://docs.developer.yelp.com/reference/v3_events_search) - `event_search_query(...)`
|
|
110
119
|
* [Featured Event API](https://docs.developer.yelp.com/reference/v3_featured_event) - `featured_event_query(...)`
|
|
120
|
+
* [Job Survey API](https://docs.developer.yelp.com/reference/v3_job_survey) - `job_survey_query(...)`
|
|
121
|
+
* [Jobs API](https://docs.developer.yelp.com/reference/v3_get_jobs) - `jobs_query(...)`
|
|
111
122
|
* [Phone Search API](https://docs.developer.yelp.com/reference/v3_business_phone_search) - `phone_search_query(...)`
|
|
123
|
+
* [Request a Quote API](https://docs.developer.yelp.com/reference/v3_raq_submit_project) - `request_a_quote_query(...)`
|
|
112
124
|
* [Review Highlights API](https://docs.developer.yelp.com/reference/v3_business_review_highlights) - `review_highlights_query(...)`
|
|
113
125
|
* [Reviews API](https://docs.developer.yelp.com/reference/v3_business_reviews) - `reviews_query(...)`
|
|
114
126
|
* [Search API](https://docs.developer.yelp.com/reference/v3_business_search) - `search_query(...)`
|
|
115
127
|
* [Transaction Search API](https://docs.developer.yelp.com/reference/v3_transaction_search) - `transaction_search_query(...)`
|
|
128
|
+
|
|
129
|
+
Yelp's [GraphQL API](https://docs.developer.yelp.com/docs/graphql-intro) is not wrapped, since it uses GraphQL queries rather than REST parameters.
|
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
[](https://github.com/lanl/yelpapi/actions/workflows/tests.yml)
|
|
4
4
|
|
|
5
5
|
## LICENSE
|
|
6
|
-
This software is licensed under the [BSD 3-Clause License](
|
|
6
|
+
This software is licensed under the [BSD 3-Clause License](https://opensource.org/licenses/BSD-3-Clause). Please refer to the separate [LICENSE](LICENSE) file for the exact text of the license. You are obligated to give attribution if you use this code.
|
|
7
7
|
|
|
8
8
|
## ABOUT
|
|
9
|
-
yelpapi is a pure Python implementation of the [Yelp
|
|
9
|
+
yelpapi is a pure Python implementation of Yelp's public REST APIs, including the [Yelp Places API](https://docs.developer.yelp.com/docs/places-intro), the [Yelp AI API](https://docs.developer.yelp.com/docs/yelp-ai-api), [Yelp Insights](https://docs.developer.yelp.com/docs/yelp-insights), and the [Home Services API](https://docs.developer.yelp.com/docs/home-services-api). It is simple, fast, and robust to any changes Yelp may make to its APIs in the future.
|
|
10
10
|
|
|
11
11
|
## REQUIREMENTS
|
|
12
|
-
This code requires Python 3.
|
|
12
|
+
This code requires Python 3.11 or higher and [requests](https://github.com/psf/requests).
|
|
13
13
|
|
|
14
14
|
## INSTALL
|
|
15
15
|
yelpapi is available on PyPI at https://pypi.org/project/yelpapi/.
|
|
16
16
|
|
|
17
|
-
Install using [pip](
|
|
17
|
+
Install using [pip](https://pip.pypa.io/):
|
|
18
18
|
|
|
19
19
|
pip install yelpapi
|
|
20
20
|
|
|
@@ -24,7 +24,7 @@ This API is demonstrated more thoroughly in [examples.py](examples/examples.py),
|
|
|
24
24
|
```python
|
|
25
25
|
from yelpapi import YelpAPI
|
|
26
26
|
with YelpAPI(api_key) as yelp_api:
|
|
27
|
-
search_results = yelp_api.search_query(
|
|
27
|
+
search_results = yelp_api.search_query(term='ice cream', location='austin, tx')
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
You can also set timeouts so API calls do not block indefinitely in degraded network conditions:
|
|
@@ -32,33 +32,43 @@ You can also set timeouts so API calls do not block indefinitely in degraded net
|
|
|
32
32
|
```python
|
|
33
33
|
from yelpapi import YelpAPI
|
|
34
34
|
with YelpAPI(api_key, timeout_s=3.0) as yelp_api:
|
|
35
|
-
search_results = yelp_api.search_query(
|
|
35
|
+
search_results = yelp_api.search_query(term='ice cream', location='austin, tx')
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
Under the covers, this module uses a [`requests.Session`](https://requests.readthedocs.io/en/latest/user/advanced/#session-objects) object for issuing all API calls, which offers potentially significant performance benefits over issuing separate API calls outside of a session. You should be sure to close the underlying session when all API interactions are complete. The above examples demonstrate using the class as a context manager, which will automatically close the connection when you're done and is the preferred way of using the class, but you can also manually close it like this if a context manager won't work for your use case:
|
|
39
39
|
|
|
40
40
|
```python
|
|
41
41
|
from yelpapi import YelpAPI
|
|
42
|
+
yelp_api = YelpAPI(api_key)
|
|
42
43
|
try:
|
|
43
|
-
yelp_api =
|
|
44
|
-
search_results = yelp_api.search_query(args)
|
|
44
|
+
search_results = yelp_api.search_query(term='ice cream', location='austin, tx')
|
|
45
45
|
finally:
|
|
46
46
|
yelp_api.close()
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
## METHODS
|
|
50
|
+
* [AI Chat API](https://docs.developer.yelp.com/reference/v2_ai_chat) - `ai_chat_query(...)`
|
|
50
51
|
* [Autocomplete API](https://docs.developer.yelp.com/reference/v3_autocomplete) - `autocomplete_query(...)`
|
|
51
52
|
* [Business API](https://docs.developer.yelp.com/reference/v3_business_info) - `business_query(...)`
|
|
52
53
|
* [Business Engagement Metrics API](https://docs.developer.yelp.com/reference/v3_get_businesses_engagement) - `business_engagement_query(...)`
|
|
54
|
+
* [Business Food & Drinks Insights API](https://docs.developer.yelp.com/reference/v3_get_business_food_and_drinks_insights) - `business_food_and_drinks_insights_query(...)`
|
|
55
|
+
* [Business Insights API](https://docs.developer.yelp.com/reference/v3_businesses_insights) - `business_insights_query(...)`
|
|
53
56
|
* [Business Match API](https://docs.developer.yelp.com/reference/v3_business_match) - `business_match_query(...)`
|
|
54
|
-
* [Business
|
|
57
|
+
* [Business Request a Phone Call API](https://docs.developer.yelp.com/reference/v3_business_rapc_enabledness) - `business_rapc_enabledness_query(...)`
|
|
58
|
+
* [Business Risk Signal Insights API](https://docs.developer.yelp.com/reference/v3_get_business_risk_signals_insights) - `business_risk_signals_insights_query(...)`
|
|
59
|
+
* [Business Service Offerings API](https://docs.developer.yelp.com/reference/v3_business_service_offerings) - `business_service_offerings_query(...)` (deprecated by Yelp in favor of "Jobs offered" on the Business API)
|
|
55
60
|
* [Categories API](https://docs.developer.yelp.com/reference/v3_all_categories) - `categories_query(...)`
|
|
56
61
|
* [Category API](https://docs.developer.yelp.com/reference/v3_categories) - `category_query(...)`
|
|
57
62
|
* [Event Lookup API](https://docs.developer.yelp.com/reference/v3_event) - `event_lookup_query(...)`
|
|
58
63
|
* [Event Search API](https://docs.developer.yelp.com/reference/v3_events_search) - `event_search_query(...)`
|
|
59
64
|
* [Featured Event API](https://docs.developer.yelp.com/reference/v3_featured_event) - `featured_event_query(...)`
|
|
65
|
+
* [Job Survey API](https://docs.developer.yelp.com/reference/v3_job_survey) - `job_survey_query(...)`
|
|
66
|
+
* [Jobs API](https://docs.developer.yelp.com/reference/v3_get_jobs) - `jobs_query(...)`
|
|
60
67
|
* [Phone Search API](https://docs.developer.yelp.com/reference/v3_business_phone_search) - `phone_search_query(...)`
|
|
68
|
+
* [Request a Quote API](https://docs.developer.yelp.com/reference/v3_raq_submit_project) - `request_a_quote_query(...)`
|
|
61
69
|
* [Review Highlights API](https://docs.developer.yelp.com/reference/v3_business_review_highlights) - `review_highlights_query(...)`
|
|
62
70
|
* [Reviews API](https://docs.developer.yelp.com/reference/v3_business_reviews) - `reviews_query(...)`
|
|
63
71
|
* [Search API](https://docs.developer.yelp.com/reference/v3_business_search) - `search_query(...)`
|
|
64
72
|
* [Transaction Search API](https://docs.developer.yelp.com/reference/v3_transaction_search) - `transaction_search_query(...)`
|
|
73
|
+
|
|
74
|
+
Yelp's [GraphQL API](https://docs.developer.yelp.com/docs/graphql-intro) is not wrapped, since it uses GraphQL queries rather than REST parameters.
|