xdataapi 0.3.0__py3-none-any.whl

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 (61) hide show
  1. xdataapi/__init__.py +8 -0
  2. xdataapi/api/__init__.py +1 -0
  3. xdataapi/api/account/__init__.py +1 -0
  4. xdataapi/api/account/get_me.py +144 -0
  5. xdataapi/api/billing/__init__.py +1 -0
  6. xdataapi/api/billing/create_checkout.py +206 -0
  7. xdataapi/api/billing/list_packs.py +144 -0
  8. xdataapi/api/tweets/__init__.py +1 -0
  9. xdataapi/api/tweets/get_quotes.py +241 -0
  10. xdataapi/api/tweets/get_replies.py +230 -0
  11. xdataapi/api/tweets/get_retweeters.py +245 -0
  12. xdataapi/api/tweets/get_thread.py +226 -0
  13. xdataapi/api/tweets/get_tweet.py +213 -0
  14. xdataapi/api/tweets/get_tweets.py +223 -0
  15. xdataapi/api/tweets/search_tweets.py +277 -0
  16. xdataapi/api/users/__init__.py +1 -0
  17. xdataapi/api/users/get_follower_ids.py +254 -0
  18. xdataapi/api/users/get_followers.py +254 -0
  19. xdataapi/api/users/get_following.py +246 -0
  20. xdataapi/api/users/get_user.py +213 -0
  21. xdataapi/api/users/get_user_tweets.py +241 -0
  22. xdataapi/api/users/get_users.py +231 -0
  23. xdataapi/client.py +268 -0
  24. xdataapi/errors.py +16 -0
  25. xdataapi/models/__init__.py +67 -0
  26. xdataapi/models/batch_error.py +79 -0
  27. xdataapi/models/batch_error_code.py +15 -0
  28. xdataapi/models/batch_meta.py +126 -0
  29. xdataapi/models/batch_meta_cache.py +11 -0
  30. xdataapi/models/create_checkout_body.py +63 -0
  31. xdataapi/models/create_checkout_body_pack.py +11 -0
  32. xdataapi/models/create_checkout_response_200.py +97 -0
  33. xdataapi/models/error.py +78 -0
  34. xdataapi/models/error_body.py +72 -0
  35. xdataapi/models/error_body_code.py +22 -0
  36. xdataapi/models/get_me_response_200.py +88 -0
  37. xdataapi/models/get_tweets_body.py +61 -0
  38. xdataapi/models/get_users_body.py +61 -0
  39. xdataapi/models/id_page.py +117 -0
  40. xdataapi/models/list_packs_response_200.py +105 -0
  41. xdataapi/models/list_packs_response_200_data_item.py +88 -0
  42. xdataapi/models/list_packs_response_200_rate_limits_item.py +70 -0
  43. xdataapi/models/media.py +96 -0
  44. xdataapi/models/media_type.py +10 -0
  45. xdataapi/models/meta.py +106 -0
  46. xdataapi/models/meta_cache.py +10 -0
  47. xdataapi/models/problem.py +131 -0
  48. xdataapi/models/search_tweets_product.py +12 -0
  49. xdataapi/models/tweet.py +310 -0
  50. xdataapi/models/tweet_batch.py +150 -0
  51. xdataapi/models/tweet_page.py +133 -0
  52. xdataapi/models/tweet_response.py +128 -0
  53. xdataapi/models/user.py +204 -0
  54. xdataapi/models/user_batch.py +150 -0
  55. xdataapi/models/user_page.py +133 -0
  56. xdataapi/models/user_response.py +128 -0
  57. xdataapi/py.typed +1 -0
  58. xdataapi/types.py +54 -0
  59. xdataapi-0.3.0.dist-info/METADATA +148 -0
  60. xdataapi-0.3.0.dist-info/RECORD +61 -0
  61. xdataapi-0.3.0.dist-info/WHEEL +4 -0
xdataapi/__init__.py ADDED
@@ -0,0 +1,8 @@
1
+ """A client library for accessing xdataapi.io API"""
2
+
3
+ from .client import AuthenticatedClient, Client
4
+
5
+ __all__ = (
6
+ "AuthenticatedClient",
7
+ "Client",
8
+ )
@@ -0,0 +1 @@
1
+ """Contains methods for accessing the API"""
@@ -0,0 +1 @@
1
+ """Contains endpoint functions for accessing the API"""
@@ -0,0 +1,144 @@
1
+ from http import HTTPStatus
2
+ from typing import Any
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...models.error import Error
9
+ from ...models.get_me_response_200 import GetMeResponse200
10
+ from ...types import Response
11
+
12
+
13
+ def _get_kwargs() -> dict[str, Any]:
14
+
15
+ _kwargs: dict[str, Any] = {
16
+ "method": "get",
17
+ "url": "/v1/me",
18
+ }
19
+
20
+ return _kwargs
21
+
22
+
23
+ def _parse_response(
24
+ *, client: AuthenticatedClient | Client, response: httpx.Response
25
+ ) -> Error | GetMeResponse200 | None:
26
+ if response.status_code == 200:
27
+ response_200 = GetMeResponse200.from_dict(response.json())
28
+
29
+ return response_200
30
+
31
+ if response.status_code == 401:
32
+ response_401 = Error.from_dict(response.json())
33
+
34
+ return response_401
35
+
36
+ if response.status_code == 429:
37
+ response_429 = Error.from_dict(response.json())
38
+
39
+ return response_429
40
+
41
+ if response.status_code == 500:
42
+ response_500 = Error.from_dict(response.json())
43
+
44
+ return response_500
45
+
46
+ if client.raise_on_unexpected_status:
47
+ raise errors.UnexpectedStatus(response.status_code, response.content)
48
+ else:
49
+ return None
50
+
51
+
52
+ def _build_response(
53
+ *, client: AuthenticatedClient | Client, response: httpx.Response
54
+ ) -> Response[Error | GetMeResponse200]:
55
+ return Response(
56
+ status_code=HTTPStatus(response.status_code),
57
+ content=response.content,
58
+ headers=response.headers,
59
+ parsed=_parse_response(client=client, response=response),
60
+ )
61
+
62
+
63
+ def sync_detailed(
64
+ *,
65
+ client: AuthenticatedClient | Client,
66
+ ) -> Response[Error | GetMeResponse200]:
67
+ """Key, balance and rate limit
68
+
69
+ Raises:
70
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
71
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
72
+
73
+ Returns:
74
+ Response[Error | GetMeResponse200]
75
+ """
76
+
77
+ kwargs = _get_kwargs()
78
+
79
+ response = client.get_httpx_client().request(
80
+ **kwargs,
81
+ )
82
+
83
+ return _build_response(client=client, response=response)
84
+
85
+
86
+ def sync(
87
+ *,
88
+ client: AuthenticatedClient | Client,
89
+ ) -> Error | GetMeResponse200 | None:
90
+ """Key, balance and rate limit
91
+
92
+ Raises:
93
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
94
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
95
+
96
+ Returns:
97
+ Error | GetMeResponse200
98
+ """
99
+
100
+ return sync_detailed(
101
+ client=client,
102
+ ).parsed
103
+
104
+
105
+ async def asyncio_detailed(
106
+ *,
107
+ client: AuthenticatedClient | Client,
108
+ ) -> Response[Error | GetMeResponse200]:
109
+ """Key, balance and rate limit
110
+
111
+ Raises:
112
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
113
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
114
+
115
+ Returns:
116
+ Response[Error | GetMeResponse200]
117
+ """
118
+
119
+ kwargs = _get_kwargs()
120
+
121
+ response = await client.get_async_httpx_client().request(**kwargs)
122
+
123
+ return _build_response(client=client, response=response)
124
+
125
+
126
+ async def asyncio(
127
+ *,
128
+ client: AuthenticatedClient | Client,
129
+ ) -> Error | GetMeResponse200 | None:
130
+ """Key, balance and rate limit
131
+
132
+ Raises:
133
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
134
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
135
+
136
+ Returns:
137
+ Error | GetMeResponse200
138
+ """
139
+
140
+ return (
141
+ await asyncio_detailed(
142
+ client=client,
143
+ )
144
+ ).parsed
@@ -0,0 +1 @@
1
+ """Contains endpoint functions for accessing the API"""
@@ -0,0 +1,206 @@
1
+ from http import HTTPStatus
2
+ from typing import Any
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...models.create_checkout_body import CreateCheckoutBody
9
+ from ...models.create_checkout_response_200 import CreateCheckoutResponse200
10
+ from ...models.error import Error
11
+ from ...types import Response
12
+
13
+
14
+ def _get_kwargs(
15
+ *,
16
+ body: CreateCheckoutBody,
17
+ ) -> dict[str, Any]:
18
+ headers: dict[str, Any] = {}
19
+
20
+ _kwargs: dict[str, Any] = {
21
+ "method": "post",
22
+ "url": "/v1/billing/checkout",
23
+ }
24
+
25
+ _kwargs["json"] = body.to_dict()
26
+
27
+ headers["Content-Type"] = "application/json"
28
+
29
+ _kwargs["headers"] = headers
30
+ return _kwargs
31
+
32
+
33
+ def _parse_response(
34
+ *, client: AuthenticatedClient | Client, response: httpx.Response
35
+ ) -> CreateCheckoutResponse200 | Error | None:
36
+ if response.status_code == 200:
37
+ response_200 = CreateCheckoutResponse200.from_dict(response.json())
38
+
39
+ return response_200
40
+
41
+ if response.status_code == 400:
42
+ response_400 = Error.from_dict(response.json())
43
+
44
+ return response_400
45
+
46
+ if response.status_code == 401:
47
+ response_401 = Error.from_dict(response.json())
48
+
49
+ return response_401
50
+
51
+ if response.status_code == 429:
52
+ response_429 = Error.from_dict(response.json())
53
+
54
+ return response_429
55
+
56
+ if response.status_code == 500:
57
+ response_500 = Error.from_dict(response.json())
58
+
59
+ return response_500
60
+
61
+ if response.status_code == 503:
62
+ response_503 = Error.from_dict(response.json())
63
+
64
+ return response_503
65
+
66
+ if client.raise_on_unexpected_status:
67
+ raise errors.UnexpectedStatus(response.status_code, response.content)
68
+ else:
69
+ return None
70
+
71
+
72
+ def _build_response(
73
+ *, client: AuthenticatedClient | Client, response: httpx.Response
74
+ ) -> Response[CreateCheckoutResponse200 | Error]:
75
+ return Response(
76
+ status_code=HTTPStatus(response.status_code),
77
+ content=response.content,
78
+ headers=response.headers,
79
+ parsed=_parse_response(client=client, response=response),
80
+ )
81
+
82
+
83
+ def sync_detailed(
84
+ *,
85
+ client: AuthenticatedClient | Client,
86
+ body: CreateCheckoutBody,
87
+ ) -> Response[CreateCheckoutResponse200 | Error]:
88
+ """Buy a credit pack
89
+
90
+ Returns a Stripe Checkout URL. Open it in a browser; after payment the credits land in the wallet of
91
+ the
92
+ key's account within seconds. The rate limit follows the total paid over the account's life and only
93
+ goes up (see `rate_limits` on `/v1/billing/packs`). Credits never expire.
94
+
95
+ Args:
96
+ body (CreateCheckoutBody):
97
+
98
+ Raises:
99
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
100
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
101
+
102
+ Returns:
103
+ Response[CreateCheckoutResponse200 | Error]
104
+ """
105
+
106
+ kwargs = _get_kwargs(
107
+ body=body,
108
+ )
109
+
110
+ response = client.get_httpx_client().request(
111
+ **kwargs,
112
+ )
113
+
114
+ return _build_response(client=client, response=response)
115
+
116
+
117
+ def sync(
118
+ *,
119
+ client: AuthenticatedClient | Client,
120
+ body: CreateCheckoutBody,
121
+ ) -> CreateCheckoutResponse200 | Error | None:
122
+ """Buy a credit pack
123
+
124
+ Returns a Stripe Checkout URL. Open it in a browser; after payment the credits land in the wallet of
125
+ the
126
+ key's account within seconds. The rate limit follows the total paid over the account's life and only
127
+ goes up (see `rate_limits` on `/v1/billing/packs`). Credits never expire.
128
+
129
+ Args:
130
+ body (CreateCheckoutBody):
131
+
132
+ Raises:
133
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
134
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
135
+
136
+ Returns:
137
+ CreateCheckoutResponse200 | Error
138
+ """
139
+
140
+ return sync_detailed(
141
+ client=client,
142
+ body=body,
143
+ ).parsed
144
+
145
+
146
+ async def asyncio_detailed(
147
+ *,
148
+ client: AuthenticatedClient | Client,
149
+ body: CreateCheckoutBody,
150
+ ) -> Response[CreateCheckoutResponse200 | Error]:
151
+ """Buy a credit pack
152
+
153
+ Returns a Stripe Checkout URL. Open it in a browser; after payment the credits land in the wallet of
154
+ the
155
+ key's account within seconds. The rate limit follows the total paid over the account's life and only
156
+ goes up (see `rate_limits` on `/v1/billing/packs`). Credits never expire.
157
+
158
+ Args:
159
+ body (CreateCheckoutBody):
160
+
161
+ Raises:
162
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
163
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
164
+
165
+ Returns:
166
+ Response[CreateCheckoutResponse200 | Error]
167
+ """
168
+
169
+ kwargs = _get_kwargs(
170
+ body=body,
171
+ )
172
+
173
+ response = await client.get_async_httpx_client().request(**kwargs)
174
+
175
+ return _build_response(client=client, response=response)
176
+
177
+
178
+ async def asyncio(
179
+ *,
180
+ client: AuthenticatedClient | Client,
181
+ body: CreateCheckoutBody,
182
+ ) -> CreateCheckoutResponse200 | Error | None:
183
+ """Buy a credit pack
184
+
185
+ Returns a Stripe Checkout URL. Open it in a browser; after payment the credits land in the wallet of
186
+ the
187
+ key's account within seconds. The rate limit follows the total paid over the account's life and only
188
+ goes up (see `rate_limits` on `/v1/billing/packs`). Credits never expire.
189
+
190
+ Args:
191
+ body (CreateCheckoutBody):
192
+
193
+ Raises:
194
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
195
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
196
+
197
+ Returns:
198
+ CreateCheckoutResponse200 | Error
199
+ """
200
+
201
+ return (
202
+ await asyncio_detailed(
203
+ client=client,
204
+ body=body,
205
+ )
206
+ ).parsed
@@ -0,0 +1,144 @@
1
+ from http import HTTPStatus
2
+ from typing import Any
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...models.error import Error
9
+ from ...models.list_packs_response_200 import ListPacksResponse200
10
+ from ...types import Response
11
+
12
+
13
+ def _get_kwargs() -> dict[str, Any]:
14
+
15
+ _kwargs: dict[str, Any] = {
16
+ "method": "get",
17
+ "url": "/v1/billing/packs",
18
+ }
19
+
20
+ return _kwargs
21
+
22
+
23
+ def _parse_response(
24
+ *, client: AuthenticatedClient | Client, response: httpx.Response
25
+ ) -> Error | ListPacksResponse200 | None:
26
+ if response.status_code == 200:
27
+ response_200 = ListPacksResponse200.from_dict(response.json())
28
+
29
+ return response_200
30
+
31
+ if response.status_code == 401:
32
+ response_401 = Error.from_dict(response.json())
33
+
34
+ return response_401
35
+
36
+ if response.status_code == 429:
37
+ response_429 = Error.from_dict(response.json())
38
+
39
+ return response_429
40
+
41
+ if response.status_code == 500:
42
+ response_500 = Error.from_dict(response.json())
43
+
44
+ return response_500
45
+
46
+ if client.raise_on_unexpected_status:
47
+ raise errors.UnexpectedStatus(response.status_code, response.content)
48
+ else:
49
+ return None
50
+
51
+
52
+ def _build_response(
53
+ *, client: AuthenticatedClient | Client, response: httpx.Response
54
+ ) -> Response[Error | ListPacksResponse200]:
55
+ return Response(
56
+ status_code=HTTPStatus(response.status_code),
57
+ content=response.content,
58
+ headers=response.headers,
59
+ parsed=_parse_response(client=client, response=response),
60
+ )
61
+
62
+
63
+ def sync_detailed(
64
+ *,
65
+ client: AuthenticatedClient | Client,
66
+ ) -> Response[Error | ListPacksResponse200]:
67
+ """Credit packs on sale
68
+
69
+ Raises:
70
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
71
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
72
+
73
+ Returns:
74
+ Response[Error | ListPacksResponse200]
75
+ """
76
+
77
+ kwargs = _get_kwargs()
78
+
79
+ response = client.get_httpx_client().request(
80
+ **kwargs,
81
+ )
82
+
83
+ return _build_response(client=client, response=response)
84
+
85
+
86
+ def sync(
87
+ *,
88
+ client: AuthenticatedClient | Client,
89
+ ) -> Error | ListPacksResponse200 | None:
90
+ """Credit packs on sale
91
+
92
+ Raises:
93
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
94
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
95
+
96
+ Returns:
97
+ Error | ListPacksResponse200
98
+ """
99
+
100
+ return sync_detailed(
101
+ client=client,
102
+ ).parsed
103
+
104
+
105
+ async def asyncio_detailed(
106
+ *,
107
+ client: AuthenticatedClient | Client,
108
+ ) -> Response[Error | ListPacksResponse200]:
109
+ """Credit packs on sale
110
+
111
+ Raises:
112
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
113
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
114
+
115
+ Returns:
116
+ Response[Error | ListPacksResponse200]
117
+ """
118
+
119
+ kwargs = _get_kwargs()
120
+
121
+ response = await client.get_async_httpx_client().request(**kwargs)
122
+
123
+ return _build_response(client=client, response=response)
124
+
125
+
126
+ async def asyncio(
127
+ *,
128
+ client: AuthenticatedClient | Client,
129
+ ) -> Error | ListPacksResponse200 | None:
130
+ """Credit packs on sale
131
+
132
+ Raises:
133
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
134
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
135
+
136
+ Returns:
137
+ Error | ListPacksResponse200
138
+ """
139
+
140
+ return (
141
+ await asyncio_detailed(
142
+ client=client,
143
+ )
144
+ ).parsed
@@ -0,0 +1 @@
1
+ """Contains endpoint functions for accessing the API"""