blocket-api 0.3.7__tar.gz → 0.3.9__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.3.9/PKG-INFO +66 -0
- blocket_api-0.3.9/README.md +45 -0
- blocket_api-0.3.9/blocket_api/__init__.py +5 -0
- blocket_api-0.3.9/blocket_api/blocket.py +54 -0
- blocket_api-0.3.9/blocket_api/constants.py +107 -0
- blocket_api-0.3.9/blocket_api.egg-info/PKG-INFO +66 -0
- {blocket_api-0.3.7 → blocket_api-0.3.9}/blocket_api.egg-info/SOURCES.txt +0 -4
- {blocket_api-0.3.7 → blocket_api-0.3.9}/pyproject.toml +1 -1
- blocket_api-0.3.7/PKG-INFO +0 -465
- blocket_api-0.3.7/README.md +0 -444
- blocket_api-0.3.7/blocket_api/__init__.py +0 -11
- blocket_api-0.3.7/blocket_api/blocket.py +0 -631
- blocket_api-0.3.7/blocket_api/constants.py +0 -7
- blocket_api-0.3.7/blocket_api/decorators.py +0 -34
- blocket_api-0.3.7/blocket_api/models.py +0 -621
- blocket_api-0.3.7/blocket_api/qasa.py +0 -137
- blocket_api-0.3.7/blocket_api/sendbird.py +0 -190
- blocket_api-0.3.7/blocket_api.egg-info/PKG-INFO +0 -465
- {blocket_api-0.3.7 → blocket_api-0.3.9}/LICENSE +0 -0
- {blocket_api-0.3.7 → blocket_api-0.3.9}/blocket_api.egg-info/dependency_links.txt +0 -0
- {blocket_api-0.3.7 → blocket_api-0.3.9}/blocket_api.egg-info/requires.txt +0 -0
- {blocket_api-0.3.7 → blocket_api-0.3.9}/blocket_api.egg-info/top_level.txt +0 -0
- {blocket_api-0.3.7 → blocket_api-0.3.9}/setup.cfg +0 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: blocket_api
|
|
3
|
+
Version: 0.3.9
|
|
4
|
+
Summary: A python API wrapper for blocket.se
|
|
5
|
+
Author-email: dunderrrrrr <emil.bjorkroth@gmail.com>
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: httpx>=0.28.1
|
|
10
|
+
Requires-Dist: pre-commit>=3.7.1
|
|
11
|
+
Requires-Dist: pytest>=8.2.2
|
|
12
|
+
Requires-Dist: respx>=0.21.1
|
|
13
|
+
Requires-Dist: mypy>=1.15.0
|
|
14
|
+
Requires-Dist: pydantic>=2.11.7
|
|
15
|
+
Requires-Dist: mkdocs>=1.6.1
|
|
16
|
+
Requires-Dist: mkdocs-material>=9.6.21
|
|
17
|
+
Requires-Dist: mkdocs-swagger-ui-tag>=0.7.2
|
|
18
|
+
Requires-Dist: websockets>=15.0.1
|
|
19
|
+
Requires-Dist: ruff>=0.14.5
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
|
|
22
|
+
<p align="center">
|
|
23
|
+
<img src="https://blocket-api.se/blocket-api.png" />
|
|
24
|
+
</p>
|
|
25
|
+
|
|
26
|
+
# BlocketAPI
|
|
27
|
+
|
|
28
|
+
[](https://pypi.org/project/blocket_api/) [](https://github.com/dunderrrrrr/blocket_api/blob/main/LICENSE)  
|
|
29
|
+
|
|
30
|
+
BlocketAPI allows users to search [blocket.se](https://blocket.se/) for ads.
|
|
31
|
+
|
|
32
|
+
> Blocket is one of Sweden's largest online marketplaces. It was founded in 1996 and allows users to buy and sell a wide range of items, including cars, real estate, jobs, services, and second-hand goods. The platform is known for its extensive reach and user-friendly interface, making it a popular choice for Swedes looking to purchase or sell items quickly and efficiently.
|
|
33
|
+
|
|
34
|
+
> [!NOTE]
|
|
35
|
+
> Blocket recently released a new version of their site which caused this package to break. But do not fear, we are actively working to try and restore all functionality. More info in [issue #43](https://github.com/dunderrrrrr/blocket_api/issues/41).
|
|
36
|
+
|
|
37
|
+
## 🧑💻️ Install
|
|
38
|
+
|
|
39
|
+
Install BlocketAPI via PyPI...
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
pip install blocket-api
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
or use [blocket-api.se](https://blocket-api.se) without installing anything!
|
|
46
|
+
|
|
47
|
+
## 💁♀️ Usage
|
|
48
|
+
|
|
49
|
+
```py
|
|
50
|
+
from blocket_api import BlocketAPI, Category, Location, SortOrder
|
|
51
|
+
|
|
52
|
+
api = BlocketAPI()
|
|
53
|
+
|
|
54
|
+
result = api.search(
|
|
55
|
+
"Vinterdäck Audi",
|
|
56
|
+
sort_order=SortOrder.PRICE_ASC,
|
|
57
|
+
locations=[Location.STOCKHOLM, Location.UPPSALA],
|
|
58
|
+
category=Category.FORDONSTILLBEHOR,
|
|
59
|
+
)
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## 📝 Notes
|
|
63
|
+
|
|
64
|
+
- REST API: https://blocket-api.se
|
|
65
|
+
- Source repo: https://github.com/dunderrrrrr/blocket_api
|
|
66
|
+
- PyPI: https://pypi.org/project/blocket-api/
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://blocket-api.se/blocket-api.png" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
# BlocketAPI
|
|
6
|
+
|
|
7
|
+
[](https://pypi.org/project/blocket_api/) [](https://github.com/dunderrrrrr/blocket_api/blob/main/LICENSE)  
|
|
8
|
+
|
|
9
|
+
BlocketAPI allows users to search [blocket.se](https://blocket.se/) for ads.
|
|
10
|
+
|
|
11
|
+
> Blocket is one of Sweden's largest online marketplaces. It was founded in 1996 and allows users to buy and sell a wide range of items, including cars, real estate, jobs, services, and second-hand goods. The platform is known for its extensive reach and user-friendly interface, making it a popular choice for Swedes looking to purchase or sell items quickly and efficiently.
|
|
12
|
+
|
|
13
|
+
> [!NOTE]
|
|
14
|
+
> Blocket recently released a new version of their site which caused this package to break. But do not fear, we are actively working to try and restore all functionality. More info in [issue #43](https://github.com/dunderrrrrr/blocket_api/issues/41).
|
|
15
|
+
|
|
16
|
+
## 🧑💻️ Install
|
|
17
|
+
|
|
18
|
+
Install BlocketAPI via PyPI...
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
pip install blocket-api
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
or use [blocket-api.se](https://blocket-api.se) without installing anything!
|
|
25
|
+
|
|
26
|
+
## 💁♀️ Usage
|
|
27
|
+
|
|
28
|
+
```py
|
|
29
|
+
from blocket_api import BlocketAPI, Category, Location, SortOrder
|
|
30
|
+
|
|
31
|
+
api = BlocketAPI()
|
|
32
|
+
|
|
33
|
+
result = api.search(
|
|
34
|
+
"Vinterdäck Audi",
|
|
35
|
+
sort_order=SortOrder.PRICE_ASC,
|
|
36
|
+
locations=[Location.STOCKHOLM, Location.UPPSALA],
|
|
37
|
+
category=Category.FORDONSTILLBEHOR,
|
|
38
|
+
)
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## 📝 Notes
|
|
42
|
+
|
|
43
|
+
- REST API: https://blocket-api.se
|
|
44
|
+
- Source repo: https://github.com/dunderrrrrr/blocket_api
|
|
45
|
+
- PyPI: https://pypi.org/project/blocket-api/
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
import httpx
|
|
7
|
+
|
|
8
|
+
from .constants import HEADERS, SITE_URL, Category, Location, SortOrder, SubCategory
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@dataclass(frozen=True)
|
|
12
|
+
class QueryParam:
|
|
13
|
+
name: str
|
|
14
|
+
value: str
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _request(
|
|
18
|
+
*,
|
|
19
|
+
url: str,
|
|
20
|
+
params: list[QueryParam],
|
|
21
|
+
) -> Any:
|
|
22
|
+
response = httpx.get(
|
|
23
|
+
url,
|
|
24
|
+
headers=HEADERS,
|
|
25
|
+
params=[(param.name, param.value) for param in params],
|
|
26
|
+
)
|
|
27
|
+
response.raise_for_status()
|
|
28
|
+
return response.json()
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@dataclass(frozen=True)
|
|
32
|
+
class BlocketAPI:
|
|
33
|
+
def search(
|
|
34
|
+
self,
|
|
35
|
+
query: str,
|
|
36
|
+
*,
|
|
37
|
+
sort_order: SortOrder = SortOrder.RELEVANCE,
|
|
38
|
+
locations: list[Location] = [],
|
|
39
|
+
category: Category | None = None,
|
|
40
|
+
sub_category: SubCategory | None = None,
|
|
41
|
+
) -> Any:
|
|
42
|
+
if category and sub_category:
|
|
43
|
+
raise AssertionError("Cannot specify both category and sub_categories")
|
|
44
|
+
|
|
45
|
+
url = f"{SITE_URL}/recommerce-search-page/api/search/SEARCH_ID_BAP_COMMON"
|
|
46
|
+
params = [
|
|
47
|
+
QueryParam("q", query),
|
|
48
|
+
QueryParam("sort", sort_order.value),
|
|
49
|
+
*[QueryParam("location", location.value) for location in locations],
|
|
50
|
+
*([QueryParam("category", category.value)] if category else []),
|
|
51
|
+
*([QueryParam("sub_category", sub_category.value)] if sub_category else []),
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
return _request(url=url, params=params)
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
from enum import StrEnum
|
|
2
|
+
|
|
3
|
+
SITE_URL = "https://www.blocket.se"
|
|
4
|
+
HEADERS = {
|
|
5
|
+
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0"
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class SortOrder(StrEnum):
|
|
10
|
+
RELEVANCE = "RELEVANCE"
|
|
11
|
+
PRICE_DESC = "PRICE_DESC"
|
|
12
|
+
PRICE_ASC = "PRICE_ASC"
|
|
13
|
+
PUBLISHED_DESC = "PUBLISHED_DESC"
|
|
14
|
+
PUBLISHED_ASC = "PUBLISHED_ASC"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Location(StrEnum):
|
|
18
|
+
BLEKINGE = "0.300010"
|
|
19
|
+
DALARNA = "0.300020"
|
|
20
|
+
GOTLAND = "0.300009"
|
|
21
|
+
GAVLEBORG = "0.300021"
|
|
22
|
+
HALLAND = "0.300013"
|
|
23
|
+
JAMTLAND = "0.300023"
|
|
24
|
+
JONKOPING = "0.300006"
|
|
25
|
+
KALMAR = "0.300008"
|
|
26
|
+
KRONOBERG = "0.300007"
|
|
27
|
+
NORRBOTTEN = "0.300025"
|
|
28
|
+
SKANE = "0.300012"
|
|
29
|
+
STOCKHOLM = "0.300001"
|
|
30
|
+
SODERMANLAND = "0.300004"
|
|
31
|
+
UPPSALA = "0.300003"
|
|
32
|
+
VARMLAND = "0.300017"
|
|
33
|
+
VASTERBOTTEN = "0.300024"
|
|
34
|
+
VASTERNORRLAND = "0.300022"
|
|
35
|
+
VASTMANLAND = "0.300019"
|
|
36
|
+
VASTRA_GÖTALAND = "0.300014"
|
|
37
|
+
OREBRO = "0.300018"
|
|
38
|
+
OSTERGOTLAND = "0.300005"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class Category(StrEnum):
|
|
42
|
+
AFFARSVERKSAMHET = "0.91"
|
|
43
|
+
# BIL_OCH_HUSVAGN = None
|
|
44
|
+
# BAT = None
|
|
45
|
+
DJUR_OCH_TILLBEHOR = "0.77"
|
|
46
|
+
ELEKTRONIK_OCH_VITVAROR = "0.93"
|
|
47
|
+
# ENTREPRENAD__OCH_LANTBRUKSMASKINER = None
|
|
48
|
+
FORDONSTILLBEHOR = "0.90"
|
|
49
|
+
FRITID_HOBBY_OCH_UNDERHALLNING = "0.86"
|
|
50
|
+
FORALDRAR_OCH_BARN = "0.68"
|
|
51
|
+
KLADER_KOSMETIKA_OCH_ACCESSOARER = "0.71"
|
|
52
|
+
KONST_OCH_ANTIKT = "0.76"
|
|
53
|
+
# MOTORCYKLAR = None
|
|
54
|
+
MOBLER_OCH_INREDNING = "0.78"
|
|
55
|
+
SPORT_OCH_FRITID = "0.69"
|
|
56
|
+
TRADGARD_OCH_RENOVERING = "0.67"
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class SubCategory(StrEnum):
|
|
60
|
+
BYGGMATERIAL_OCH_RENOVERING = "1.67.3899"
|
|
61
|
+
BILDELAR_OCH_TILLBEHOR = "1.90.82"
|
|
62
|
+
CYKEL = "1.69.3963"
|
|
63
|
+
JAKT_FISKE_OCH_CAMPING = "1.69.3964"
|
|
64
|
+
TRADGARD_OCH_UTEMILJO = "1.67.3901"
|
|
65
|
+
MC_UTRUSTNING_OCH_RESERVDELAR = "1.90.20"
|
|
66
|
+
HUSVAGNS_OCH_HUSBILSDELAR = "1.90.70"
|
|
67
|
+
VERKTYG = "1.67.5219"
|
|
68
|
+
BUTIK_OCH_DETALJHANDEL = "1.91.3108"
|
|
69
|
+
CONTAINRAR_OCH_BARACKER = "1.91.3111"
|
|
70
|
+
DOMANER_OCH_SAJTER = "1.91.3106"
|
|
71
|
+
HALSA_OCH_FORSTA_HJALPEN = "1.91.8343"
|
|
72
|
+
JORDBRUK = "1.91.3114"
|
|
73
|
+
KONTORSUTRUSTNING_OCH_INREDNING = "1.91.3105"
|
|
74
|
+
LAST_OCH_TRANSPORT = "1.91.3113"
|
|
75
|
+
MASKINUTRUSTNING_OCH_RESERVDELAR = "1.91.3112"
|
|
76
|
+
SCEN = "1.91.3110"
|
|
77
|
+
STORKOK_OCH_RESTAURANG = "1.91.3103"
|
|
78
|
+
VERKSTAD_BYGG_OCH_KONSTRUKTION = "1.91.3102"
|
|
79
|
+
SLAP_OCH_TRAILER = "1.90.80"
|
|
80
|
+
BATDELAR_OCH_TILLBEHOR = "1.90.30"
|
|
81
|
+
AKVARIUM = "1.77.3976"
|
|
82
|
+
BURAR = "1.77.3977"
|
|
83
|
+
FISKAR = "1.77.5206"
|
|
84
|
+
FODER_DJURVARD_KENNLAR_OCH_STALL = "1.77.5186"
|
|
85
|
+
FAGLAR = "1.77.5205"
|
|
86
|
+
GNAGARE_OCH_KANINER = "1.77.5207"
|
|
87
|
+
HUNDAR = "1.77.5192"
|
|
88
|
+
HUNDTILLBEHOR = "1.77.5193"
|
|
89
|
+
HAST_OCH_RIDUTRUSTNING = "1.77.5195"
|
|
90
|
+
HASTAR = "1.77.5190"
|
|
91
|
+
KATTER = "1.77.5191"
|
|
92
|
+
KATTILLBEHOR = "1.77.5194"
|
|
93
|
+
LANTBRUKSDJUR = "1.77.9439"
|
|
94
|
+
REPTILER = "1.77.5210"
|
|
95
|
+
SPINDLAR_OCH_INSEKTER = "1.77.5208"
|
|
96
|
+
OVRIGA_DJUR = "1.77.5183"
|
|
97
|
+
OVRIGA_DJURTILLBEHOR = "1.77.5185"
|
|
98
|
+
DATORER = "1.93.3215"
|
|
99
|
+
FOTO_OCH_VIDEO = "1.93.3904"
|
|
100
|
+
HUSHALLSAPPARATER = "1.93.3216"
|
|
101
|
+
LJUD_OCH_BILD = "1.93.3906"
|
|
102
|
+
PERSONVARD = "1.93.9809"
|
|
103
|
+
TELEFONER_OCH_TILLBEHOR = "1.93.3217"
|
|
104
|
+
TV_SPEL_OCH_SPELKONSOLER = "1.93.3905"
|
|
105
|
+
VITVAROR = "1.93.3907"
|
|
106
|
+
ATV_RESERVDELAR = "1.90.3975"
|
|
107
|
+
OVRIGT = "1.90.3974"
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: blocket_api
|
|
3
|
+
Version: 0.3.9
|
|
4
|
+
Summary: A python API wrapper for blocket.se
|
|
5
|
+
Author-email: dunderrrrrr <emil.bjorkroth@gmail.com>
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: httpx>=0.28.1
|
|
10
|
+
Requires-Dist: pre-commit>=3.7.1
|
|
11
|
+
Requires-Dist: pytest>=8.2.2
|
|
12
|
+
Requires-Dist: respx>=0.21.1
|
|
13
|
+
Requires-Dist: mypy>=1.15.0
|
|
14
|
+
Requires-Dist: pydantic>=2.11.7
|
|
15
|
+
Requires-Dist: mkdocs>=1.6.1
|
|
16
|
+
Requires-Dist: mkdocs-material>=9.6.21
|
|
17
|
+
Requires-Dist: mkdocs-swagger-ui-tag>=0.7.2
|
|
18
|
+
Requires-Dist: websockets>=15.0.1
|
|
19
|
+
Requires-Dist: ruff>=0.14.5
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
|
|
22
|
+
<p align="center">
|
|
23
|
+
<img src="https://blocket-api.se/blocket-api.png" />
|
|
24
|
+
</p>
|
|
25
|
+
|
|
26
|
+
# BlocketAPI
|
|
27
|
+
|
|
28
|
+
[](https://pypi.org/project/blocket_api/) [](https://github.com/dunderrrrrr/blocket_api/blob/main/LICENSE)  
|
|
29
|
+
|
|
30
|
+
BlocketAPI allows users to search [blocket.se](https://blocket.se/) for ads.
|
|
31
|
+
|
|
32
|
+
> Blocket is one of Sweden's largest online marketplaces. It was founded in 1996 and allows users to buy and sell a wide range of items, including cars, real estate, jobs, services, and second-hand goods. The platform is known for its extensive reach and user-friendly interface, making it a popular choice for Swedes looking to purchase or sell items quickly and efficiently.
|
|
33
|
+
|
|
34
|
+
> [!NOTE]
|
|
35
|
+
> Blocket recently released a new version of their site which caused this package to break. But do not fear, we are actively working to try and restore all functionality. More info in [issue #43](https://github.com/dunderrrrrr/blocket_api/issues/41).
|
|
36
|
+
|
|
37
|
+
## 🧑💻️ Install
|
|
38
|
+
|
|
39
|
+
Install BlocketAPI via PyPI...
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
pip install blocket-api
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
or use [blocket-api.se](https://blocket-api.se) without installing anything!
|
|
46
|
+
|
|
47
|
+
## 💁♀️ Usage
|
|
48
|
+
|
|
49
|
+
```py
|
|
50
|
+
from blocket_api import BlocketAPI, Category, Location, SortOrder
|
|
51
|
+
|
|
52
|
+
api = BlocketAPI()
|
|
53
|
+
|
|
54
|
+
result = api.search(
|
|
55
|
+
"Vinterdäck Audi",
|
|
56
|
+
sort_order=SortOrder.PRICE_ASC,
|
|
57
|
+
locations=[Location.STOCKHOLM, Location.UPPSALA],
|
|
58
|
+
category=Category.FORDONSTILLBEHOR,
|
|
59
|
+
)
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## 📝 Notes
|
|
63
|
+
|
|
64
|
+
- REST API: https://blocket-api.se
|
|
65
|
+
- Source repo: https://github.com/dunderrrrrr/blocket_api
|
|
66
|
+
- PyPI: https://pypi.org/project/blocket-api/
|
|
@@ -4,10 +4,6 @@ pyproject.toml
|
|
|
4
4
|
blocket_api/__init__.py
|
|
5
5
|
blocket_api/blocket.py
|
|
6
6
|
blocket_api/constants.py
|
|
7
|
-
blocket_api/decorators.py
|
|
8
|
-
blocket_api/models.py
|
|
9
|
-
blocket_api/qasa.py
|
|
10
|
-
blocket_api/sendbird.py
|
|
11
7
|
blocket_api.egg-info/PKG-INFO
|
|
12
8
|
blocket_api.egg-info/SOURCES.txt
|
|
13
9
|
blocket_api.egg-info/dependency_links.txt
|