blocket-api 0.3.0__tar.gz → 0.3.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: blocket_api
3
- Version: 0.3.0
3
+ Version: 0.3.1
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
@@ -31,6 +31,7 @@ BlocketAPI allows users to query saved searches, known as "Bevakningar", on [blo
31
31
  - Get vehicle information, price evaluation and search for vehicles with multiple filters.
32
32
  - Search for homes with filters for city, home type and more.
33
33
  - Search for stores and get a specific store's listings.
34
+ - ...and more!
34
35
 
35
36
  ## 🧑‍💻️ Install
36
37
 
@@ -69,6 +70,7 @@ Some calls require a `bearerToken`. However, some calls are public and don't req
69
70
  | [`api.store_search()`](#store_search) | 👏 No | Yes | Search for a store.
70
71
  | [`api.get_store_listings()`](#get_store_listings) | 👏 No | Yes | Get listings from a specific store.
71
72
  | [`api.get_ad_by_id()`](#get_ad_by_id) | 👏 No | Yes | Get ad data from id.
73
+ | [`api.get_user_by_id()`](#get_user_by_id) | 👏 No | Yes | Get user data from id.
72
74
 
73
75
 
74
76
  ## 🤓 Detailed usage
@@ -302,6 +304,29 @@ Get ad data from a specific ad id.
302
304
  }
303
305
  ```
304
306
 
307
+ ### get_user_by_id
308
+ Get user data from a user id. User id can be found in ads, searches and in blocket url `https://www.blocket.se/profil/<user_id>`.
309
+
310
+ - `user_id` (`int`, required) - The blocket user id.
311
+ - `as_objects` (`bool`, optional) - Return results as pydantic models, default is `False`.
312
+
313
+
314
+ ```py
315
+ >>> api.get_user_by_id(1234)
316
+ {
317
+ 'account': {
318
+ 'blocket_account_id': '1234',
319
+ 'created_at': '2020-10-10T15:45:06.407660',
320
+ 'is_verified': True,
321
+ 'name': 'Janne',
322
+ ...
323
+ },
324
+ 'active_ads': {[
325
+ ...
326
+ ]}
327
+ }
328
+ ```
329
+
305
330
  ## 🔐 Blocket API token
306
331
 
307
332
  There are two ways to acquire your token:
@@ -14,6 +14,7 @@ BlocketAPI allows users to query saved searches, known as "Bevakningar", on [blo
14
14
  - Get vehicle information, price evaluation and search for vehicles with multiple filters.
15
15
  - Search for homes with filters for city, home type and more.
16
16
  - Search for stores and get a specific store's listings.
17
+ - ...and more!
17
18
 
18
19
  ## 🧑‍💻️ Install
19
20
 
@@ -52,6 +53,7 @@ Some calls require a `bearerToken`. However, some calls are public and don't req
52
53
  | [`api.store_search()`](#store_search) | 👏 No | Yes | Search for a store.
53
54
  | [`api.get_store_listings()`](#get_store_listings) | 👏 No | Yes | Get listings from a specific store.
54
55
  | [`api.get_ad_by_id()`](#get_ad_by_id) | 👏 No | Yes | Get ad data from id.
56
+ | [`api.get_user_by_id()`](#get_user_by_id) | 👏 No | Yes | Get user data from id.
55
57
 
56
58
 
57
59
  ## 🤓 Detailed usage
@@ -285,6 +287,29 @@ Get ad data from a specific ad id.
285
287
  }
286
288
  ```
287
289
 
290
+ ### get_user_by_id
291
+ Get user data from a user id. User id can be found in ads, searches and in blocket url `https://www.blocket.se/profil/<user_id>`.
292
+
293
+ - `user_id` (`int`, required) - The blocket user id.
294
+ - `as_objects` (`bool`, optional) - Return results as pydantic models, default is `False`.
295
+
296
+
297
+ ```py
298
+ >>> api.get_user_by_id(1234)
299
+ {
300
+ 'account': {
301
+ 'blocket_account_id': '1234',
302
+ 'created_at': '2020-10-10T15:45:06.407660',
303
+ 'is_verified': True,
304
+ 'name': 'Janne',
305
+ ...
306
+ },
307
+ 'active_ads': {[
308
+ ...
309
+ ]}
310
+ }
311
+ ```
312
+
288
313
  ## 🔐 Blocket API token
289
314
 
290
315
  There are two ways to acquire your token:
@@ -11,6 +11,7 @@ import httpx
11
11
 
12
12
  from blocket_api.models import (
13
13
  AdByIdResults,
14
+ BlocketUser,
14
15
  CustomSearchResults,
15
16
  HomeSearchResults,
16
17
  MotorSearchResults,
@@ -456,20 +457,12 @@ class BlocketAPI:
456
457
 
457
458
  @overload
458
459
  def search_store(
459
- self,
460
- search_query: str,
461
- page: int = 0,
462
- *,
463
- as_objects: Literal[True],
460
+ self, search_query: str, page: int = 0, *, as_objects: Literal[True]
464
461
  ) -> StoreSearchResults: ...
465
462
 
466
463
  @overload
467
464
  def search_store(
468
- self,
469
- search_query: str,
470
- page: int = 0,
471
- *,
472
- as_objects: Literal[False] = False,
465
+ self, search_query: str, page: int = 0, *, as_objects: Literal[False] = False
473
466
  ) -> dict: ...
474
467
 
475
468
  @overload
@@ -505,20 +498,12 @@ class BlocketAPI:
505
498
 
506
499
  @overload
507
500
  def get_store_listings(
508
- self,
509
- store_id: int,
510
- page: int = 0,
511
- *,
512
- as_objects: Literal[True],
501
+ self, store_id: int, page: int = 0, *, as_objects: Literal[True]
513
502
  ) -> StoreListings: ...
514
503
 
515
504
  @overload
516
505
  def get_store_listings(
517
- self,
518
- store_id: int,
519
- page: int = 0,
520
- *,
521
- as_objects: Literal[False] = False,
506
+ self, store_id: int, page: int = 0, *, as_objects: Literal[False] = False
522
507
  ) -> dict: ...
523
508
 
524
509
  @public_token
@@ -542,27 +527,44 @@ class BlocketAPI:
542
527
 
543
528
  @overload
544
529
  def get_ad_by_id(
545
- self,
546
- ad_id: int,
547
- *,
548
- as_objects: Literal[True],
530
+ self, ad_id: int, *, as_objects: Literal[True]
549
531
  ) -> AdByIdResults: ...
550
532
 
551
533
  @overload
552
534
  def get_ad_by_id(
553
- self,
554
- ad_id: int,
555
- *,
556
- as_objects: Literal[False] = False,
535
+ self, ad_id: int, *, as_objects: Literal[False] = False
557
536
  ) -> dict: ...
558
537
 
559
538
  @public_token
560
539
  def get_ad_by_id(
561
- self,
562
- ad_id: int,
563
- *,
564
- as_objects: bool = False,
540
+ self, ad_id: int, *, as_objects: bool = False
565
541
  ) -> dict | AdByIdResults:
542
+ """
543
+ Return an ad with it's content. The ad_id can be found by searching or
544
+ from the blocket ad url.
545
+ """
566
546
  url = f"{BASE_URL}/search_bff/v2/content/{ad_id}"
567
547
  response = _make_request(url=f"{url}", token=self.token).json()
568
548
  return AdByIdResults.model_validate(response) if as_objects else response
549
+
550
+ @overload
551
+ def get_user_by_id(
552
+ self, user_id: int, *, as_objects: Literal[True]
553
+ ) -> BlocketUser: ...
554
+
555
+ @overload
556
+ def get_user_by_id(
557
+ self, user_id: int, *, as_objects: Literal[False] = False
558
+ ) -> dict: ...
559
+
560
+ @public_token
561
+ def get_user_by_id(
562
+ self, user_id: int, *, as_objects: bool = False
563
+ ) -> dict | BlocketUser:
564
+ """
565
+ Returns a user's profile data. Contains account information, ads and more.
566
+ Blocket url is https://www.blocket.se/profil/<user_id>.
567
+ """
568
+ url = f"{BASE_URL}/profile-be/v1/public-profiles/{user_id}"
569
+ response = _make_request(url=f"{url}", token=self.token).json()
570
+ return BlocketUser.model_validate(response) if as_objects else response
@@ -534,3 +534,59 @@ class AdByIdResults(BaseModel):
534
534
  data: AdByIdData
535
535
  inventory: AdByIdInventory
536
536
  placements: list[AdByIdPlacement] | None = None
537
+
538
+
539
+ ### GetUserById ###
540
+
541
+
542
+ class BlocketUserAccount(BaseModel):
543
+ blocket_account_id: str
544
+ created_at: datetime.datetime
545
+ is_verified: bool
546
+ name: str
547
+ on_blocket_since: str
548
+ verified_with: str
549
+
550
+
551
+ class BlocketUserAd(BaseModel):
552
+ ad_id: str
553
+ ad_url: str
554
+ image_url: str
555
+ price: str
556
+ region: str
557
+ subject: str
558
+
559
+
560
+ class BlocketUserActiveAds(BaseModel):
561
+ ads: list[BlocketUserAd]
562
+ label_primary: str
563
+ label_secondary: str
564
+
565
+
566
+ class BlocketUserBadge(BaseModel):
567
+ description: str
568
+ icon: str
569
+ icon_blocket_ui: str
570
+ id: str
571
+ label: str
572
+
573
+
574
+ class BlocketUserCO2Savings(BaseModel):
575
+ date_range: str
576
+ equivalent: str
577
+ text: str
578
+
579
+
580
+ class BlocketUserProfileInfo(BaseModel):
581
+ description: str | None = None
582
+ has_reviews: bool
583
+ name: str
584
+
585
+
586
+ class BlocketUser(BaseModel):
587
+ account: BlocketUserAccount
588
+ active_ads: BlocketUserActiveAds
589
+ badges: list[BlocketUserBadge]
590
+ co2_savings: BlocketUserCO2Savings
591
+ profile_info: BlocketUserProfileInfo
592
+ review_scores: dict | None = None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: blocket_api
3
- Version: 0.3.0
3
+ Version: 0.3.1
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
@@ -31,6 +31,7 @@ BlocketAPI allows users to query saved searches, known as "Bevakningar", on [blo
31
31
  - Get vehicle information, price evaluation and search for vehicles with multiple filters.
32
32
  - Search for homes with filters for city, home type and more.
33
33
  - Search for stores and get a specific store's listings.
34
+ - ...and more!
34
35
 
35
36
  ## 🧑‍💻️ Install
36
37
 
@@ -69,6 +70,7 @@ Some calls require a `bearerToken`. However, some calls are public and don't req
69
70
  | [`api.store_search()`](#store_search) | 👏 No | Yes | Search for a store.
70
71
  | [`api.get_store_listings()`](#get_store_listings) | 👏 No | Yes | Get listings from a specific store.
71
72
  | [`api.get_ad_by_id()`](#get_ad_by_id) | 👏 No | Yes | Get ad data from id.
73
+ | [`api.get_user_by_id()`](#get_user_by_id) | 👏 No | Yes | Get user data from id.
72
74
 
73
75
 
74
76
  ## 🤓 Detailed usage
@@ -302,6 +304,29 @@ Get ad data from a specific ad id.
302
304
  }
303
305
  ```
304
306
 
307
+ ### get_user_by_id
308
+ Get user data from a user id. User id can be found in ads, searches and in blocket url `https://www.blocket.se/profil/<user_id>`.
309
+
310
+ - `user_id` (`int`, required) - The blocket user id.
311
+ - `as_objects` (`bool`, optional) - Return results as pydantic models, default is `False`.
312
+
313
+
314
+ ```py
315
+ >>> api.get_user_by_id(1234)
316
+ {
317
+ 'account': {
318
+ 'blocket_account_id': '1234',
319
+ 'created_at': '2020-10-10T15:45:06.407660',
320
+ 'is_verified': True,
321
+ 'name': 'Janne',
322
+ ...
323
+ },
324
+ 'active_ads': {[
325
+ ...
326
+ ]}
327
+ }
328
+ ```
329
+
305
330
  ## 🔐 Blocket API token
306
331
 
307
332
  There are two ways to acquire your token:
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "blocket_api"
3
- version = "0.3.0"
3
+ version = "0.3.1"
4
4
  description = "A python API wrapper for blocket.se"
5
5
  authors = [{name = "dunderrrrrr", email = "emil.bjorkroth@gmail.com"}]
6
6
  readme = "README.md"
File without changes
File without changes