blocket-api 0.2.5__tar.gz → 0.2.6__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.
- {blocket_api-0.2.5 → blocket_api-0.2.6}/PKG-INFO +21 -1
- {blocket_api-0.2.5 → blocket_api-0.2.6}/README.md +20 -0
- {blocket_api-0.2.5 → blocket_api-0.2.6}/blocket_api/blocket.py +23 -0
- blocket_api-0.2.6/blocket_api/qasa.py +135 -0
- {blocket_api-0.2.5 → blocket_api-0.2.6}/blocket_api.egg-info/PKG-INFO +21 -1
- {blocket_api-0.2.5 → blocket_api-0.2.6}/blocket_api.egg-info/SOURCES.txt +1 -0
- {blocket_api-0.2.5 → blocket_api-0.2.6}/pyproject.toml +1 -1
- {blocket_api-0.2.5 → blocket_api-0.2.6}/LICENSE +0 -0
- {blocket_api-0.2.5 → blocket_api-0.2.6}/blocket_api/__init__.py +0 -0
- {blocket_api-0.2.5 → blocket_api-0.2.6}/blocket_api.egg-info/dependency_links.txt +0 -0
- {blocket_api-0.2.5 → blocket_api-0.2.6}/blocket_api.egg-info/requires.txt +0 -0
- {blocket_api-0.2.5 → blocket_api-0.2.6}/blocket_api.egg-info/top_level.txt +0 -0
- {blocket_api-0.2.5 → blocket_api-0.2.6}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: blocket_api
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.6
|
|
4
4
|
Summary: A python API wrapper for blocket.se
|
|
5
5
|
Author-email: dunderrrrrr <emil.bjorkroth@gmail.com>
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -60,6 +60,7 @@ Some calls require a bearerToken. However, some calls are public and don't requi
|
|
|
60
60
|
| [`api.custom_search()`](#custom_searchsearch_query-region-limit) | 👏 No | Search for everything on Blocket and filter by region |
|
|
61
61
|
| [`api.motor_search()`](#motor_searchpage-make-fuel-chassi-price-modelyear-milage-gearbox) | 👏 No | Advanced search for car-listings. |
|
|
62
62
|
| [`api.price_eval()`](#price_evalregistration_number) | 👏 No | Vehicle purchase valuation and details. |
|
|
63
|
+
| [`api.home_search()`](#home_searchcity-type-order_by-ordering-offset) | 👏 No | Query home listings.
|
|
63
64
|
|
|
64
65
|
## 🤓 Detailed usage
|
|
65
66
|
|
|
@@ -197,6 +198,25 @@ Query price evaluation for a specific vehicle by using cars registration number
|
|
|
197
198
|
}
|
|
198
199
|
```
|
|
199
200
|
|
|
201
|
+
### home_search(city, type, order_by, ordering, offset)
|
|
202
|
+
Query home listings from [bostad.blocket.se](https://bostad.blocket.se/).
|
|
203
|
+
|
|
204
|
+
- `city` (`str`, required) - City name, ex. Stockholm.
|
|
205
|
+
- `type` (`HomeType`, optional) - Type of home, ex. `HomeType.apartment`.
|
|
206
|
+
- `order_by` (`OrderBy`, optional) - Sorting order, ex. `OrderBy.price`.
|
|
207
|
+
- `ordering` (`HOME_SEARCH_ORDERING`, optional) - Sorting order, ex. `"descending"`.
|
|
208
|
+
- `offset` (`int`, optional) - Offset for results, ex. `60`.
|
|
209
|
+
|
|
210
|
+
```py
|
|
211
|
+
>>> api.home_search(
|
|
212
|
+
city="Stockholm",
|
|
213
|
+
type=HomeType.apartment,
|
|
214
|
+
order_by=OrderBy.price,
|
|
215
|
+
ordering="descending",
|
|
216
|
+
)
|
|
217
|
+
...
|
|
218
|
+
```
|
|
219
|
+
|
|
200
220
|
## 🔐 Blocket API token
|
|
201
221
|
|
|
202
222
|
There are two ways to acquire your token:
|
|
@@ -44,6 +44,7 @@ Some calls require a bearerToken. However, some calls are public and don't requi
|
|
|
44
44
|
| [`api.custom_search()`](#custom_searchsearch_query-region-limit) | 👏 No | Search for everything on Blocket and filter by region |
|
|
45
45
|
| [`api.motor_search()`](#motor_searchpage-make-fuel-chassi-price-modelyear-milage-gearbox) | 👏 No | Advanced search for car-listings. |
|
|
46
46
|
| [`api.price_eval()`](#price_evalregistration_number) | 👏 No | Vehicle purchase valuation and details. |
|
|
47
|
+
| [`api.home_search()`](#home_searchcity-type-order_by-ordering-offset) | 👏 No | Query home listings.
|
|
47
48
|
|
|
48
49
|
## 🤓 Detailed usage
|
|
49
50
|
|
|
@@ -181,6 +182,25 @@ Query price evaluation for a specific vehicle by using cars registration number
|
|
|
181
182
|
}
|
|
182
183
|
```
|
|
183
184
|
|
|
185
|
+
### home_search(city, type, order_by, ordering, offset)
|
|
186
|
+
Query home listings from [bostad.blocket.se](https://bostad.blocket.se/).
|
|
187
|
+
|
|
188
|
+
- `city` (`str`, required) - City name, ex. Stockholm.
|
|
189
|
+
- `type` (`HomeType`, optional) - Type of home, ex. `HomeType.apartment`.
|
|
190
|
+
- `order_by` (`OrderBy`, optional) - Sorting order, ex. `OrderBy.price`.
|
|
191
|
+
- `ordering` (`HOME_SEARCH_ORDERING`, optional) - Sorting order, ex. `"descending"`.
|
|
192
|
+
- `offset` (`int`, optional) - Offset for results, ex. `60`.
|
|
193
|
+
|
|
194
|
+
```py
|
|
195
|
+
>>> api.home_search(
|
|
196
|
+
city="Stockholm",
|
|
197
|
+
type=HomeType.apartment,
|
|
198
|
+
order_by=OrderBy.price,
|
|
199
|
+
ordering="descending",
|
|
200
|
+
)
|
|
201
|
+
...
|
|
202
|
+
```
|
|
203
|
+
|
|
184
204
|
## 🔐 Blocket API token
|
|
185
205
|
|
|
186
206
|
There are two ways to acquire your token:
|
|
@@ -9,6 +9,8 @@ from typing import TYPE_CHECKING, Any, List, Literal, Optional, Tuple
|
|
|
9
9
|
|
|
10
10
|
import httpx
|
|
11
11
|
|
|
12
|
+
from blocket_api.qasa import HOME_SEARCH_ORDERING, HomeType, OrderBy, Qasa
|
|
13
|
+
|
|
12
14
|
if TYPE_CHECKING:
|
|
13
15
|
from httpx import Response
|
|
14
16
|
|
|
@@ -259,3 +261,24 @@ class BlocketAPI:
|
|
|
259
261
|
"""
|
|
260
262
|
url = f"{BYTBIL_URL}/blocket-basedata-api/v3/vehicle-data/{registration_number}"
|
|
261
263
|
return _make_request(url=f"{url}", token=None).json()
|
|
264
|
+
|
|
265
|
+
def home_search(
|
|
266
|
+
self,
|
|
267
|
+
city: str,
|
|
268
|
+
type: HomeType,
|
|
269
|
+
order_by: OrderBy = OrderBy.published_at,
|
|
270
|
+
ordering: HOME_SEARCH_ORDERING = "descending",
|
|
271
|
+
offset: int = 0,
|
|
272
|
+
) -> dict:
|
|
273
|
+
"""
|
|
274
|
+
This returns all available home listings available at
|
|
275
|
+
https://bostad.blocket.se/. Specify offset to get next page. Each page contains
|
|
276
|
+
60 items, which is max items returned per api query.
|
|
277
|
+
"""
|
|
278
|
+
return Qasa(
|
|
279
|
+
city=city,
|
|
280
|
+
home_type=type,
|
|
281
|
+
order_by=order_by,
|
|
282
|
+
ordering=ordering,
|
|
283
|
+
offset=offset,
|
|
284
|
+
).search()
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from enum import Enum
|
|
3
|
+
from typing import Literal
|
|
4
|
+
import httpx
|
|
5
|
+
|
|
6
|
+
QASA_URL = "https://api.qasa.se/graphql"
|
|
7
|
+
HOME_SEARCH_ORDERING = Literal["descending", "ascending"]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class OrderBy(Enum):
|
|
11
|
+
published_at = "published_or_bumped_at"
|
|
12
|
+
price = "monthly_cost_cents"
|
|
13
|
+
size = "square_meters"
|
|
14
|
+
move_in_date = "start_date"
|
|
15
|
+
move_out_date = "end_date"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class HomeType(Enum):
|
|
19
|
+
apartment = ["apartment", "loft"]
|
|
20
|
+
house = ["house", "terrace_house", "duplex"]
|
|
21
|
+
cottage = ["cottage"]
|
|
22
|
+
corridor = ["corridor", "room"]
|
|
23
|
+
other = ["other"]
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@dataclass
|
|
27
|
+
class Qasa:
|
|
28
|
+
city: str
|
|
29
|
+
home_type: HomeType
|
|
30
|
+
order_by: OrderBy
|
|
31
|
+
ordering: HOME_SEARCH_ORDERING
|
|
32
|
+
offset: int
|
|
33
|
+
|
|
34
|
+
def _construct_payload(self) -> dict:
|
|
35
|
+
return {
|
|
36
|
+
"operationName": "HomeSearch",
|
|
37
|
+
"variables": {
|
|
38
|
+
"limit": 60, # no more than 60 items per page is allowed
|
|
39
|
+
"offset": 0,
|
|
40
|
+
"order": {
|
|
41
|
+
"direction": f"{self.ordering}",
|
|
42
|
+
"orderBy": f"{self.order_by.value}",
|
|
43
|
+
},
|
|
44
|
+
"params": {
|
|
45
|
+
"currency": "SEK",
|
|
46
|
+
"homeType": self.home_type.value,
|
|
47
|
+
"areaIdentifier": [f"se/{self.city}"],
|
|
48
|
+
"rentalType": ["long_term"],
|
|
49
|
+
"markets": ["sweden"],
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
"query": """
|
|
53
|
+
query HomeSearch(
|
|
54
|
+
$order: HomeIndexSearchOrderInput,
|
|
55
|
+
$offset: Int,
|
|
56
|
+
$limit: Int,
|
|
57
|
+
$params: HomeSearchParamsInput
|
|
58
|
+
) {
|
|
59
|
+
homeIndexSearch(order: $order, params: $params) {
|
|
60
|
+
documents(offset: $offset, limit: $limit) {
|
|
61
|
+
hasNextPage
|
|
62
|
+
hasPreviousPage
|
|
63
|
+
nodes {
|
|
64
|
+
bedroomCount
|
|
65
|
+
blockListing
|
|
66
|
+
rentalLengthSeconds
|
|
67
|
+
householdSize
|
|
68
|
+
corporateHome
|
|
69
|
+
description
|
|
70
|
+
endDate
|
|
71
|
+
firstHand
|
|
72
|
+
furnished
|
|
73
|
+
homeType
|
|
74
|
+
id
|
|
75
|
+
instantSign
|
|
76
|
+
market
|
|
77
|
+
lastBumpedAt
|
|
78
|
+
monthlyCost
|
|
79
|
+
petsAllowed
|
|
80
|
+
platform
|
|
81
|
+
publishedAt
|
|
82
|
+
publishedOrBumpedAt
|
|
83
|
+
earlyAccessEndsAt
|
|
84
|
+
rent
|
|
85
|
+
currency
|
|
86
|
+
roomCount
|
|
87
|
+
seniorHome
|
|
88
|
+
shared
|
|
89
|
+
shortcutHome
|
|
90
|
+
smokingAllowed
|
|
91
|
+
sortingScore
|
|
92
|
+
squareMeters
|
|
93
|
+
startDate
|
|
94
|
+
studentHome
|
|
95
|
+
tenantBaseFee
|
|
96
|
+
title
|
|
97
|
+
wheelchairAccessible
|
|
98
|
+
location {
|
|
99
|
+
id
|
|
100
|
+
locality
|
|
101
|
+
countryCode
|
|
102
|
+
streetNumber
|
|
103
|
+
point {
|
|
104
|
+
lat
|
|
105
|
+
lon
|
|
106
|
+
__typename
|
|
107
|
+
}
|
|
108
|
+
route
|
|
109
|
+
__typename
|
|
110
|
+
}
|
|
111
|
+
displayStreetNumber
|
|
112
|
+
uploads {
|
|
113
|
+
id
|
|
114
|
+
order
|
|
115
|
+
type
|
|
116
|
+
url
|
|
117
|
+
__typename
|
|
118
|
+
}
|
|
119
|
+
__typename
|
|
120
|
+
}
|
|
121
|
+
pagesCount
|
|
122
|
+
totalCount
|
|
123
|
+
__typename
|
|
124
|
+
}
|
|
125
|
+
__typename
|
|
126
|
+
}
|
|
127
|
+
}""",
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
def search(self) -> dict:
|
|
131
|
+
query = self._construct_payload()
|
|
132
|
+
|
|
133
|
+
response = httpx.post(QASA_URL, json=query)
|
|
134
|
+
response.raise_for_status()
|
|
135
|
+
return response.json()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: blocket_api
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.6
|
|
4
4
|
Summary: A python API wrapper for blocket.se
|
|
5
5
|
Author-email: dunderrrrrr <emil.bjorkroth@gmail.com>
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -60,6 +60,7 @@ Some calls require a bearerToken. However, some calls are public and don't requi
|
|
|
60
60
|
| [`api.custom_search()`](#custom_searchsearch_query-region-limit) | 👏 No | Search for everything on Blocket and filter by region |
|
|
61
61
|
| [`api.motor_search()`](#motor_searchpage-make-fuel-chassi-price-modelyear-milage-gearbox) | 👏 No | Advanced search for car-listings. |
|
|
62
62
|
| [`api.price_eval()`](#price_evalregistration_number) | 👏 No | Vehicle purchase valuation and details. |
|
|
63
|
+
| [`api.home_search()`](#home_searchcity-type-order_by-ordering-offset) | 👏 No | Query home listings.
|
|
63
64
|
|
|
64
65
|
## 🤓 Detailed usage
|
|
65
66
|
|
|
@@ -197,6 +198,25 @@ Query price evaluation for a specific vehicle by using cars registration number
|
|
|
197
198
|
}
|
|
198
199
|
```
|
|
199
200
|
|
|
201
|
+
### home_search(city, type, order_by, ordering, offset)
|
|
202
|
+
Query home listings from [bostad.blocket.se](https://bostad.blocket.se/).
|
|
203
|
+
|
|
204
|
+
- `city` (`str`, required) - City name, ex. Stockholm.
|
|
205
|
+
- `type` (`HomeType`, optional) - Type of home, ex. `HomeType.apartment`.
|
|
206
|
+
- `order_by` (`OrderBy`, optional) - Sorting order, ex. `OrderBy.price`.
|
|
207
|
+
- `ordering` (`HOME_SEARCH_ORDERING`, optional) - Sorting order, ex. `"descending"`.
|
|
208
|
+
- `offset` (`int`, optional) - Offset for results, ex. `60`.
|
|
209
|
+
|
|
210
|
+
```py
|
|
211
|
+
>>> api.home_search(
|
|
212
|
+
city="Stockholm",
|
|
213
|
+
type=HomeType.apartment,
|
|
214
|
+
order_by=OrderBy.price,
|
|
215
|
+
ordering="descending",
|
|
216
|
+
)
|
|
217
|
+
...
|
|
218
|
+
```
|
|
219
|
+
|
|
200
220
|
## 🔐 Blocket API token
|
|
201
221
|
|
|
202
222
|
There are two ways to acquire your token:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|