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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
|
# Fetching data using the REPL
Using the Python REPL can be another way to test and review the information and data available using the Discogs API. This will help show what data is available and how it will presented back to you when using the `python3-discogs-client` library.
Note that the examples in this chapter require an existing [Client object](quickstart.md).
## Artist
Query for an artist using the artist's name:
```python
>>> artist = d.artist(956139)
>>> print(artist)
<Artist "...">
>>> 'name' in artist.data.keys()
True
```
### Special properties
Get a list of `Artist`s representing this artists' aliases:
```python
>>> artist.aliases
[...]
```
Get a list of `Release`s by this artist by page number:
```python
>>> artist.releases.page(1)
[...]
```
## Release
Query for a release using its Discogs ID:
```python
>>> release = d.release(221824)
```
### Special properties
Get the title of this `Release`:
```python
>>> release.title
'...'
```
Get a list of all `Artist`s associated with this `Release`:
```python
>>> release.artists
[<Artist "...">]
```
Get the tracklist for this `Release`:
```python
>>> release.tracklist
[...]
```
Get details of the first track on this `Release`
```python
>>> release.tracklist[0].title
[...]
>>> release.tracklist[0].duration
[...]
```
Find the available properties of a `Track` object in the module docs:
{class}`discogs_client.models.Track`
Get the `MasterRelease` for this `Release`:
```python
>>> release.master
<MasterRelease "...">
```
Get a list of all `Label`s for this `Release`:
```python
>>> release.labels
[...]
```
## MasterRelease
Query for a master release using its Discogs ID:
```python
>>> master_release = d.master(120735)
```
### Special properties
Get the key `Release` for this `MasterRelease`:
```python
>>> master_release.main_release
<Release "...">
```
Get the title of this `MasterRelease`:
```python
>>> master_release.title
'...'
>>> master_release.title == master_release.main_release.title
True
```
Get a list of `Release`s representing other versions of this `MasterRelease` by
page number:
```python
>>> master_release.versions.page(1)
[...]
```
Get the tracklist for this `MasterRelease`:
```python
>>> master_release.tracklist
[...]
```
## Label
Query for a label using the label's ID:
```python
>>> label = d.label(6170)
```
### Special properties
Get a list of `Release`s from this `Label` by page number:
```python
>>> label.releases.page(1)
[...]
```
Get a list of `Label`s representing sublabels associated with this `Label`:
```python
>>> label.sublabels
[...]
```
Get the `Label`'s parent label, if it exists:
```python
>>> label.parent_label
<Label "Warp Records Limited">
```
|