gamegains-sdk 0.0.2__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 (146) hide show
  1. gamegains_sdk-0.0.2/PKG-INFO +591 -0
  2. gamegains_sdk-0.0.2/README.md +578 -0
  3. gamegains_sdk-0.0.2/pyproject.toml +54 -0
  4. gamegains_sdk-0.0.2/setup.cfg +4 -0
  5. gamegains_sdk-0.0.2/src/gamegains_sdk/__init__.py +17 -0
  6. gamegains_sdk-0.0.2/src/gamegains_sdk/_eip712.py +162 -0
  7. gamegains_sdk-0.0.2/src/gamegains_sdk/_hooks/__init__.py +5 -0
  8. gamegains_sdk-0.0.2/src/gamegains_sdk/_hooks/registration.py +19 -0
  9. gamegains_sdk-0.0.2/src/gamegains_sdk/_hooks/sdkhooks.py +76 -0
  10. gamegains_sdk-0.0.2/src/gamegains_sdk/_hooks/types.py +124 -0
  11. gamegains_sdk-0.0.2/src/gamegains_sdk/_signing.py +78 -0
  12. gamegains_sdk-0.0.2/src/gamegains_sdk/_version.py +15 -0
  13. gamegains_sdk-0.0.2/src/gamegains_sdk/account.py +193 -0
  14. gamegains_sdk-0.0.2/src/gamegains_sdk/auth.py +572 -0
  15. gamegains_sdk-0.0.2/src/gamegains_sdk/basesdk.py +396 -0
  16. gamegains_sdk-0.0.2/src/gamegains_sdk/collateral.py +187 -0
  17. gamegains_sdk-0.0.2/src/gamegains_sdk/errors/__init__.py +39 -0
  18. gamegains_sdk-0.0.2/src/gamegains_sdk/errors/errorresponse.py +29 -0
  19. gamegains_sdk-0.0.2/src/gamegains_sdk/errors/gamegainsdefaulterror.py +40 -0
  20. gamegains_sdk-0.0.2/src/gamegains_sdk/errors/gamegainserror.py +30 -0
  21. gamegains_sdk-0.0.2/src/gamegains_sdk/errors/no_response_error.py +17 -0
  22. gamegains_sdk-0.0.2/src/gamegains_sdk/errors/responsevalidationerror.py +27 -0
  23. gamegains_sdk-0.0.2/src/gamegains_sdk/httpclient.py +125 -0
  24. gamegains_sdk-0.0.2/src/gamegains_sdk/lp.py +352 -0
  25. gamegains_sdk-0.0.2/src/gamegains_sdk/market_data.py +694 -0
  26. gamegains_sdk-0.0.2/src/gamegains_sdk/markets.py +1066 -0
  27. gamegains_sdk-0.0.2/src/gamegains_sdk/models/__init__.py +831 -0
  28. gamegains_sdk-0.0.2/src/gamegains_sdk/models/accountcollateral.py +32 -0
  29. gamegains_sdk-0.0.2/src/gamegains_sdk/models/accountinfo.py +52 -0
  30. gamegains_sdk-0.0.2/src/gamegains_sdk/models/addmarginresult.py +16 -0
  31. gamegains_sdk-0.0.2/src/gamegains_sdk/models/addpositionmarginop.py +64 -0
  32. gamegains_sdk-0.0.2/src/gamegains_sdk/models/amendorderop.py +26 -0
  33. gamegains_sdk-0.0.2/src/gamegains_sdk/models/amendrequest.py +58 -0
  34. gamegains_sdk-0.0.2/src/gamegains_sdk/models/amendresult.py +69 -0
  35. gamegains_sdk-0.0.2/src/gamegains_sdk/models/batchorderresult.py +52 -0
  36. gamegains_sdk-0.0.2/src/gamegains_sdk/models/batchreplaceresult.py +38 -0
  37. gamegains_sdk-0.0.2/src/gamegains_sdk/models/cancelallordersop.py +47 -0
  38. gamegains_sdk-0.0.2/src/gamegains_sdk/models/cancelallresult.py +24 -0
  39. gamegains_sdk-0.0.2/src/gamegains_sdk/models/cancelorderbatchop.py +43 -0
  40. gamegains_sdk-0.0.2/src/gamegains_sdk/models/cancelorderbyclientidop.py +19 -0
  41. gamegains_sdk-0.0.2/src/gamegains_sdk/models/cancelorderop.py +19 -0
  42. gamegains_sdk-0.0.2/src/gamegains_sdk/models/cancelresult.py +58 -0
  43. gamegains_sdk-0.0.2/src/gamegains_sdk/models/claimrevshareop.py +25 -0
  44. gamegains_sdk-0.0.2/src/gamegains_sdk/models/clearpositiontpslop.py +70 -0
  45. gamegains_sdk-0.0.2/src/gamegains_sdk/models/collateralinfo.py +30 -0
  46. gamegains_sdk-0.0.2/src/gamegains_sdk/models/createapikeyop.py +52 -0
  47. gamegains_sdk-0.0.2/src/gamegains_sdk/models/createapikeyresult.py +58 -0
  48. gamegains_sdk-0.0.2/src/gamegains_sdk/models/createorderbatchop.py +282 -0
  49. gamegains_sdk-0.0.2/src/gamegains_sdk/models/createorderop.py +274 -0
  50. gamegains_sdk-0.0.2/src/gamegains_sdk/models/createwebhookop.py +17 -0
  51. gamegains_sdk-0.0.2/src/gamegains_sdk/models/deleted.py +26 -0
  52. gamegains_sdk-0.0.2/src/gamegains_sdk/models/deletewebhookop.py +16 -0
  53. gamegains_sdk-0.0.2/src/gamegains_sdk/models/eip712domain.py +31 -0
  54. gamegains_sdk-0.0.2/src/gamegains_sdk/models/eip712field.py +16 -0
  55. gamegains_sdk-0.0.2/src/gamegains_sdk/models/eip712orderintentspec.py +49 -0
  56. gamegains_sdk-0.0.2/src/gamegains_sdk/models/engineposition.py +56 -0
  57. gamegains_sdk-0.0.2/src/gamegains_sdk/models/errorresponse.py +16 -0
  58. gamegains_sdk-0.0.2/src/gamegains_sdk/models/exchangeinfo.py +122 -0
  59. gamegains_sdk-0.0.2/src/gamegains_sdk/models/exchangeinfosymbol.py +37 -0
  60. gamegains_sdk-0.0.2/src/gamegains_sdk/models/fundinginfo.py +45 -0
  61. gamegains_sdk-0.0.2/src/gamegains_sdk/models/fundinglist.py +15 -0
  62. gamegains_sdk-0.0.2/src/gamegains_sdk/models/getfundinginfoop.py +30 -0
  63. gamegains_sdk-0.0.2/src/gamegains_sdk/models/getliquidationstatusop.py +16 -0
  64. gamegains_sdk-0.0.2/src/gamegains_sdk/models/getlpvalueop.py +16 -0
  65. gamegains_sdk-0.0.2/src/gamegains_sdk/models/getoraclepriceop.py +30 -0
  66. gamegains_sdk-0.0.2/src/gamegains_sdk/models/getorderbookop.py +53 -0
  67. gamegains_sdk-0.0.2/src/gamegains_sdk/models/getorderop.py +19 -0
  68. gamegains_sdk-0.0.2/src/gamegains_sdk/models/getpositiontpslop.py +43 -0
  69. gamegains_sdk-0.0.2/src/gamegains_sdk/models/getreferralleaderboardcountop.py +35 -0
  70. gamegains_sdk-0.0.2/src/gamegains_sdk/models/getreferralleaderboardearningsop.py +35 -0
  71. gamegains_sdk-0.0.2/src/gamegains_sdk/models/gettickerop.py +30 -0
  72. gamegains_sdk-0.0.2/src/gamegains_sdk/models/legacyposition.py +96 -0
  73. gamegains_sdk-0.0.2/src/gamegains_sdk/models/liquidationstatus.py +46 -0
  74. gamegains_sdk-0.0.2/src/gamegains_sdk/models/listpositionsop.py +35 -0
  75. gamegains_sdk-0.0.2/src/gamegains_sdk/models/listtradesop.py +53 -0
  76. gamegains_sdk-0.0.2/src/gamegains_sdk/models/lpvalue.py +23 -0
  77. gamegains_sdk-0.0.2/src/gamegains_sdk/models/lpvaultinfo.py +42 -0
  78. gamegains_sdk-0.0.2/src/gamegains_sdk/models/margintier.py +34 -0
  79. gamegains_sdk-0.0.2/src/gamegains_sdk/models/market.py +69 -0
  80. gamegains_sdk-0.0.2/src/gamegains_sdk/models/marketslist.py +15 -0
  81. gamegains_sdk-0.0.2/src/gamegains_sdk/models/openorder.py +129 -0
  82. gamegains_sdk-0.0.2/src/gamegains_sdk/models/openorderslist.py +27 -0
  83. gamegains_sdk-0.0.2/src/gamegains_sdk/models/oracleprice.py +45 -0
  84. gamegains_sdk-0.0.2/src/gamegains_sdk/models/oraclepriceslist.py +15 -0
  85. gamegains_sdk-0.0.2/src/gamegains_sdk/models/orderaccepted.py +68 -0
  86. gamegains_sdk-0.0.2/src/gamegains_sdk/models/orderbook.py +31 -0
  87. gamegains_sdk-0.0.2/src/gamegains_sdk/models/orderdetail.py +35 -0
  88. gamegains_sdk-0.0.2/src/gamegains_sdk/models/position.py +15 -0
  89. gamegains_sdk-0.0.2/src/gamegains_sdk/models/positionslist.py +15 -0
  90. gamegains_sdk-0.0.2/src/gamegains_sdk/models/positiontpsl.py +35 -0
  91. gamegains_sdk-0.0.2/src/gamegains_sdk/models/positiontpslclearresult.py +23 -0
  92. gamegains_sdk-0.0.2/src/gamegains_sdk/models/positiontpslsetresult.py +41 -0
  93. gamegains_sdk-0.0.2/src/gamegains_sdk/models/primaryapikeyresult.py +54 -0
  94. gamegains_sdk-0.0.2/src/gamegains_sdk/models/referralleaderboardcount.py +38 -0
  95. gamegains_sdk-0.0.2/src/gamegains_sdk/models/referralleaderboardearnings.py +38 -0
  96. gamegains_sdk-0.0.2/src/gamegains_sdk/models/replacelegresult.py +44 -0
  97. gamegains_sdk-0.0.2/src/gamegains_sdk/models/replaceorderbatchop.py +297 -0
  98. gamegains_sdk-0.0.2/src/gamegains_sdk/models/revshareclaimresult.py +32 -0
  99. gamegains_sdk-0.0.2/src/gamegains_sdk/models/revsharestats.py +50 -0
  100. gamegains_sdk-0.0.2/src/gamegains_sdk/models/security.py +42 -0
  101. gamegains_sdk-0.0.2/src/gamegains_sdk/models/servertime.py +27 -0
  102. gamegains_sdk-0.0.2/src/gamegains_sdk/models/setdeadmanswitchop.py +60 -0
  103. gamegains_sdk-0.0.2/src/gamegains_sdk/models/setpositiontpslop.py +172 -0
  104. gamegains_sdk-0.0.2/src/gamegains_sdk/models/ticker.py +56 -0
  105. gamegains_sdk-0.0.2/src/gamegains_sdk/models/trade.py +56 -0
  106. gamegains_sdk-0.0.2/src/gamegains_sdk/models/tradeslist.py +15 -0
  107. gamegains_sdk-0.0.2/src/gamegains_sdk/models/webhook.py +30 -0
  108. gamegains_sdk-0.0.2/src/gamegains_sdk/models/webhookcreateresult.py +19 -0
  109. gamegains_sdk-0.0.2/src/gamegains_sdk/models/webhookslist.py +15 -0
  110. gamegains_sdk-0.0.2/src/gamegains_sdk/models/wschannelinfo.py +49 -0
  111. gamegains_sdk-0.0.2/src/gamegains_sdk/models/wsinfo.py +42 -0
  112. gamegains_sdk-0.0.2/src/gamegains_sdk/orders.py +2243 -0
  113. gamegains_sdk-0.0.2/src/gamegains_sdk/positions.py +1025 -0
  114. gamegains_sdk-0.0.2/src/gamegains_sdk/py.typed +1 -0
  115. gamegains_sdk-0.0.2/src/gamegains_sdk/referral.py +755 -0
  116. gamegains_sdk-0.0.2/src/gamegains_sdk/risk.py +188 -0
  117. gamegains_sdk-0.0.2/src/gamegains_sdk/sdk.py +228 -0
  118. gamegains_sdk-0.0.2/src/gamegains_sdk/sdkconfiguration.py +51 -0
  119. gamegains_sdk-0.0.2/src/gamegains_sdk/types/__init__.py +24 -0
  120. gamegains_sdk-0.0.2/src/gamegains_sdk/types/base64fileinput.py +43 -0
  121. gamegains_sdk-0.0.2/src/gamegains_sdk/types/basemodel.py +77 -0
  122. gamegains_sdk-0.0.2/src/gamegains_sdk/utils/__init__.py +180 -0
  123. gamegains_sdk-0.0.2/src/gamegains_sdk/utils/annotations.py +79 -0
  124. gamegains_sdk-0.0.2/src/gamegains_sdk/utils/datetimes.py +37 -0
  125. gamegains_sdk-0.0.2/src/gamegains_sdk/utils/dynamic_imports.py +54 -0
  126. gamegains_sdk-0.0.2/src/gamegains_sdk/utils/enums.py +134 -0
  127. gamegains_sdk-0.0.2/src/gamegains_sdk/utils/eventstreaming.py +326 -0
  128. gamegains_sdk-0.0.2/src/gamegains_sdk/utils/forms.py +239 -0
  129. gamegains_sdk-0.0.2/src/gamegains_sdk/utils/headers.py +136 -0
  130. gamegains_sdk-0.0.2/src/gamegains_sdk/utils/logger.py +27 -0
  131. gamegains_sdk-0.0.2/src/gamegains_sdk/utils/metadata.py +119 -0
  132. gamegains_sdk-0.0.2/src/gamegains_sdk/utils/queryparams.py +217 -0
  133. gamegains_sdk-0.0.2/src/gamegains_sdk/utils/requestbodies.py +67 -0
  134. gamegains_sdk-0.0.2/src/gamegains_sdk/utils/retries.py +356 -0
  135. gamegains_sdk-0.0.2/src/gamegains_sdk/utils/security.py +215 -0
  136. gamegains_sdk-0.0.2/src/gamegains_sdk/utils/serializers.py +306 -0
  137. gamegains_sdk-0.0.2/src/gamegains_sdk/utils/unmarshal_json_response.py +38 -0
  138. gamegains_sdk-0.0.2/src/gamegains_sdk/utils/url.py +155 -0
  139. gamegains_sdk-0.0.2/src/gamegains_sdk/utils/values.py +137 -0
  140. gamegains_sdk-0.0.2/src/gamegains_sdk/webhooks.py +577 -0
  141. gamegains_sdk-0.0.2/src/gamegains_sdk/websocket.py +178 -0
  142. gamegains_sdk-0.0.2/src/gamegains_sdk.egg-info/PKG-INFO +591 -0
  143. gamegains_sdk-0.0.2/src/gamegains_sdk.egg-info/SOURCES.txt +144 -0
  144. gamegains_sdk-0.0.2/src/gamegains_sdk.egg-info/dependency_links.txt +1 -0
  145. gamegains_sdk-0.0.2/src/gamegains_sdk.egg-info/requires.txt +4 -0
  146. gamegains_sdk-0.0.2/src/gamegains_sdk.egg-info/top_level.txt +1 -0
@@ -0,0 +1,591 @@
1
+ Metadata-Version: 2.4
2
+ Name: gamegains-sdk
3
+ Version: 0.0.2
4
+ Summary: Official Python SDK for the GameGains perpetual-futures trading API — HMAC + EIP-712 signing built in.
5
+ Author: GameGains
6
+ License: Apache-2.0
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: httpcore>=1.0.9
10
+ Requires-Dist: httpx>=0.28.1
11
+ Requires-Dist: pydantic<2.13,>=2.11.2
12
+ Requires-Dist: eth-account>=0.13.0
13
+
14
+ # gamegains-sdk
15
+
16
+ Developer-friendly & type-safe Python SDK specifically catered to leverage *gamegains-sdk* API.
17
+
18
+ [![Built by Speakeasy](https://img.shields.io/badge/Built_by-SPEAKEASY-374151?style=for-the-badge&labelColor=f3f4f6)](https://www.speakeasy.com/?utm_source=gamegains-sdk&utm_campaign=python)
19
+ [![License: MIT](https://img.shields.io/badge/LICENSE_//_MIT-3b5bdb?style=for-the-badge&labelColor=eff6ff)](https://opensource.org/licenses/MIT)
20
+
21
+
22
+ <br /><br />
23
+ > [!IMPORTANT]
24
+ > This SDK is not yet ready for production use. To complete setup please follow the steps outlined in your [workspace](https://app.speakeasy.com/org/gamegains/gamegains-sdk). Delete this section before > publishing to a package manager.
25
+
26
+ <!-- Start Summary [summary] -->
27
+ ## Summary
28
+
29
+ GameGains API: GameGains v1 REST API.
30
+
31
+ **Auth:** authenticated endpoints sign each request with HMAC-SHA256. The signing string is the literal byte concatenation `timestamp + method + originalUrl + rawBody`, where:
32
+ - `timestamp` — Unix epoch ms as a decimal string (also sent in `X-GG-TIMESTAMP`).
33
+ - `method` — uppercase verb (`GET`, `POST`, `DELETE`).
34
+ - `originalUrl` — request path **including the query string** (e.g. `/api/v1/orders?market=AK47-REDLINE-FT`).
35
+ - `rawBody` — the exact request body bytes you put on the wire. Sign before parsing; the server re-hashes the raw buffer.
36
+
37
+ Send the hex-encoded HMAC in `X-GG-SIGNATURE`, the API key value (the `apiKey` field, e.g. `gg_pk_…` — NOT the `keyId`) in `X-GG-APIKEY`, and the timestamp in `X-GG-TIMESTAMP`. The server rejects skew > 5s — call `GET /api/v1/time` once at boot to detect clock drift.
38
+
39
+ **Replay protection:** the timestamp is also a per-key nonce and must strictly increase on every call for a given key. A timestamp <= the last one accepted for that key is rejected (covers exact replays, two requests in the same millisecond, and blind retries of identical signed bytes); a timestamp >5s in the future is also rejected. Never replay signed bytes — bump the timestamp and re-sign on retry. To run requests concurrently, send an optional `X-GG-NONCE` (a unique token per request, appended to the signed string after the body, separated by a newline); distinct nonces use per-key nonce-uniqueness instead of the monotonic timestamp, so parallel requests do not serialize.
40
+
41
+ **Content-Type:** any request that carries a body must set `Content-Type: application/json` (including a body-bearing DELETE such as batch cancel); otherwise the body is dropped, `rawBody` is empty, and the signature fails as a 401.
42
+
43
+ **Errors:** every error response is `{ "error": { "code": "<MACHINE_CODE>", "message": "<human text>" } }`. Status code carries semantics (`400` bad params, `401` auth, `403` permission, `404` missing, `409` conflict, `429` rate-limited, `5xx` server).
44
+
45
+ **Bootstrap:** sign an EIP-712 `ApiKeyCreate` intent with the trader wallet → `POST /api/v1/auth/create-key` to mint a key + API secret (shown **once**).
46
+ <!-- End Summary [summary] -->
47
+
48
+ <!-- Start Table of Contents [toc] -->
49
+ ## Table of Contents
50
+ <!-- $toc-max-depth=2 -->
51
+ * [gamegains-sdk](#gamegains-sdk)
52
+ * [SDK Installation](#sdk-installation)
53
+ * [IDE Support](#ide-support)
54
+ * [SDK Example Usage](#sdk-example-usage)
55
+ * [Authentication](#authentication)
56
+ * [Available Resources and Operations](#available-resources-and-operations)
57
+ * [Retries](#retries)
58
+ * [Error Handling](#error-handling)
59
+ * [Server Selection](#server-selection)
60
+ * [Custom HTTP Client](#custom-http-client)
61
+ * [Resource Management](#resource-management)
62
+ * [Debugging](#debugging)
63
+ * [Development](#development)
64
+ * [Maturity](#maturity)
65
+ * [Contributions](#contributions)
66
+
67
+ <!-- End Table of Contents [toc] -->
68
+
69
+ <!-- Start SDK Installation [installation] -->
70
+ ## SDK Installation
71
+
72
+ > [!TIP]
73
+ > To finish publishing your SDK to PyPI you must [run your first generation action](https://www.speakeasy.com/docs/github-setup#step-by-step-guide).
74
+
75
+
76
+ > [!NOTE]
77
+ > **Python version upgrade policy**
78
+ >
79
+ > Once a Python version reaches its [official end of life date](https://devguide.python.org/versions/), a 3-month grace period is provided for users to upgrade. Following this grace period, the minimum python version supported in the SDK will be updated.
80
+
81
+ The SDK can be installed with *uv*, *pip*, or *poetry* package managers.
82
+
83
+ ### uv
84
+
85
+ *uv* is a fast Python package installer and resolver, designed as a drop-in replacement for pip and pip-tools. It's recommended for its speed and modern Python tooling capabilities.
86
+
87
+ ```bash
88
+ uv add git+<UNSET>.git
89
+ ```
90
+
91
+ ### PIP
92
+
93
+ *PIP* is the default package installer for Python, enabling easy installation and management of packages from PyPI via the command line.
94
+
95
+ ```bash
96
+ pip install git+<UNSET>.git
97
+ ```
98
+
99
+ ### Poetry
100
+
101
+ *Poetry* is a modern tool that simplifies dependency management and package publishing by using a single `pyproject.toml` file to handle project metadata and dependencies.
102
+
103
+ ```bash
104
+ poetry add git+<UNSET>.git
105
+ ```
106
+
107
+ ### Shell and script usage with `uv`
108
+
109
+ You can use this SDK in a Python shell with [uv](https://docs.astral.sh/uv/) and the `uvx` command that comes with it like so:
110
+
111
+ ```shell
112
+ uvx --from gamegains-sdk python
113
+ ```
114
+
115
+ It's also possible to write a standalone Python script without needing to set up a whole project like so:
116
+
117
+ ```python
118
+ #!/usr/bin/env -S uv run --script
119
+ # /// script
120
+ # requires-python = ">=3.10"
121
+ # dependencies = [
122
+ # "gamegains-sdk",
123
+ # ]
124
+ # ///
125
+
126
+ from gamegains_sdk import GameGains
127
+
128
+ sdk = GameGains(
129
+ # SDK arguments
130
+ )
131
+
132
+ # Rest of script here...
133
+ ```
134
+
135
+ Once that is saved to a file, you can run it with `uv run script.py` where
136
+ `script.py` can be replaced with the actual file name.
137
+ <!-- End SDK Installation [installation] -->
138
+
139
+ <!-- Start IDE Support [idesupport] -->
140
+ ## IDE Support
141
+
142
+ ### PyCharm
143
+
144
+ Generally, the SDK will work well with most IDEs out of the box. However, when using PyCharm, you can enjoy much better integration with Pydantic by installing an additional plugin.
145
+
146
+ - [PyCharm Pydantic Plugin](https://docs.pydantic.dev/latest/integrations/pycharm/)
147
+ <!-- End IDE Support [idesupport] -->
148
+
149
+ <!-- Start SDK Example Usage [usage] -->
150
+ ## SDK Example Usage
151
+
152
+ ### Example
153
+
154
+ ```python
155
+ # Synchronous Example
156
+ from gamegains_sdk import GameGains
157
+
158
+
159
+ with GameGains() as game_gains:
160
+
161
+ res = game_gains.auth.create_api_key()
162
+
163
+ # Handle response
164
+ print(res)
165
+ ```
166
+
167
+ </br>
168
+
169
+ The same SDK client can also be used to make asynchronous requests by importing asyncio.
170
+
171
+ ```python
172
+ # Asynchronous Example
173
+ import asyncio
174
+ from gamegains_sdk import GameGains
175
+
176
+ async def main():
177
+
178
+ async with GameGains() as game_gains:
179
+
180
+ res = await game_gains.auth.create_api_key_async()
181
+
182
+ # Handle response
183
+ print(res)
184
+
185
+ asyncio.run(main())
186
+ ```
187
+ <!-- End SDK Example Usage [usage] -->
188
+
189
+ <!-- Start Authentication [security] -->
190
+ ## Authentication
191
+
192
+ ### Per-Client Security Schemes
193
+
194
+ This SDK supports the following security scheme globally:
195
+
196
+ | Name | Type | Scheme | Environment Variable |
197
+ | ----------- | ------ | ------- | --------------------- |
198
+ | `gg_apikey` | apiKey | API key | `GAMEGAINS_GG_APIKEY` |
199
+
200
+ To authenticate with the API the `gg_apikey` parameter must be set when initializing the SDK client instance. For example:
201
+ ```python
202
+ from gamegains_sdk import GameGains
203
+ import os
204
+
205
+
206
+ with GameGains(
207
+ gg_apikey=os.getenv("GAMEGAINS_GG_APIKEY", ""),
208
+ ) as game_gains:
209
+
210
+ res = game_gains.auth.create_api_key()
211
+
212
+ # Handle response
213
+ print(res)
214
+
215
+ ```
216
+ <!-- End Authentication [security] -->
217
+
218
+ <!-- Start Available Resources and Operations [operations] -->
219
+ ## Available Resources and Operations
220
+
221
+ <details open>
222
+ <summary>Available methods</summary>
223
+
224
+ ### [Account](docs/sdks/account/README.md)
225
+
226
+ * [get_account](docs/sdks/account/README.md#get_account) - Get account info for the authenticated API key
227
+
228
+ ### [Auth](docs/sdks/auth/README.md)
229
+
230
+ * [create_api_key](docs/sdks/auth/README.md#create_api_key) - Mint an API key, authenticated by an EIP-712 wallet signature
231
+ * [get_primary_api_key](docs/sdks/auth/README.md#get_primary_api_key) - Lazy-mint + return the wallet’s stable primary API key
232
+ * [rotate_primary_api_key](docs/sdks/auth/README.md#rotate_primary_api_key) - Regenerate the HMAC secret on the wallet’s primary key
233
+
234
+ ### [Collateral](docs/sdks/collateral/README.md)
235
+
236
+ * [get_collateral](docs/sdks/collateral/README.md#get_collateral) - Get collateral balances for the authenticated user
237
+
238
+ ### [Lp](docs/sdks/lp/README.md)
239
+
240
+ * [get_lp_vault](docs/sdks/lp/README.md#get_lp_vault) - Get LP vault overview
241
+ * [get_lp_value](docs/sdks/lp/README.md#get_lp_value) - Get LP value for a specific address
242
+
243
+ ### [MarketData](docs/sdks/marketdata/README.md)
244
+
245
+ * [list_oracle_prices](docs/sdks/marketdata/README.md#list_oracle_prices) - Get oracle prices for all markets
246
+ * [get_oracle_price](docs/sdks/marketdata/README.md#get_oracle_price) - Get oracle price for one market
247
+ * [list_funding_info](docs/sdks/marketdata/README.md#list_funding_info) - Get funding info for all markets
248
+ * [get_funding_info](docs/sdks/marketdata/README.md#get_funding_info) - Get funding info for one market
249
+
250
+ ### [Markets](docs/sdks/markets/README.md)
251
+
252
+ * [list_markets](docs/sdks/markets/README.md#list_markets) - List all tradable markets
253
+ * [get_server_time](docs/sdks/markets/README.md#get_server_time) - Server clock for HMAC + nonce skew detection
254
+ * [get_exchange_info](docs/sdks/markets/README.md#get_exchange_info) - One-shot venue metadata for bot bootstrap
255
+ * [get_orderbook](docs/sdks/markets/README.md#get_orderbook) - Get order book for a market
256
+ * [get_ticker](docs/sdks/markets/README.md#get_ticker) - Get latest ticker for a market
257
+ * [list_trades](docs/sdks/markets/README.md#list_trades) - Get recent trades for a market
258
+
259
+ ### [Orders](docs/sdks/orders/README.md)
260
+
261
+ * [create_order](docs/sdks/orders/README.md#create_order) - Place a single order
262
+ * [list_orders](docs/sdks/orders/README.md#list_orders) - List open / matched / settled orders for the authenticated trader
263
+ * [create_order_batch](docs/sdks/orders/README.md#create_order_batch) - Place a batch of orders in a single request (up to 10; market makers up to 25)
264
+ * [cancel_order_batch](docs/sdks/orders/README.md#cancel_order_batch) - Cancel up to 20 orders in a single request
265
+ * [cancel_all_orders](docs/sdks/orders/README.md#cancel_all_orders) - Cancel all open orders, optionally filtered by market
266
+ * [replace_order_batch](docs/sdks/orders/README.md#replace_order_batch) - Cancel + place up to 25 orders in one call (engine mode only)
267
+ * [set_dead_man_switch](docs/sdks/orders/README.md#set_dead_man_switch) - Arm/disarm the account-wide dead-man switch (cancel-on-disconnect)
268
+ * [get_order](docs/sdks/orders/README.md#get_order) - Get a single order by ID (engine mode only)
269
+ * [cancel_order](docs/sdks/orders/README.md#cancel_order) - Cancel a single order
270
+ * [amend_order](docs/sdks/orders/README.md#amend_order) - Amend an order (priority-preserving size-down)
271
+ * [cancel_order_by_client_id](docs/sdks/orders/README.md#cancel_order_by_client_id) - Cancel a single open order by its client-supplied tag (Binance origClientOrderId equivalent)
272
+
273
+ ### [Positions](docs/sdks/positions/README.md)
274
+
275
+ * [list_positions](docs/sdks/positions/README.md#list_positions) - List positions for the authenticated trader
276
+ * [add_position_margin](docs/sdks/positions/README.md#add_position_margin) - Add margin to an existing position
277
+ * [set_position_tp_sl](docs/sdks/positions/README.md#set_position_tp_sl) - Attach a take-profit and/or stop-loss to an open position
278
+ * [clear_position_tp_sl](docs/sdks/positions/README.md#clear_position_tp_sl) - Clear both arms of a position TP/SL
279
+ * [get_position_tp_sl](docs/sdks/positions/README.md#get_position_tp_sl) - Read the active TP and SL trigger prices for the authed trader
280
+
281
+ ### [Referral](docs/sdks/referral/README.md)
282
+
283
+ * [get_rev_share_stats](docs/sdks/referral/README.md#get_rev_share_stats) - Accrued / claimed / claimable rev-share for the authed trader
284
+ * [claim_rev_share](docs/sdks/referral/README.md#claim_rev_share) - Debit accrued balance and queue the on-chain vault credit
285
+ * [get_referral_leaderboard_count](docs/sdks/referral/README.md#get_referral_leaderboard_count) - Top referrers ranked by number of referees
286
+ * [get_referral_leaderboard_earnings](docs/sdks/referral/README.md#get_referral_leaderboard_earnings) - Top referrers ranked by lifetime rev-share USD
287
+
288
+ ### [Risk](docs/sdks/risk/README.md)
289
+
290
+ * [get_liquidation_status](docs/sdks/risk/README.md#get_liquidation_status) - Check liquidation status for a trader
291
+
292
+ ### [Webhooks](docs/sdks/webhooks/README.md)
293
+
294
+ * [create_webhook](docs/sdks/webhooks/README.md#create_webhook) - Register a webhook
295
+ * [list_webhooks](docs/sdks/webhooks/README.md#list_webhooks) - List registered webhooks
296
+ * [delete_webhook](docs/sdks/webhooks/README.md#delete_webhook) - Delete a webhook
297
+
298
+ ### [WebSocket](docs/sdks/websocket/README.md)
299
+
300
+ * [get_web_socket_info](docs/sdks/websocket/README.md#get_web_socket_info) - Get WebSocket endpoint metadata
301
+
302
+ </details>
303
+ <!-- End Available Resources and Operations [operations] -->
304
+
305
+ <!-- Start Retries [retries] -->
306
+ ## Retries
307
+
308
+ Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
309
+
310
+ To change the default retry strategy for a single API call, simply provide a `RetryConfig` object to the call:
311
+ ```python
312
+ from gamegains_sdk import GameGains
313
+ from gamegains_sdk.utils import BackoffStrategy, RetryConfig
314
+
315
+
316
+ with GameGains() as game_gains:
317
+
318
+ res = game_gains.auth.create_api_key(,
319
+ RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False))
320
+
321
+ # Handle response
322
+ print(res)
323
+
324
+ ```
325
+
326
+ If you'd like to override the default retry strategy for all operations that support retries, you can use the `retry_config` optional parameter when initializing the SDK:
327
+ ```python
328
+ from gamegains_sdk import GameGains
329
+ from gamegains_sdk.utils import BackoffStrategy, RetryConfig
330
+
331
+
332
+ with GameGains(
333
+ retry_config=RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False),
334
+ ) as game_gains:
335
+
336
+ res = game_gains.auth.create_api_key()
337
+
338
+ # Handle response
339
+ print(res)
340
+
341
+ ```
342
+ <!-- End Retries [retries] -->
343
+
344
+ <!-- Start Error Handling [errors] -->
345
+ ## Error Handling
346
+
347
+ [`GameGainsError`](./src/gamegains_sdk/errors/gamegainserror.py) is the base class for all HTTP error responses. It has the following properties:
348
+
349
+ | Property | Type | Description |
350
+ | ------------------ | ---------------- | --------------------------------------------------------------------------------------- |
351
+ | `err.message` | `str` | Error message |
352
+ | `err.status_code` | `int` | HTTP response status code eg `404` |
353
+ | `err.headers` | `httpx.Headers` | HTTP response headers |
354
+ | `err.body` | `str` | HTTP body. Can be empty string if no body is returned. |
355
+ | `err.raw_response` | `httpx.Response` | Raw HTTP response |
356
+ | `err.data` | | Optional. Some errors may contain structured data. [See Error Classes](#error-classes). |
357
+
358
+ ### Example
359
+ ```python
360
+ from gamegains_sdk import GameGains, errors
361
+
362
+
363
+ with GameGains() as game_gains:
364
+ res = None
365
+ try:
366
+
367
+ res = game_gains.auth.create_api_key()
368
+
369
+ # Handle response
370
+ print(res)
371
+
372
+
373
+ except errors.GameGainsError as e:
374
+ # The base class for HTTP error responses
375
+ print(e.message)
376
+ print(e.status_code)
377
+ print(e.body)
378
+ print(e.headers)
379
+ print(e.raw_response)
380
+
381
+ # Depending on the method different errors may be thrown
382
+ if isinstance(e, errors.ErrorResponse):
383
+ print(e.data.error) # models.Error
384
+ ```
385
+
386
+ ### Error Classes
387
+ **Primary errors:**
388
+ * [`GameGainsError`](./src/gamegains_sdk/errors/gamegainserror.py): The base class for HTTP error responses.
389
+ * [`ErrorResponse`](./src/gamegains_sdk/errors/errorresponse.py): Generic error.
390
+
391
+ <details><summary>Less common errors (5)</summary>
392
+
393
+ <br />
394
+
395
+ **Network errors:**
396
+ * [`httpx.RequestError`](https://www.python-httpx.org/exceptions/#httpx.RequestError): Base class for request errors.
397
+ * [`httpx.ConnectError`](https://www.python-httpx.org/exceptions/#httpx.ConnectError): HTTP client was unable to make a request to a server.
398
+ * [`httpx.TimeoutException`](https://www.python-httpx.org/exceptions/#httpx.TimeoutException): HTTP request timed out.
399
+
400
+
401
+ **Inherit from [`GameGainsError`](./src/gamegains_sdk/errors/gamegainserror.py)**:
402
+ * [`ResponseValidationError`](./src/gamegains_sdk/errors/responsevalidationerror.py): Type mismatch between the response data and the expected Pydantic model. Provides access to the Pydantic validation error via the `cause` attribute.
403
+
404
+ </details>
405
+ <!-- End Error Handling [errors] -->
406
+
407
+ <!-- Start Server Selection [server] -->
408
+ ## Server Selection
409
+
410
+ ### Select Server by Index
411
+
412
+ You can override the default server globally by passing a server index to the `server_idx: int` optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:
413
+
414
+ | # | Server | Description |
415
+ | --- | -------------------------- | ------------------------------------------------------------------------------ |
416
+ | 0 | `https://api.gamegains.gg` | Production (active chain via GET /exchange-info; currently Base Sepolia 84532) |
417
+ | 1 | `http://localhost:3000` | Local dev |
418
+
419
+ #### Example
420
+
421
+ ```python
422
+ from gamegains_sdk import GameGains
423
+
424
+
425
+ with GameGains(
426
+ server_idx=0,
427
+ ) as game_gains:
428
+
429
+ res = game_gains.auth.create_api_key()
430
+
431
+ # Handle response
432
+ print(res)
433
+
434
+ ```
435
+
436
+ ### Override Server URL Per-Client
437
+
438
+ The default server can also be overridden globally by passing a URL to the `server_url: str` optional parameter when initializing the SDK client instance. For example:
439
+ ```python
440
+ from gamegains_sdk import GameGains
441
+
442
+
443
+ with GameGains(
444
+ server_url="http://localhost:3000",
445
+ ) as game_gains:
446
+
447
+ res = game_gains.auth.create_api_key()
448
+
449
+ # Handle response
450
+ print(res)
451
+
452
+ ```
453
+ <!-- End Server Selection [server] -->
454
+
455
+ <!-- Start Custom HTTP Client [http-client] -->
456
+ ## Custom HTTP Client
457
+
458
+ The Python SDK makes API calls using the [httpx](https://www.python-httpx.org/) HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with your own HTTP client instance.
459
+ Depending on whether you are using the sync or async version of the SDK, you can pass an instance of `HttpClient` or `AsyncHttpClient` respectively, which are Protocol's ensuring that the client has the necessary methods to make API calls.
460
+ This allows you to wrap the client with your own custom logic, such as adding custom headers, logging, or error handling, or you can just pass an instance of `httpx.Client` or `httpx.AsyncClient` directly.
461
+
462
+ For example, you could specify a header for every request that this sdk makes as follows:
463
+ ```python
464
+ from gamegains_sdk import GameGains
465
+ import httpx
466
+
467
+ http_client = httpx.Client(headers={"x-custom-header": "someValue"})
468
+ s = GameGains(client=http_client)
469
+ ```
470
+
471
+ or you could wrap the client with your own custom logic:
472
+ ```python
473
+ from gamegains_sdk import GameGains
474
+ from gamegains_sdk.httpclient import AsyncHttpClient
475
+ import httpx
476
+
477
+ class CustomClient(AsyncHttpClient):
478
+ client: AsyncHttpClient
479
+
480
+ def __init__(self, client: AsyncHttpClient):
481
+ self.client = client
482
+
483
+ async def send(
484
+ self,
485
+ request: httpx.Request,
486
+ *,
487
+ stream: bool = False,
488
+ auth: Union[
489
+ httpx._types.AuthTypes, httpx._client.UseClientDefault, None
490
+ ] = httpx.USE_CLIENT_DEFAULT,
491
+ follow_redirects: Union[
492
+ bool, httpx._client.UseClientDefault
493
+ ] = httpx.USE_CLIENT_DEFAULT,
494
+ ) -> httpx.Response:
495
+ request.headers["Client-Level-Header"] = "added by client"
496
+
497
+ return await self.client.send(
498
+ request, stream=stream, auth=auth, follow_redirects=follow_redirects
499
+ )
500
+
501
+ def build_request(
502
+ self,
503
+ method: str,
504
+ url: httpx._types.URLTypes,
505
+ *,
506
+ content: Optional[httpx._types.RequestContent] = None,
507
+ data: Optional[httpx._types.RequestData] = None,
508
+ files: Optional[httpx._types.RequestFiles] = None,
509
+ json: Optional[Any] = None,
510
+ params: Optional[httpx._types.QueryParamTypes] = None,
511
+ headers: Optional[httpx._types.HeaderTypes] = None,
512
+ cookies: Optional[httpx._types.CookieTypes] = None,
513
+ timeout: Union[
514
+ httpx._types.TimeoutTypes, httpx._client.UseClientDefault
515
+ ] = httpx.USE_CLIENT_DEFAULT,
516
+ extensions: Optional[httpx._types.RequestExtensions] = None,
517
+ ) -> httpx.Request:
518
+ return self.client.build_request(
519
+ method,
520
+ url,
521
+ content=content,
522
+ data=data,
523
+ files=files,
524
+ json=json,
525
+ params=params,
526
+ headers=headers,
527
+ cookies=cookies,
528
+ timeout=timeout,
529
+ extensions=extensions,
530
+ )
531
+
532
+ s = GameGains(async_client=CustomClient(httpx.AsyncClient()))
533
+ ```
534
+ <!-- End Custom HTTP Client [http-client] -->
535
+
536
+ <!-- Start Resource Management [resource-management] -->
537
+ ## Resource Management
538
+
539
+ The `GameGains` class implements the context manager protocol and registers a finalizer function to close the underlying sync and async HTTPX clients it uses under the hood. This will close HTTP connections, release memory and free up other resources held by the SDK. In short-lived Python programs and notebooks that make a few SDK method calls, resource management may not be a concern. However, in longer-lived programs, it is beneficial to create a single SDK instance via a [context manager][context-manager] and reuse it across the application.
540
+
541
+ [context-manager]: https://docs.python.org/3/reference/datamodel.html#context-managers
542
+
543
+ ```python
544
+ from gamegains_sdk import GameGains
545
+ def main():
546
+
547
+ with GameGains() as game_gains:
548
+ # Rest of application here...
549
+
550
+
551
+ # Or when using async:
552
+ async def amain():
553
+
554
+ async with GameGains() as game_gains:
555
+ # Rest of application here...
556
+ ```
557
+ <!-- End Resource Management [resource-management] -->
558
+
559
+ <!-- Start Debugging [debug] -->
560
+ ## Debugging
561
+
562
+ You can setup your SDK to emit debug logs for SDK requests and responses.
563
+
564
+ You can pass your own logger class directly into your SDK.
565
+ ```python
566
+ from gamegains_sdk import GameGains
567
+ import logging
568
+
569
+ logging.basicConfig(level=logging.DEBUG)
570
+ s = GameGains(debug_logger=logging.getLogger("gamegains_sdk"))
571
+ ```
572
+
573
+ You can also enable a default debug logger by setting an environment variable `GAMEGAINS_DEBUG` to true.
574
+ <!-- End Debugging [debug] -->
575
+
576
+ <!-- Placeholder for Future Speakeasy SDK Sections -->
577
+
578
+ # Development
579
+
580
+ ## Maturity
581
+
582
+ This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage
583
+ to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally
584
+ looking for the latest version.
585
+
586
+ ## Contributions
587
+
588
+ While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation.
589
+ We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.
590
+
591
+ ### SDK Created by [Speakeasy](https://www.speakeasy.com/?utm_source=gamegains-sdk&utm_campaign=python)