dexscreen 0.0.1__tar.gz → 0.0.4__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.
Files changed (94) hide show
  1. dexscreen-0.0.4/.github/workflows/docs.yml +48 -0
  2. {dexscreen-0.0.1 → dexscreen-0.0.4}/.github/workflows/release.yml +6 -4
  3. {dexscreen-0.0.1 → dexscreen-0.0.4}/.gitignore +5 -0
  4. {dexscreen-0.0.1 → dexscreen-0.0.4}/.yamllint +1 -0
  5. {dexscreen-0.0.1 → dexscreen-0.0.4}/PKG-INFO +52 -1
  6. {dexscreen-0.0.1 → dexscreen-0.0.4}/README.md +51 -0
  7. dexscreen-0.0.4/dexscreen/__init__.py +118 -0
  8. {dexscreen-0.0.1 → dexscreen-0.0.4}/dexscreen/api/client.py +275 -42
  9. dexscreen-0.0.4/dexscreen/core/exceptions.py +1067 -0
  10. dexscreen-0.0.4/dexscreen/core/http.py +1204 -0
  11. dexscreen-0.0.4/dexscreen/core/validators.py +542 -0
  12. {dexscreen-0.0.1 → dexscreen-0.0.4}/dexscreen/stream/polling.py +288 -78
  13. dexscreen-0.0.4/dexscreen/utils/__init__.py +57 -0
  14. {dexscreen-0.0.1 → dexscreen-0.0.4}/dexscreen/utils/filters.py +182 -12
  15. dexscreen-0.0.4/dexscreen/utils/logging_config.py +421 -0
  16. dexscreen-0.0.4/dexscreen/utils/middleware.py +363 -0
  17. dexscreen-0.0.4/dexscreen/utils/ratelimit.py +269 -0
  18. dexscreen-0.0.4/dexscreen/utils/retry.py +357 -0
  19. {dexscreen-0.0.1 → dexscreen-0.0.4}/docs/examples.zh.md +3 -3
  20. {dexscreen-0.0.1 → dexscreen-0.0.4}/docs/getting-started.zh.md +5 -5
  21. {dexscreen-0.0.1 → dexscreen-0.0.4}/docs/index.md +5 -5
  22. {dexscreen-0.0.1 → dexscreen-0.0.4}/docs/index.zh.md +17 -17
  23. {dexscreen-0.0.1 → dexscreen-0.0.4}/examples/01_async_basic_apis.py +4 -0
  24. {dexscreen-0.0.1 → dexscreen-0.0.4}/examples/03_token_address_polling.py +4 -1
  25. dexscreen-0.0.4/examples/05_exception_handling.py +210 -0
  26. dexscreen-0.0.4/examples/06_timeout_configuration.py +254 -0
  27. {dexscreen-0.0.1 → dexscreen-0.0.4}/justfile +1 -1
  28. {dexscreen-0.0.1 → dexscreen-0.0.4}/mkdocs.yml +4 -0
  29. {dexscreen-0.0.1 → dexscreen-0.0.4}/package.json +0 -1
  30. {dexscreen-0.0.1 → dexscreen-0.0.4}/pyproject.toml +5 -5
  31. {dexscreen-0.0.1 → dexscreen-0.0.4}/tests/conftest.py +48 -27
  32. {dexscreen-0.0.1 → dexscreen-0.0.4}/tests/unit/api/test_batch_limits.py +69 -55
  33. dexscreen-0.0.4/tests/unit/api/test_batch_limits_integration.py +293 -0
  34. dexscreen-0.0.4/tests/unit/api/test_client.py +703 -0
  35. dexscreen-0.0.4/tests/unit/api/test_client_comprehensive.py +946 -0
  36. dexscreen-0.0.4/tests/unit/api/test_client_error_handling.py +795 -0
  37. dexscreen-0.0.4/tests/unit/api/test_client_subscriptions.py +858 -0
  38. dexscreen-0.0.4/tests/unit/api/test_timeout_functionality.py +376 -0
  39. {dexscreen-0.0.1 → dexscreen-0.0.4}/tests/unit/core/test_dynamic_config.py +75 -46
  40. dexscreen-0.0.4/tests/unit/core/test_http.py +558 -0
  41. dexscreen-0.0.4/tests/unit/utils/test_retry.py +423 -0
  42. {dexscreen-0.0.1 → dexscreen-0.0.4}/uv.lock +1 -1
  43. dexscreen-0.0.1/dexscreen/__init__.py +0 -31
  44. dexscreen-0.0.1/dexscreen/core/http.py +0 -460
  45. dexscreen-0.0.1/dexscreen/utils/__init__.py +0 -4
  46. dexscreen-0.0.1/dexscreen/utils/ratelimit.py +0 -65
  47. dexscreen-0.0.1/tests/unit/api/test_batch_limits_integration.py +0 -112
  48. dexscreen-0.0.1/tests/unit/api/test_client.py +0 -251
  49. dexscreen-0.0.1/tests/unit/core/test_http.py +0 -206
  50. dexscreen-0.0.1/tests/unit/core/test_models_simple.py +0 -74
  51. {dexscreen-0.0.1 → dexscreen-0.0.4}/.gitattributes +0 -0
  52. {dexscreen-0.0.1 → dexscreen-0.0.4}/.github/workflows/ci.yml +0 -0
  53. {dexscreen-0.0.1 → dexscreen-0.0.4}/.nvmrc +0 -0
  54. {dexscreen-0.0.1 → dexscreen-0.0.4}/.pre-commit-config.yaml +0 -0
  55. {dexscreen-0.0.1 → dexscreen-0.0.4}/.prettierignore +0 -0
  56. {dexscreen-0.0.1 → dexscreen-0.0.4}/.prettierrc.json +0 -0
  57. {dexscreen-0.0.1 → dexscreen-0.0.4}/LICENSE +0 -0
  58. {dexscreen-0.0.1 → dexscreen-0.0.4}/dexscreen/api/__init__.py +0 -0
  59. {dexscreen-0.0.1 → dexscreen-0.0.4}/dexscreen/config/__init__.py +0 -0
  60. {dexscreen-0.0.1 → dexscreen-0.0.4}/dexscreen/core/__init__.py +0 -0
  61. {dexscreen-0.0.1 → dexscreen-0.0.4}/dexscreen/core/models.py +0 -0
  62. {dexscreen-0.0.1 → dexscreen-0.0.4}/dexscreen/stream/__init__.py +0 -0
  63. {dexscreen-0.0.1 → dexscreen-0.0.4}/dexscreen/utils/browser_selector.py +0 -0
  64. {dexscreen-0.0.1 → dexscreen-0.0.4}/docs/README.md +0 -0
  65. {dexscreen-0.0.1 → dexscreen-0.0.4}/docs/api/data-models.md +0 -0
  66. {dexscreen-0.0.1 → dexscreen-0.0.4}/docs/api/data-models.zh.md +0 -0
  67. {dexscreen-0.0.1 → dexscreen-0.0.4}/docs/api/filtering.md +0 -0
  68. {dexscreen-0.0.1 → dexscreen-0.0.4}/docs/api/filtering.zh.md +0 -0
  69. {dexscreen-0.0.1 → dexscreen-0.0.4}/docs/api/query-api.md +0 -0
  70. {dexscreen-0.0.1 → dexscreen-0.0.4}/docs/api/query-api.zh.md +0 -0
  71. {dexscreen-0.0.1 → dexscreen-0.0.4}/docs/api/streaming-api.md +0 -0
  72. {dexscreen-0.0.1 → dexscreen-0.0.4}/docs/api/streaming-api.zh.md +0 -0
  73. {dexscreen-0.0.1 → dexscreen-0.0.4}/docs/examples.md +0 -0
  74. {dexscreen-0.0.1 → dexscreen-0.0.4}/docs/getting-started.md +0 -0
  75. {dexscreen-0.0.1 → dexscreen-0.0.4}/examples/02_dynamic_config_update.py +0 -0
  76. {dexscreen-0.0.1 → dexscreen-0.0.4}/examples/04_dynamic_subscription.py +0 -0
  77. {dexscreen-0.0.1 → dexscreen-0.0.4}/pnpm-lock.yaml +0 -0
  78. {dexscreen-0.0.1 → dexscreen-0.0.4}/tests/integration/test_api_response_format.py +0 -0
  79. {dexscreen-0.0.1 → dexscreen-0.0.4}/tests/integration/test_examples.py +0 -0
  80. {dexscreen-0.0.1 → dexscreen-0.0.4}/tests/integration/test_pool_endpoint.py +0 -0
  81. {dexscreen-0.0.1 → dexscreen-0.0.4}/tests/integration/test_token_endpoints.py +0 -0
  82. {dexscreen-0.0.1 → dexscreen-0.0.4}/tests/unit/__init__.py +0 -0
  83. {dexscreen-0.0.1 → dexscreen-0.0.4}/tests/unit/api/__init__.py +0 -0
  84. {dexscreen-0.0.1 → dexscreen-0.0.4}/tests/unit/core/__init__.py +0 -0
  85. {dexscreen-0.0.1 → dexscreen-0.0.4}/tests/unit/core/test_models.py +0 -0
  86. {dexscreen-0.0.1 → dexscreen-0.0.4}/tests/unit/stream/__init__.py +0 -0
  87. {dexscreen-0.0.1 → dexscreen-0.0.4}/tests/unit/stream/test_batch_polling.py +0 -0
  88. {dexscreen-0.0.1 → dexscreen-0.0.4}/tests/unit/stream/test_polling.py +0 -0
  89. {dexscreen-0.0.1 → dexscreen-0.0.4}/tests/unit/utils/__init__.py +0 -0
  90. {dexscreen-0.0.1 → dexscreen-0.0.4}/tests/unit/utils/test_filters.py +0 -0
  91. {dexscreen-0.0.1 → dexscreen-0.0.4}/tests/unit/utils/test_ratelimit.py +0 -0
  92. {dexscreen-0.0.1 → dexscreen-0.0.4}/tests/upstream/test_official_api.py +0 -0
  93. {dexscreen-0.0.1 → dexscreen-0.0.4}/tests/upstream/test_official_api_multi.py +0 -0
  94. {dexscreen-0.0.1 → dexscreen-0.0.4}/tests/upstream/test_official_api_rate.py +0 -0
@@ -0,0 +1,48 @@
1
+ name: Deploy Docs
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ paths:
7
+ - "docs/**"
8
+ - "mkdocs.yml"
9
+ - ".github/workflows/docs.yml"
10
+ - "README.md"
11
+ - "dexscreen/**/*.py" # API changes might need doc updates
12
+ workflow_dispatch:
13
+
14
+ permissions:
15
+ contents: write
16
+ pages: write
17
+ id-token: write
18
+
19
+ jobs:
20
+ deploy:
21
+ runs-on: ubuntu-latest
22
+ steps:
23
+ - uses: actions/checkout@v4
24
+ with:
25
+ fetch-depth: 0
26
+
27
+ - name: Install uv
28
+ uses: astral-sh/setup-uv@v3
29
+
30
+ - name: Set up Python
31
+ run: uv python install 3.12
32
+
33
+ - name: Install dependencies
34
+ run: uv sync --dev
35
+
36
+ - name: Build docs
37
+ run: uv run mkdocs build
38
+
39
+ - name: Deploy to GitHub Pages
40
+ uses: peaceiris/actions-gh-pages@v4
41
+ with:
42
+ github_token: ${{ secrets.GITHUB_TOKEN }}
43
+ publish_dir: ./site
44
+ publish_branch: gh-pages
45
+ force_orphan: true
46
+ user_name: "github-actions[bot]"
47
+ user_email: "github-actions[bot]@users.noreply.github.com"
48
+ commit_message: "Deploy docs from ${{ github.sha }}"
@@ -3,7 +3,7 @@ name: Release
3
3
  on:
4
4
  push:
5
5
  tags:
6
- - 'v*'
6
+ - "v*"
7
7
 
8
8
  jobs:
9
9
  build_and_publish:
@@ -31,6 +31,8 @@ jobs:
31
31
  path: dist/
32
32
 
33
33
  - name: Publish to PyPI
34
- uses: pypa/gh-action-pypi-publish@release/v1
35
- with:
36
- password: ${{ secrets.PYPI_API_TOKEN }}
34
+ env:
35
+ UV_PUBLISH_TOKEN: ${{ secrets.UV_PUBLISH_TOKEN }}
36
+ run: |
37
+ uv build
38
+ uv publish
@@ -110,6 +110,11 @@ ENV/
110
110
  env.bak/
111
111
  venv.bak/
112
112
 
113
+ # Backup files
114
+ *.bak
115
+ *~
116
+ *.orig
117
+
113
118
  # Editor directories
114
119
  .zed/
115
120
 
@@ -24,6 +24,7 @@ ignore: |
24
24
  .pyright/
25
25
  .git/
26
26
  pnpm-lock.yaml
27
+ node_modules
27
28
 
28
29
  # 允许 Python 标签
29
30
  allowed-tags:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dexscreen
3
- Version: 0.0.1
3
+ Version: 0.0.4
4
4
  Summary: Python wrapper for Dexscreener API with stable HTTP support
5
5
  Project-URL: Repository, https://github.com/solanab/dexscreen
6
6
  Project-URL: Documentation, https://github.com/solanab/dexscreen#readme
@@ -68,8 +68,12 @@ pip install dexscreen
68
68
  ```python
69
69
  from dexscreen import DexscreenerClient
70
70
 
71
+ # Default client with 10-second timeout
71
72
  client = DexscreenerClient()
72
73
 
74
+ # Custom timeout client
75
+ client = DexscreenerClient(client_kwargs={"timeout": 30})
76
+
73
77
  # Get a specific pair by token address
74
78
  pairs = client.get_pairs_by_token_address("solana", "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN")
75
79
  if pairs:
@@ -259,6 +263,47 @@ The SDK automatically handles rate limiting:
259
263
  - 60 requests/minute for token profile endpoints
260
264
  - 300 requests/minute for pair data endpoints
261
265
 
266
+ ## Timeout Configuration
267
+
268
+ The SDK provides flexible timeout configuration for different use cases:
269
+
270
+ ### Default Timeout
271
+ ```python
272
+ # Default timeout is 10 seconds
273
+ client = DexscreenerClient()
274
+ ```
275
+
276
+ ### Custom Timeout
277
+ ```python
278
+ # Set custom timeout during initialization
279
+ client = DexscreenerClient(client_kwargs={"timeout": 30})
280
+
281
+ # Different timeouts for different scenarios
282
+ fast_client = DexscreenerClient(client_kwargs={"timeout": 5}) # Quick responses
283
+ stable_client = DexscreenerClient(client_kwargs={"timeout": 60}) # Stable connections
284
+ ```
285
+
286
+ ### Runtime Timeout Updates
287
+ ```python
288
+ # Update timeout at runtime
289
+ await client._client_300rpm.update_config({"timeout": 15})
290
+
291
+ # Multiple config updates including timeout
292
+ await client._client_300rpm.update_config({
293
+ "timeout": 25,
294
+ "impersonate": "chrome136"
295
+ })
296
+ ```
297
+
298
+ ### Recommended Timeout Values
299
+
300
+ | Use Case | Timeout (seconds) | Description |
301
+ |----------|------------------|-------------|
302
+ | Quick Trading | 5-10 | Fast response for time-sensitive operations |
303
+ | General Use | 10-15 | Default balanced setting |
304
+ | Stable Monitoring | 20-30 | Reliable for long-running subscriptions |
305
+ | Poor Networks | 30-60 | Handle unstable connections |
306
+
262
307
  ## Browser Impersonation
263
308
 
264
309
  The SDK uses curl_cffi for browser impersonation to bypass anti-bot protection:
@@ -267,6 +312,12 @@ The SDK uses curl_cffi for browser impersonation to bypass anti-bot protection:
267
312
  # Use different browser versions
268
313
  client = DexscreenerClient(impersonate="chrome134")
269
314
  client = DexscreenerClient(impersonate="safari180")
315
+
316
+ # Combine browser impersonation with custom timeout
317
+ client = DexscreenerClient(
318
+ impersonate="chrome136",
319
+ client_kwargs={"timeout": 20}
320
+ )
270
321
  ```
271
322
 
272
323
  ## Contributing
@@ -40,8 +40,12 @@ pip install dexscreen
40
40
  ```python
41
41
  from dexscreen import DexscreenerClient
42
42
 
43
+ # Default client with 10-second timeout
43
44
  client = DexscreenerClient()
44
45
 
46
+ # Custom timeout client
47
+ client = DexscreenerClient(client_kwargs={"timeout": 30})
48
+
45
49
  # Get a specific pair by token address
46
50
  pairs = client.get_pairs_by_token_address("solana", "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN")
47
51
  if pairs:
@@ -231,6 +235,47 @@ The SDK automatically handles rate limiting:
231
235
  - 60 requests/minute for token profile endpoints
232
236
  - 300 requests/minute for pair data endpoints
233
237
 
238
+ ## Timeout Configuration
239
+
240
+ The SDK provides flexible timeout configuration for different use cases:
241
+
242
+ ### Default Timeout
243
+ ```python
244
+ # Default timeout is 10 seconds
245
+ client = DexscreenerClient()
246
+ ```
247
+
248
+ ### Custom Timeout
249
+ ```python
250
+ # Set custom timeout during initialization
251
+ client = DexscreenerClient(client_kwargs={"timeout": 30})
252
+
253
+ # Different timeouts for different scenarios
254
+ fast_client = DexscreenerClient(client_kwargs={"timeout": 5}) # Quick responses
255
+ stable_client = DexscreenerClient(client_kwargs={"timeout": 60}) # Stable connections
256
+ ```
257
+
258
+ ### Runtime Timeout Updates
259
+ ```python
260
+ # Update timeout at runtime
261
+ await client._client_300rpm.update_config({"timeout": 15})
262
+
263
+ # Multiple config updates including timeout
264
+ await client._client_300rpm.update_config({
265
+ "timeout": 25,
266
+ "impersonate": "chrome136"
267
+ })
268
+ ```
269
+
270
+ ### Recommended Timeout Values
271
+
272
+ | Use Case | Timeout (seconds) | Description |
273
+ |----------|------------------|-------------|
274
+ | Quick Trading | 5-10 | Fast response for time-sensitive operations |
275
+ | General Use | 10-15 | Default balanced setting |
276
+ | Stable Monitoring | 20-30 | Reliable for long-running subscriptions |
277
+ | Poor Networks | 30-60 | Handle unstable connections |
278
+
234
279
  ## Browser Impersonation
235
280
 
236
281
  The SDK uses curl_cffi for browser impersonation to bypass anti-bot protection:
@@ -239,6 +284,12 @@ The SDK uses curl_cffi for browser impersonation to bypass anti-bot protection:
239
284
  # Use different browser versions
240
285
  client = DexscreenerClient(impersonate="chrome134")
241
286
  client = DexscreenerClient(impersonate="safari180")
287
+
288
+ # Combine browser impersonation with custom timeout
289
+ client = DexscreenerClient(
290
+ impersonate="chrome136",
291
+ client_kwargs={"timeout": 20}
292
+ )
242
293
  ```
243
294
 
244
295
  ## Contributing
@@ -0,0 +1,118 @@
1
+ """
2
+ Dexscreen - Python SDK for DexScreener API
3
+
4
+ A modern, stable, and reliable Python SDK for DexScreener API with HTTP support.
5
+ """
6
+
7
+ from .api.client import DexscreenerClient
8
+ from .core.exceptions import (
9
+ # API errors
10
+ APIError,
11
+ APILimitError,
12
+ AuthenticationError,
13
+ # Configuration errors
14
+ ConfigurationError,
15
+ ConnectionError,
16
+ DataFormatError,
17
+ # Base exceptions
18
+ DexscreenError,
19
+ FilterConfigError,
20
+ HttpConnectionError,
21
+ # HTTP errors
22
+ HttpError,
23
+ HttpRequestError,
24
+ HttpResponseParsingError,
25
+ HttpSessionError,
26
+ HttpTimeoutError,
27
+ InvalidAddressError,
28
+ InvalidChainError,
29
+ InvalidConfigError,
30
+ InvalidResponseError,
31
+ MissingConfigError,
32
+ MissingDataError,
33
+ # Network errors
34
+ NetworkError,
35
+ ProxyError,
36
+ RateLimitError,
37
+ ServerError,
38
+ StreamConnectionError,
39
+ StreamDataError,
40
+ # Streaming errors
41
+ StreamError,
42
+ StreamTimeoutError,
43
+ SubscriptionError,
44
+ TimeoutError,
45
+ # Validation errors
46
+ ValidationError,
47
+ # Utility functions
48
+ get_error_category,
49
+ is_retryable_error,
50
+ should_wait_before_retry,
51
+ )
52
+ from .core.models import (
53
+ BaseToken,
54
+ Liquidity,
55
+ PairTransactionCounts,
56
+ PriceChangePeriods,
57
+ TokenPair,
58
+ TransactionCount,
59
+ VolumeChangePeriods,
60
+ )
61
+ from .utils.filters import FilterConfig, FilterPresets
62
+
63
+ __version__ = "1.0.0"
64
+ __all__ = [
65
+ # API errors
66
+ "APIError",
67
+ "APILimitError",
68
+ "AuthenticationError",
69
+ # Core models and client
70
+ "BaseToken",
71
+ # Configuration errors
72
+ "ConfigurationError",
73
+ "ConnectionError",
74
+ "DataFormatError",
75
+ # Base exceptions
76
+ "DexscreenError",
77
+ "DexscreenerClient",
78
+ "FilterConfig",
79
+ "FilterConfigError",
80
+ "FilterPresets",
81
+ "HttpConnectionError",
82
+ # HTTP errors
83
+ "HttpError",
84
+ "HttpRequestError",
85
+ "HttpResponseParsingError",
86
+ "HttpSessionError",
87
+ "HttpTimeoutError",
88
+ "InvalidAddressError",
89
+ "InvalidChainError",
90
+ "InvalidConfigError",
91
+ "InvalidResponseError",
92
+ "Liquidity",
93
+ "MissingConfigError",
94
+ "MissingDataError",
95
+ # Network errors
96
+ "NetworkError",
97
+ "PairTransactionCounts",
98
+ "PriceChangePeriods",
99
+ "ProxyError",
100
+ "RateLimitError",
101
+ "ServerError",
102
+ "StreamConnectionError",
103
+ "StreamDataError",
104
+ # Streaming errors
105
+ "StreamError",
106
+ "StreamTimeoutError",
107
+ "SubscriptionError",
108
+ "TimeoutError",
109
+ "TokenPair",
110
+ "TransactionCount",
111
+ # Validation errors
112
+ "ValidationError",
113
+ "VolumeChangePeriods",
114
+ # Utility functions
115
+ "get_error_category",
116
+ "is_retryable_error",
117
+ "should_wait_before_retry",
118
+ ]