File: listing.md

package info (click to toggle)
python-discogs-client 2.7.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 568 kB
  • sloc: python: 1,685; sh: 83; makefile: 18
file content (69 lines) | stat: -rw-r--r-- 2,041 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Marketplace listing

As an authenticated user you can add, edit and delete your own marketplace
`Listing`s.

## Add

```python
from discogs_client import Client, Condition, Status, Sort

d = Client('user-agent', user_token='my_user_token')
me = d.identity()

me.inventory.add_listing(
    release=15246519,                       # Also accepts an Release object
    condition=Condition.MINT,               # condition set to 'Mint (M)'
    price=29.99,
    status=Status.DRAFT,                    # status set to 'Draft'
    sleeve_condition=Condition.NEAR_MINT    # sleeve condition set to 'Near Mint (NM or M-)'
)
```

See the module documentation for possible values of condition
{class}`discogs_client.utils.Condition` and status
{class}`discogs_client.utils.Status`.

## Read

You do not have to be authenticated to read a user's public inventory.

```python
user = d.user('username')         # gets a user with username
inventory = user.inventory        # get that user's inventory
first_page = inventory.page(0)    # get the first page
first_listing = first_page[0]     # get the first listing from that page
release = first_listing.release   # get the release from the release
````

## Update

Get the most expensive listing and update its price.

```python
inventory = me.inventory    # Get up to date inventory
inventory.sort(             # Sort by price in descending order
    Sort.By.PRICE,          # == 'price'
    Sort.Order.DESCENDING)  # == 'desc'
listing = inventory[0]      # Get the first item, i.e. most expensive
listing.price = 34.99       # Update its price
listing.save()              # Save changes made to listing
```

See the module documentation for possible values of sort criteria and sort
order {class}`discogs_client.utils.Sort`.

## Delete

Instantiate a `Listing` object as described in the previous example and call

```python
listing.delete()
```

to remove it.

## More information

View the module documentation at {class}`discogs_client.models.Inventory` and
{class}`discogs_client.models.Listing`