seatdata-sdk 0.1.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.
- seatdata_sdk-0.1.0/LICENSE +21 -0
- seatdata_sdk-0.1.0/MANIFEST.in +6 -0
- seatdata_sdk-0.1.0/PKG-INFO +89 -0
- seatdata_sdk-0.1.0/README.md +61 -0
- seatdata_sdk-0.1.0/examples/README.md +32 -0
- seatdata_sdk-0.1.0/examples/basic_usage.py +56 -0
- seatdata_sdk-0.1.0/pyproject.toml +48 -0
- seatdata_sdk-0.1.0/requirements.txt +6 -0
- seatdata_sdk-0.1.0/seatdata/__init__.py +5 -0
- seatdata_sdk-0.1.0/seatdata/client.py +128 -0
- seatdata_sdk-0.1.0/seatdata/exceptions.py +10 -0
- seatdata_sdk-0.1.0/seatdata_sdk.egg-info/PKG-INFO +89 -0
- seatdata_sdk-0.1.0/seatdata_sdk.egg-info/SOURCES.txt +19 -0
- seatdata_sdk-0.1.0/seatdata_sdk.egg-info/dependency_links.txt +1 -0
- seatdata_sdk-0.1.0/seatdata_sdk.egg-info/requires.txt +8 -0
- seatdata_sdk-0.1.0/seatdata_sdk.egg-info/top_level.txt +1 -0
- seatdata_sdk-0.1.0/setup.cfg +4 -0
- seatdata_sdk-0.1.0/setup.py +3 -0
- seatdata_sdk-0.1.0/tests/__init__.py +0 -0
- seatdata_sdk-0.1.0/tests/test_client.py +125 -0
- seatdata_sdk-0.1.0/tests/test_integration.py +103 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 SeatDataIO
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: seatdata-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python SDK for SeatData API
|
|
5
|
+
Author-email: SeatData <support@seatdata.io>
|
|
6
|
+
License: MIT
|
|
7
|
+
Classifier: Development Status :: 3 - Alpha
|
|
8
|
+
Classifier: Intended Audience :: Developers
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Requires-Python: >=3.8
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: requests>=2.31.0
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: pytest>=7.4.0; extra == "dev"
|
|
23
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
|
|
24
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
25
|
+
Requires-Dist: mypy>=1.5.0; extra == "dev"
|
|
26
|
+
Requires-Dist: types-requests>=2.31.0; extra == "dev"
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# SeatData Python SDK
|
|
30
|
+
|
|
31
|
+
[](https://badge.fury.io/py/seatdata-sdk)
|
|
32
|
+
[](https://github.com/SeatDataIO/python-sdk/actions/workflows/test.yml)
|
|
33
|
+
[](https://pypi.org/project/seatdata-sdk/)
|
|
34
|
+
[](https://opensource.org/licenses/MIT)
|
|
35
|
+
|
|
36
|
+
Official Python SDK for SeatData API - access ticket sales data, event listings, and search functionality.
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install seatdata-sdk
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Quick Start
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from seatdata import SeatDataClient
|
|
48
|
+
|
|
49
|
+
# Initialize client with your API key
|
|
50
|
+
client = SeatDataClient(api_key="your_64_char_api_key")
|
|
51
|
+
|
|
52
|
+
# Search for events
|
|
53
|
+
events = client.search_events(
|
|
54
|
+
venue_name="Madison Square Garden",
|
|
55
|
+
venue_city="New York"
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
# Get sales data for an event
|
|
59
|
+
sales_data = client.get_sales_data(event_id="1234567")
|
|
60
|
+
|
|
61
|
+
# Get current listings
|
|
62
|
+
listings = client.get_listings(event_id="1234567")
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## API Key
|
|
66
|
+
|
|
67
|
+
Contact support@seatdata.io to obtain an API key.
|
|
68
|
+
|
|
69
|
+
## Development
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Clone the repository
|
|
73
|
+
git clone https://github.com/SeatDataIO/python-sdk.git
|
|
74
|
+
cd python-sdk
|
|
75
|
+
|
|
76
|
+
# Install development dependencies
|
|
77
|
+
pip install -r requirements.txt
|
|
78
|
+
|
|
79
|
+
# Run tests
|
|
80
|
+
pytest
|
|
81
|
+
|
|
82
|
+
# Run integration tests (requires API key)
|
|
83
|
+
export SEATDATA_API_KEY="your_api_key"
|
|
84
|
+
pytest -m integration
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## License
|
|
88
|
+
|
|
89
|
+
MIT
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# SeatData Python SDK
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/py/seatdata-sdk)
|
|
4
|
+
[](https://github.com/SeatDataIO/python-sdk/actions/workflows/test.yml)
|
|
5
|
+
[](https://pypi.org/project/seatdata-sdk/)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
Official Python SDK for SeatData API - access ticket sales data, event listings, and search functionality.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
pip install seatdata-sdk
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Quick Start
|
|
17
|
+
|
|
18
|
+
```python
|
|
19
|
+
from seatdata import SeatDataClient
|
|
20
|
+
|
|
21
|
+
# Initialize client with your API key
|
|
22
|
+
client = SeatDataClient(api_key="your_64_char_api_key")
|
|
23
|
+
|
|
24
|
+
# Search for events
|
|
25
|
+
events = client.search_events(
|
|
26
|
+
venue_name="Madison Square Garden",
|
|
27
|
+
venue_city="New York"
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
# Get sales data for an event
|
|
31
|
+
sales_data = client.get_sales_data(event_id="1234567")
|
|
32
|
+
|
|
33
|
+
# Get current listings
|
|
34
|
+
listings = client.get_listings(event_id="1234567")
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## API Key
|
|
38
|
+
|
|
39
|
+
Contact support@seatdata.io to obtain an API key.
|
|
40
|
+
|
|
41
|
+
## Development
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Clone the repository
|
|
45
|
+
git clone https://github.com/SeatDataIO/python-sdk.git
|
|
46
|
+
cd python-sdk
|
|
47
|
+
|
|
48
|
+
# Install development dependencies
|
|
49
|
+
pip install -r requirements.txt
|
|
50
|
+
|
|
51
|
+
# Run tests
|
|
52
|
+
pytest
|
|
53
|
+
|
|
54
|
+
# Run integration tests (requires API key)
|
|
55
|
+
export SEATDATA_API_KEY="your_api_key"
|
|
56
|
+
pytest -m integration
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## License
|
|
60
|
+
|
|
61
|
+
MIT
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# SeatData SDK Examples
|
|
2
|
+
|
|
3
|
+
This directory contains example scripts showing how to use the SeatData Python SDK.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
1. Install the SDK:
|
|
8
|
+
```bash
|
|
9
|
+
pip install -e ..
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
2. Set your API key as an environment variable:
|
|
13
|
+
```bash
|
|
14
|
+
export SEATDATA_API_KEY="your_32_character_api_key_here"
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Examples
|
|
18
|
+
|
|
19
|
+
### basic_usage.py
|
|
20
|
+
Demonstrates basic SDK functionality including:
|
|
21
|
+
- Searching for events
|
|
22
|
+
- Retrieving sales data
|
|
23
|
+
- Getting current listings
|
|
24
|
+
|
|
25
|
+
Run it with:
|
|
26
|
+
```bash
|
|
27
|
+
python basic_usage.py
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Getting an API Key
|
|
31
|
+
|
|
32
|
+
Contact support@seatdata.io to obtain an API key for the SeatData API.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from seatdata import SeatDataClient
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def main():
|
|
6
|
+
api_key = os.environ.get("SEATDATA_API_KEY")
|
|
7
|
+
if not api_key:
|
|
8
|
+
print("Please set SEATDATA_API_KEY environment variable")
|
|
9
|
+
print("You can get an API key from support@seatdata.io")
|
|
10
|
+
return
|
|
11
|
+
|
|
12
|
+
with SeatDataClient(api_key=api_key) as client:
|
|
13
|
+
events = []
|
|
14
|
+
|
|
15
|
+
print("\n=== Searching for Events ===")
|
|
16
|
+
try:
|
|
17
|
+
events = client.search_events(
|
|
18
|
+
event_name="Taylor Swift",
|
|
19
|
+
venue_name="Madison Square Garden",
|
|
20
|
+
venue_city="New York",
|
|
21
|
+
venue_state="NY"
|
|
22
|
+
)
|
|
23
|
+
print(f"Found {len(events)} events")
|
|
24
|
+
for event in events[:3]:
|
|
25
|
+
print(f"- {event.get('event_name', 'N/A')} on {event.get('event_date', 'N/A')} at {event.get('venue_name', 'N/A')}")
|
|
26
|
+
except Exception as e:
|
|
27
|
+
print(f"Error searching events: {e}")
|
|
28
|
+
|
|
29
|
+
print("\n=== Getting Sales Data ===")
|
|
30
|
+
if events and len(events) > 0:
|
|
31
|
+
event_id = str(events[0]["event_id"])
|
|
32
|
+
event_name = events[0].get("event_name", "Unknown")
|
|
33
|
+
|
|
34
|
+
try:
|
|
35
|
+
sales_data = client.get_sales_data(event_id=event_id)
|
|
36
|
+
print(f"Retrieved sales data for {event_name} (ID: {event_id})")
|
|
37
|
+
print(f"Total sales records: {len(sales_data)}")
|
|
38
|
+
except Exception as e:
|
|
39
|
+
print(f"Error getting sales data: {e}")
|
|
40
|
+
|
|
41
|
+
print("\n=== Getting Current Listings ===")
|
|
42
|
+
try:
|
|
43
|
+
listings = client.get_listings(event_id=event_id)
|
|
44
|
+
print(f"Retrieved current listings for {event_name} (ID: {event_id})")
|
|
45
|
+
|
|
46
|
+
if "listings" in listings:
|
|
47
|
+
active_listings = [l for l in listings['listings'] if l.get('active')]
|
|
48
|
+
print(f"Active listings: {len(active_listings)}")
|
|
49
|
+
except Exception as e:
|
|
50
|
+
print(f"Error getting listings: {e}")
|
|
51
|
+
else:
|
|
52
|
+
print("No events found to get sales/listing data")
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
if __name__ == "__main__":
|
|
56
|
+
main()
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "seatdata-sdk"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Official Python SDK for SeatData API"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "MIT"}
|
|
11
|
+
authors = [
|
|
12
|
+
{name = "SeatData", email = "support@seatdata.io"}
|
|
13
|
+
]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.8",
|
|
20
|
+
"Programming Language :: Python :: 3.9",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Programming Language :: Python :: 3.13",
|
|
25
|
+
]
|
|
26
|
+
requires-python = ">=3.8"
|
|
27
|
+
dependencies = [
|
|
28
|
+
"requests>=2.31.0",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[project.optional-dependencies]
|
|
32
|
+
dev = [
|
|
33
|
+
"pytest>=7.4.0",
|
|
34
|
+
"pytest-cov>=4.1.0",
|
|
35
|
+
"black>=23.0.0",
|
|
36
|
+
"mypy>=1.5.0",
|
|
37
|
+
"types-requests>=2.31.0",
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
[tool.black]
|
|
41
|
+
line-length = 100
|
|
42
|
+
target-version = ["py38", "py39", "py310", "py311", "py312"]
|
|
43
|
+
|
|
44
|
+
[tool.mypy]
|
|
45
|
+
python_version = "3.8"
|
|
46
|
+
warn_return_any = true
|
|
47
|
+
warn_unused_configs = true
|
|
48
|
+
ignore_missing_imports = true
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
from typing import Dict, Any, Optional, List
|
|
2
|
+
import requests
|
|
3
|
+
|
|
4
|
+
from .exceptions import SeatDataException, AuthenticationError, RateLimitError
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class SeatDataClient:
|
|
8
|
+
BASE_URL = "https://seatdata.io/api"
|
|
9
|
+
|
|
10
|
+
def __init__(self, api_key: str, timeout: int = 30):
|
|
11
|
+
if not api_key or len(api_key) != 64:
|
|
12
|
+
raise ValueError("API key must be a 64-character hexadecimal string")
|
|
13
|
+
|
|
14
|
+
self.api_key = api_key
|
|
15
|
+
self.timeout = timeout
|
|
16
|
+
self.session = requests.Session()
|
|
17
|
+
self.session.headers.update({
|
|
18
|
+
"api-key": api_key,
|
|
19
|
+
"User-Agent": "SeatData-Python-SDK/0.1.0"
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
def _make_request(
|
|
23
|
+
self,
|
|
24
|
+
method: str,
|
|
25
|
+
endpoint: str,
|
|
26
|
+
params: Optional[Dict[str, Any]] = None,
|
|
27
|
+
json_data: Optional[Dict[str, Any]] = None
|
|
28
|
+
) -> Any:
|
|
29
|
+
url = self.BASE_URL + endpoint
|
|
30
|
+
|
|
31
|
+
try:
|
|
32
|
+
response = self.session.request(
|
|
33
|
+
method=method,
|
|
34
|
+
url=url,
|
|
35
|
+
params=params,
|
|
36
|
+
json=json_data,
|
|
37
|
+
timeout=self.timeout
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
if response.status_code == 401:
|
|
41
|
+
raise AuthenticationError("Invalid API key")
|
|
42
|
+
elif response.status_code == 429:
|
|
43
|
+
raise RateLimitError("Rate limit exceeded")
|
|
44
|
+
elif response.status_code == 400:
|
|
45
|
+
raise SeatDataException(f"Bad request: {response.text}")
|
|
46
|
+
|
|
47
|
+
response.raise_for_status()
|
|
48
|
+
|
|
49
|
+
return response.json()
|
|
50
|
+
|
|
51
|
+
except requests.exceptions.RequestException as e:
|
|
52
|
+
raise SeatDataException(f"Request failed: {str(e)}")
|
|
53
|
+
|
|
54
|
+
def get_sales_data(
|
|
55
|
+
self,
|
|
56
|
+
event_id: Optional[str] = None,
|
|
57
|
+
event_id_sh: Optional[str] = None
|
|
58
|
+
) -> List[Dict[str, Any]]:
|
|
59
|
+
if not event_id and not event_id_sh:
|
|
60
|
+
raise ValueError("Either event_id or event_id_sh must be provided")
|
|
61
|
+
|
|
62
|
+
params = {}
|
|
63
|
+
if event_id:
|
|
64
|
+
params["event_id"] = event_id
|
|
65
|
+
if event_id_sh:
|
|
66
|
+
params["event_id_sh"] = event_id_sh
|
|
67
|
+
|
|
68
|
+
return self._make_request("GET", "/v0.3/salesdata/get", params=params)
|
|
69
|
+
|
|
70
|
+
def get_listings(
|
|
71
|
+
self,
|
|
72
|
+
event_id: Optional[str] = None,
|
|
73
|
+
event_id_sh: Optional[str] = None
|
|
74
|
+
) -> Dict[str, Any]:
|
|
75
|
+
if not event_id and not event_id_sh:
|
|
76
|
+
raise ValueError("Either event_id or event_id_sh must be provided")
|
|
77
|
+
|
|
78
|
+
params = {}
|
|
79
|
+
if event_id:
|
|
80
|
+
params["event_id"] = event_id
|
|
81
|
+
if event_id_sh:
|
|
82
|
+
params["event_id_sh"] = event_id_sh
|
|
83
|
+
|
|
84
|
+
return self._make_request("GET", "/v0.1/listings/get", params=params)
|
|
85
|
+
|
|
86
|
+
def search_events(
|
|
87
|
+
self,
|
|
88
|
+
event_name: Optional[str] = None,
|
|
89
|
+
event_date: Optional[str] = None,
|
|
90
|
+
venue_name: Optional[str] = None,
|
|
91
|
+
venue_city: Optional[str] = None,
|
|
92
|
+
venue_state: Optional[str] = None,
|
|
93
|
+
return_full_response: bool = False,
|
|
94
|
+
**kwargs
|
|
95
|
+
) -> List[Dict[str, Any]]:
|
|
96
|
+
search_params = {}
|
|
97
|
+
|
|
98
|
+
if event_name:
|
|
99
|
+
search_params["event_name"] = event_name
|
|
100
|
+
if event_date:
|
|
101
|
+
search_params["event_date"] = event_date
|
|
102
|
+
if venue_name:
|
|
103
|
+
search_params["venue_name"] = venue_name
|
|
104
|
+
if venue_city:
|
|
105
|
+
search_params["venue_city"] = venue_city
|
|
106
|
+
if venue_state:
|
|
107
|
+
search_params["venue_state"] = venue_state
|
|
108
|
+
|
|
109
|
+
search_params.update(kwargs)
|
|
110
|
+
|
|
111
|
+
response = self._make_request("POST", "/v0.3.1/events/search", json_data=search_params)
|
|
112
|
+
|
|
113
|
+
if return_full_response:
|
|
114
|
+
return response
|
|
115
|
+
|
|
116
|
+
if isinstance(response, dict) and "items" in response:
|
|
117
|
+
return response["items"]
|
|
118
|
+
|
|
119
|
+
return response
|
|
120
|
+
|
|
121
|
+
def close(self):
|
|
122
|
+
self.session.close()
|
|
123
|
+
|
|
124
|
+
def __enter__(self):
|
|
125
|
+
return self
|
|
126
|
+
|
|
127
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
128
|
+
self.close()
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: seatdata-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python SDK for SeatData API
|
|
5
|
+
Author-email: SeatData <support@seatdata.io>
|
|
6
|
+
License: MIT
|
|
7
|
+
Classifier: Development Status :: 3 - Alpha
|
|
8
|
+
Classifier: Intended Audience :: Developers
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Requires-Python: >=3.8
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: requests>=2.31.0
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: pytest>=7.4.0; extra == "dev"
|
|
23
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
|
|
24
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
25
|
+
Requires-Dist: mypy>=1.5.0; extra == "dev"
|
|
26
|
+
Requires-Dist: types-requests>=2.31.0; extra == "dev"
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# SeatData Python SDK
|
|
30
|
+
|
|
31
|
+
[](https://badge.fury.io/py/seatdata-sdk)
|
|
32
|
+
[](https://github.com/SeatDataIO/python-sdk/actions/workflows/test.yml)
|
|
33
|
+
[](https://pypi.org/project/seatdata-sdk/)
|
|
34
|
+
[](https://opensource.org/licenses/MIT)
|
|
35
|
+
|
|
36
|
+
Official Python SDK for SeatData API - access ticket sales data, event listings, and search functionality.
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install seatdata-sdk
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Quick Start
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from seatdata import SeatDataClient
|
|
48
|
+
|
|
49
|
+
# Initialize client with your API key
|
|
50
|
+
client = SeatDataClient(api_key="your_64_char_api_key")
|
|
51
|
+
|
|
52
|
+
# Search for events
|
|
53
|
+
events = client.search_events(
|
|
54
|
+
venue_name="Madison Square Garden",
|
|
55
|
+
venue_city="New York"
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
# Get sales data for an event
|
|
59
|
+
sales_data = client.get_sales_data(event_id="1234567")
|
|
60
|
+
|
|
61
|
+
# Get current listings
|
|
62
|
+
listings = client.get_listings(event_id="1234567")
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## API Key
|
|
66
|
+
|
|
67
|
+
Contact support@seatdata.io to obtain an API key.
|
|
68
|
+
|
|
69
|
+
## Development
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Clone the repository
|
|
73
|
+
git clone https://github.com/SeatDataIO/python-sdk.git
|
|
74
|
+
cd python-sdk
|
|
75
|
+
|
|
76
|
+
# Install development dependencies
|
|
77
|
+
pip install -r requirements.txt
|
|
78
|
+
|
|
79
|
+
# Run tests
|
|
80
|
+
pytest
|
|
81
|
+
|
|
82
|
+
# Run integration tests (requires API key)
|
|
83
|
+
export SEATDATA_API_KEY="your_api_key"
|
|
84
|
+
pytest -m integration
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## License
|
|
88
|
+
|
|
89
|
+
MIT
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
README.md
|
|
4
|
+
pyproject.toml
|
|
5
|
+
requirements.txt
|
|
6
|
+
setup.py
|
|
7
|
+
examples/README.md
|
|
8
|
+
examples/basic_usage.py
|
|
9
|
+
seatdata/__init__.py
|
|
10
|
+
seatdata/client.py
|
|
11
|
+
seatdata/exceptions.py
|
|
12
|
+
seatdata_sdk.egg-info/PKG-INFO
|
|
13
|
+
seatdata_sdk.egg-info/SOURCES.txt
|
|
14
|
+
seatdata_sdk.egg-info/dependency_links.txt
|
|
15
|
+
seatdata_sdk.egg-info/requires.txt
|
|
16
|
+
seatdata_sdk.egg-info/top_level.txt
|
|
17
|
+
tests/__init__.py
|
|
18
|
+
tests/test_client.py
|
|
19
|
+
tests/test_integration.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
seatdata
|
|
File without changes
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from unittest.mock import Mock, patch
|
|
3
|
+
|
|
4
|
+
from seatdata import SeatDataClient, SeatDataException, AuthenticationError, RateLimitError
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class TestSeatDataClient:
|
|
8
|
+
|
|
9
|
+
def test_init_valid_api_key(self):
|
|
10
|
+
api_key = "a" * 64
|
|
11
|
+
client = SeatDataClient(api_key=api_key)
|
|
12
|
+
assert client.api_key == api_key
|
|
13
|
+
assert client.timeout == 30
|
|
14
|
+
|
|
15
|
+
def test_init_invalid_api_key_length(self):
|
|
16
|
+
with pytest.raises(ValueError, match="API key must be a 64-character hexadecimal string"):
|
|
17
|
+
SeatDataClient(api_key="short_key")
|
|
18
|
+
|
|
19
|
+
def test_init_empty_api_key(self):
|
|
20
|
+
with pytest.raises(ValueError, match="API key must be a 64-character hexadecimal string"):
|
|
21
|
+
SeatDataClient(api_key="")
|
|
22
|
+
|
|
23
|
+
@patch("seatdata.client.requests.Session")
|
|
24
|
+
def test_authentication_error(self, mock_session):
|
|
25
|
+
mock_response = Mock()
|
|
26
|
+
mock_response.status_code = 401
|
|
27
|
+
mock_session.return_value.request.return_value = mock_response
|
|
28
|
+
|
|
29
|
+
client = SeatDataClient(api_key="a" * 64)
|
|
30
|
+
|
|
31
|
+
with pytest.raises(AuthenticationError, match="Invalid API key"):
|
|
32
|
+
client.get_sales_data(event_id="test_event")
|
|
33
|
+
|
|
34
|
+
@patch("seatdata.client.requests.Session")
|
|
35
|
+
def test_rate_limit_error(self, mock_session):
|
|
36
|
+
mock_response = Mock()
|
|
37
|
+
mock_response.status_code = 429
|
|
38
|
+
mock_session.return_value.request.return_value = mock_response
|
|
39
|
+
|
|
40
|
+
client = SeatDataClient(api_key="a" * 64)
|
|
41
|
+
|
|
42
|
+
with pytest.raises(RateLimitError, match="Rate limit exceeded"):
|
|
43
|
+
client.search_events(event_name="test")
|
|
44
|
+
|
|
45
|
+
@patch("seatdata.client.requests.Session")
|
|
46
|
+
def test_bad_request_error(self, mock_session):
|
|
47
|
+
mock_response = Mock()
|
|
48
|
+
mock_response.status_code = 400
|
|
49
|
+
mock_response.text = "Missing required parameter"
|
|
50
|
+
mock_session.return_value.request.return_value = mock_response
|
|
51
|
+
|
|
52
|
+
client = SeatDataClient(api_key="a" * 64)
|
|
53
|
+
|
|
54
|
+
with pytest.raises(SeatDataException, match="Bad request: Missing required parameter"):
|
|
55
|
+
client.get_listings(event_id="test")
|
|
56
|
+
|
|
57
|
+
@patch("seatdata.client.requests.Session")
|
|
58
|
+
def test_get_sales_data_success(self, mock_session):
|
|
59
|
+
test_data = {"sales": [{"price": 100, "quantity": 2}]}
|
|
60
|
+
|
|
61
|
+
mock_response = Mock()
|
|
62
|
+
mock_response.status_code = 200
|
|
63
|
+
mock_response.json.return_value = test_data
|
|
64
|
+
mock_session.return_value.request.return_value = mock_response
|
|
65
|
+
|
|
66
|
+
client = SeatDataClient(api_key="a" * 64)
|
|
67
|
+
result = client.get_sales_data(event_id="test_event")
|
|
68
|
+
|
|
69
|
+
assert result == test_data
|
|
70
|
+
mock_session.return_value.request.assert_called_once()
|
|
71
|
+
|
|
72
|
+
@patch("seatdata.client.requests.Session")
|
|
73
|
+
def test_get_listings_success(self, mock_session):
|
|
74
|
+
test_data = {"listings": [{"id": "123", "price": 50}]}
|
|
75
|
+
|
|
76
|
+
mock_response = Mock()
|
|
77
|
+
mock_response.status_code = 200
|
|
78
|
+
mock_response.headers = {}
|
|
79
|
+
mock_response.json.return_value = test_data
|
|
80
|
+
mock_session.return_value.request.return_value = mock_response
|
|
81
|
+
|
|
82
|
+
client = SeatDataClient(api_key="a" * 64)
|
|
83
|
+
result = client.get_listings(event_id_sh="test_sh_id")
|
|
84
|
+
|
|
85
|
+
assert result == test_data
|
|
86
|
+
|
|
87
|
+
def test_get_sales_data_missing_params(self):
|
|
88
|
+
client = SeatDataClient(api_key="a" * 64)
|
|
89
|
+
|
|
90
|
+
with pytest.raises(ValueError, match="Either event_id or event_id_sh must be provided"):
|
|
91
|
+
client.get_sales_data()
|
|
92
|
+
|
|
93
|
+
def test_get_listings_missing_params(self):
|
|
94
|
+
client = SeatDataClient(api_key="a" * 64)
|
|
95
|
+
|
|
96
|
+
with pytest.raises(ValueError, match="Either event_id or event_id_sh must be provided"):
|
|
97
|
+
client.get_listings()
|
|
98
|
+
|
|
99
|
+
@patch("seatdata.client.requests.Session")
|
|
100
|
+
def test_search_events_success(self, mock_session):
|
|
101
|
+
test_data = [{"event_name": "Concert", "venue": "Stadium"}]
|
|
102
|
+
|
|
103
|
+
mock_response = Mock()
|
|
104
|
+
mock_response.status_code = 200
|
|
105
|
+
mock_response.headers = {}
|
|
106
|
+
mock_response.json.return_value = test_data
|
|
107
|
+
mock_session.return_value.request.return_value = mock_response
|
|
108
|
+
|
|
109
|
+
client = SeatDataClient(api_key="a" * 64)
|
|
110
|
+
result = client.search_events(event_name="Concert", venue_name="Stadium")
|
|
111
|
+
|
|
112
|
+
assert result == test_data
|
|
113
|
+
|
|
114
|
+
call_args = mock_session.return_value.request.call_args
|
|
115
|
+
assert call_args.kwargs["json"] == {"event_name": "Concert", "venue_name": "Stadium"}
|
|
116
|
+
|
|
117
|
+
@patch("seatdata.client.requests.Session")
|
|
118
|
+
def test_context_manager(self, mock_session):
|
|
119
|
+
mock_close = Mock()
|
|
120
|
+
mock_session.return_value.close = mock_close
|
|
121
|
+
|
|
122
|
+
with SeatDataClient(api_key="a" * 64) as client:
|
|
123
|
+
assert client.api_key == "a" * 64
|
|
124
|
+
|
|
125
|
+
mock_close.assert_called_once()
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import pytest
|
|
3
|
+
from seatdata import SeatDataClient, AuthenticationError, RateLimitError
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@pytest.mark.integration
|
|
7
|
+
class TestSeatDataIntegration:
|
|
8
|
+
"""Integration tests that make real API calls.
|
|
9
|
+
|
|
10
|
+
Run with: pytest tests/test_integration.py -m integration
|
|
11
|
+
Requires: SEATDATA_API_KEY environment variable
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
@pytest.fixture
|
|
15
|
+
def api_key(self):
|
|
16
|
+
key = os.environ.get("SEATDATA_API_KEY")
|
|
17
|
+
if not key:
|
|
18
|
+
pytest.skip("SEATDATA_API_KEY environment variable not set")
|
|
19
|
+
if len(key) != 64:
|
|
20
|
+
pytest.skip("SEATDATA_API_KEY must be 64 characters")
|
|
21
|
+
return key
|
|
22
|
+
|
|
23
|
+
@pytest.fixture
|
|
24
|
+
def client(self, api_key):
|
|
25
|
+
return SeatDataClient(api_key=api_key)
|
|
26
|
+
|
|
27
|
+
def test_search_events_real(self, client):
|
|
28
|
+
"""Test searching for events with real API."""
|
|
29
|
+
try:
|
|
30
|
+
events = client.search_events(venue_name="Madison Square Garden")
|
|
31
|
+
assert isinstance(events, list)
|
|
32
|
+
print(f"\nFound {len(events)} events at Madison Square Garden")
|
|
33
|
+
|
|
34
|
+
if events:
|
|
35
|
+
first_event = events[0]
|
|
36
|
+
print(f"First event: {first_event.get('event_name', 'N/A')} on {first_event.get('event_date', 'N/A')}")
|
|
37
|
+
except RateLimitError:
|
|
38
|
+
pytest.skip("Rate limit hit - test later")
|
|
39
|
+
except AuthenticationError:
|
|
40
|
+
pytest.fail("Invalid API key")
|
|
41
|
+
|
|
42
|
+
def test_search_events_by_name(self, client):
|
|
43
|
+
"""Test searching events by name."""
|
|
44
|
+
try:
|
|
45
|
+
events = client.search_events(event_name="Lakers")
|
|
46
|
+
assert isinstance(events, list)
|
|
47
|
+
print(f"\nFound {len(events)} Lakers events")
|
|
48
|
+
except RateLimitError:
|
|
49
|
+
pytest.skip("Rate limit hit - test later")
|
|
50
|
+
|
|
51
|
+
def test_invalid_api_key(self):
|
|
52
|
+
"""Test that invalid API key raises AuthenticationError."""
|
|
53
|
+
bad_client = SeatDataClient(api_key="0" * 64)
|
|
54
|
+
|
|
55
|
+
with pytest.raises(AuthenticationError):
|
|
56
|
+
bad_client.search_events(venue_name="test")
|
|
57
|
+
|
|
58
|
+
def test_get_sales_data_real(self, client):
|
|
59
|
+
"""Test getting sales data with real API."""
|
|
60
|
+
try:
|
|
61
|
+
# First get an event_id from search
|
|
62
|
+
events = client.search_events(venue_name="Madison Square Garden")
|
|
63
|
+
if not events:
|
|
64
|
+
pytest.skip("No events found to test with")
|
|
65
|
+
|
|
66
|
+
event_id = str(events[0]["event_id"])
|
|
67
|
+
print(f"\nTesting sales data for event: {events[0].get('event_name')} (ID: {event_id})")
|
|
68
|
+
|
|
69
|
+
sales_data = client.get_sales_data(event_id=event_id)
|
|
70
|
+
assert isinstance(sales_data, list)
|
|
71
|
+
print(f"Found {len(sales_data)} sales records")
|
|
72
|
+
|
|
73
|
+
if sales_data:
|
|
74
|
+
first_sale = sales_data[0]
|
|
75
|
+
print(f"First sale keys: {first_sale.keys() if isinstance(first_sale, dict) else 'N/A'}")
|
|
76
|
+
except RateLimitError:
|
|
77
|
+
pytest.skip("Rate limit hit - test later")
|
|
78
|
+
except AuthenticationError:
|
|
79
|
+
pytest.fail("Invalid API key")
|
|
80
|
+
|
|
81
|
+
def test_get_listings_real(self, client):
|
|
82
|
+
"""Test getting listings with real API."""
|
|
83
|
+
try:
|
|
84
|
+
# First get an event_id from search
|
|
85
|
+
events = client.search_events(venue_name="Madison Square Garden")
|
|
86
|
+
if not events:
|
|
87
|
+
pytest.skip("No events found to test with")
|
|
88
|
+
|
|
89
|
+
event_id = str(events[0]["event_id"])
|
|
90
|
+
print(f"\nTesting listings for event: {events[0].get('event_name')} (ID: {event_id})")
|
|
91
|
+
|
|
92
|
+
listings = client.get_listings(event_id=event_id)
|
|
93
|
+
assert isinstance(listings, dict)
|
|
94
|
+
print(f"Listings keys: {listings.keys()}")
|
|
95
|
+
|
|
96
|
+
if "listings" in listings:
|
|
97
|
+
print(f"Found {len(listings['listings'])} current listings")
|
|
98
|
+
active_count = sum(1 for l in listings['listings'] if l.get('active'))
|
|
99
|
+
print(f"Active listings: {active_count}")
|
|
100
|
+
except RateLimitError:
|
|
101
|
+
pytest.skip("Rate limit hit - test later")
|
|
102
|
+
except AuthenticationError:
|
|
103
|
+
pytest.fail("Invalid API key")
|