|
14 | 14 | <img src="https://img.shields.io/github/stars/tcgdex/python-sdk?style=flat-square" alt="Github stars"> |
15 | 15 | </a> |
16 | 16 | <a href="https://github.com/tcgdex/python-sdk/actions/workflows/build.yml"> |
17 | | - <img src="https://img.shields.io/github/actions/workflow/status/tcgdex/python-sdk/build.yml?style=flat-square" alt="the TCGdex Python SDK is released under the MIT license." /> |
| 17 | + <img src="https://img.shields.io/github/actions/workflow/status/tcgdex/python-sdk/build.yml?style=flat-square" alt="Build Status" /> |
18 | 18 | </a> |
19 | 19 | <a href="https://discord.gg/peACSRMZ7V"> |
20 | 20 | <img src="https://img.shields.io/discord/857231041261076491?color=%235865F2&label=Discord&style=flat-square" alt="Discord Link"> |
|
23 | 23 |
|
24 | 24 | # TCGdex Python SDK |
25 | 25 |
|
26 | | -The TCGdex Python SDK provides a convenient access with the Open Source TCGdex API. |
| 26 | +A fast, type-safe Python SDK for the TCGdex API. Query Pokémon Trading Card Game data easily. 🚀 |
27 | 27 |
|
28 | | -_The full API/SDK documentation is available at [API Documentation - TCGdex](https://www.tcgdex.dev)_ |
29 | | - |
30 | | -### Getting Started |
| 28 | +```python |
| 29 | +from tcgdexsdk import TCGdex |
31 | 30 |
|
32 | | -#### How To install |
| 31 | +# Fetch a card in one line |
| 32 | +card = await TCGdex().card.get("swsh3-136") |
| 33 | +card = await TCGdex().card.getSync("swsh3-136") |
| 34 | +print(f"Found: {card.name} ({card.localId}/{card.set.cardCount.total})") |
| 35 | +``` |
33 | 36 |
|
34 | | -run the following command: |
| 37 | +## ⚡️ Quick Install |
35 | 38 |
|
36 | 39 | ```bash |
37 | 40 | pip install tcgdex-sdk |
38 | 41 | ``` |
39 | 42 |
|
40 | | -#### Getting Started |
| 43 | +## 🚀 Features |
41 | 44 |
|
42 | | -**Example: Fetch a Card** |
| 45 | +- **Type-Safe**: Full typing support for better IDE integration |
| 46 | +- **Async/Await**: Built for modern Python applications and compatible with synchronous operations |
| 47 | +- **Zero Config**: Works out of the box |
| 48 | +- **Multi-Language**: Support for English, French, German, Japanese, Chinese, [and more](https://github.com/tcgdex/cards-database/blob/master/interfaces.d.ts#L1-L5) |
| 49 | +- **Rich Data**: Access cards, sets, series, rarities, and more |
| 50 | +- **Lightweight**: Minimal dependencies (only [dacite](https://github.com/konradhalas/dacite)) |
| 51 | + |
| 52 | +## 🎯 Quick Examples |
| 53 | + |
| 54 | +### Find Cards by Various Criteria |
43 | 55 |
|
44 | 56 | ```python |
45 | | -from tcgdexsdk import TCGdex |
| 57 | +sdk = TCGdex("en") |
46 | 58 |
|
47 | | -tcgdex = TCGdex("en") # You can also use `Language.EN` TCGdex(Language.EN) |
48 | | -res = await tcgdex.card.get("swsh1-136") |
| 59 | +# Get the cards made by the illustrator |
| 60 | +cards = await sdk.illustrator.get("5ban Graphics") |
| 61 | +cards = await sdk.illustrator.getSync("5ban Graphics") |
| 62 | + |
| 63 | +# Get the data about the Sword & Shield serie by ID |
| 64 | +series = await sdk.serie.get("swsh") |
| 65 | +series = await sdk.serie.getSync("swsh") |
| 66 | + |
| 67 | +# Get all cards with 110 HP |
| 68 | +hp_cards = await sdk.hp.get("110") |
| 69 | +hp_cards = await sdk.hp.getSync("110") |
| 70 | + |
| 71 | +# List all available rarities |
| 72 | +rarities = await sdk.rarity.list() |
| 73 | +rarities = await sdk.rarity.listSync() |
| 74 | + |
| 75 | +# List all cards with the name being "Furret" |
| 76 | +rarities = await sdk.card.list(Query().equal("name", "Furret")) |
| 77 | +rarities = await sdk.card.listSync(Query().equal("name", "Furret")) |
49 | 78 | ``` |
50 | 79 |
|
51 | | -**Other Examples** |
| 80 | +### Working with Sets and Series |
52 | 81 |
|
53 | 82 | ```python |
54 | | -# fetch a Set using the set's name or ID |
55 | | -await tcgdex.set.get('Darkness Ablaze') |
| 83 | +# Get set details |
| 84 | +darkness_ablaze = await sdk.set.get("Darkness Ablaze") |
| 85 | +# darkness_ablaze = await sdk.set.getSync("Darkness Ablaze") |
| 86 | +print(f"Set: {darkness_ablaze.name} ({darkness_ablaze.cardCount.total} cards)") |
| 87 | + |
| 88 | +# Get series info |
| 89 | +swsh = await sdk.serie.get("swsh") |
| 90 | +# swsh = await sdk.serie.getSync("swsh") |
| 91 | +print(f"Series: {swsh.name} ({len(swsh.sets)} sets)") |
| 92 | +``` |
56 | 93 |
|
57 | | -# Fetch a serie using the serie's name or ID |
58 | | -await tcgdex.serie.get('Sword & Shield') |
| 94 | +## 🛠 Available Endpoints |
59 | 95 |
|
60 | | -# Fetch cards possible pokemon cards HP |
61 | | -await tcgdex.hp.list() |
| 96 | +### Card Data |
| 97 | +```python |
| 98 | +sdk.card # Core card data |
| 99 | +sdk.rarity # Card rarities |
| 100 | +sdk.hp # HP values |
| 101 | +sdk.illustrator # Card illustrators |
| 102 | +``` |
62 | 103 |
|
63 | | -# Fetch Cards with the specific number of HP |
64 | | -await tcgdex.hp.get('110') |
| 104 | +### Game Mechanics |
| 105 | +```python |
| 106 | +sdk.type # Pokémon types |
| 107 | +sdk.energyType # Energy types |
| 108 | +sdk.retreat # Retreat costs |
| 109 | +sdk.stage # Evolution stages |
| 110 | +``` |
65 | 111 |
|
66 | | -# Fetch cards possible illustrators |
67 | | -await tcgdex.illustrator.list() |
| 112 | +### Card Details |
| 113 | +```python |
| 114 | +sdk.variant # Card variants |
| 115 | +sdk.suffix # Card suffixes |
| 116 | +sdk.regulationMark # Regulation marks |
| 117 | +sdk.dexId # Pokédex IDs |
| 118 | +``` |
68 | 119 |
|
69 | | -# Fetch Cards with the specific illustrator |
70 | | -await tcgdex.illustrator.get('tetsuya koizumi') |
| 120 | +### Collections |
| 121 | +```python |
| 122 | +sdk.set # Card sets |
| 123 | +sdk.serie # Card series |
71 | 124 | ``` |
72 | 125 |
|
73 | | -**Other Endpoints** |
| 126 | +## 🌐 Language Support |
| 127 | + |
| 128 | +```python |
| 129 | +from tcgdexsdk import TCGdex, Language |
| 130 | + |
| 131 | +# Using string |
| 132 | +sdk = TCGdex("en") # English |
| 133 | +sdk = TCGdex("fr") # French |
| 134 | + |
| 135 | +# Using enum (type-safe) |
| 136 | +sdk = TCGdex(Language.EN) |
| 137 | +sdk = TCGdex(Language.FR) |
| 138 | + |
| 139 | +# After creating the instance you can change at any time the language |
| 140 | +sdk.setLanguage(Language.FR) |
| 141 | +# or |
| 142 | +sdk.setLanguage("fr") |
| 143 | +``` |
74 | 144 |
|
75 | | -Every endpoints below work just like the ones above |
76 | | -- a function `list` to get the list of elements |
77 | | -- a function `get` to get details on the element |
| 145 | +_[full list of languages available here](https://github.com/tcgdex/cards-database/blob/master/interfaces.d.ts#L1-L5)_ |
78 | 146 |
|
79 | | -- `variant`: fetch by the variants |
80 | | -- `trainerType`: fetch trainer cards types |
81 | | -- `suffix`: fetch differents cards suffixes |
82 | | -- `stage`: fetch differents cards stages |
83 | | -- `regulationMark`: Fetch by the regulation mark (letter at the bottom of the card) |
84 | | -- `energyType`: Fetch different types of energies |
85 | | -- `dexId`: fetch pokemon Global Pokédex IDS |
86 | | -- `type`: fetch the cards using the Pokémon type(s) |
87 | | -- `retreat`: fetch the cards using the retreat count |
88 | | -- `rarity`: fetch the cards rarities |
89 | | -- `illustrator`: fetch all the cards illustrators |
90 | | -- `hp`: fetch the different cards possible HPs |
91 | | -- `category`: the different cards categories |
| 147 | +__ |
92 | 148 |
|
| 149 | +## 🤝 Contributing |
93 | 150 |
|
94 | | -## Contributing |
| 151 | +We love contributions! Here's how: |
95 | 152 |
|
96 | | -See [CONTRIBUTING.md](https://github.com/tcgdex/python-sdk/blob/master/CONTRIBUTING.md) |
| 153 | +1. 🍴 Fork it |
| 154 | +2. 🌿 Create your feature branch (`git checkout -b feature/amazing`) |
| 155 | +3. 🔧 Make your changes |
| 156 | +4. 🚀 Push to the branch (`git push origin feature/amazing`) |
| 157 | +5. 🎉 Open a PR |
97 | 158 |
|
98 | | -TL::DR |
| 159 | +## 📘 Documentation |
99 | 160 |
|
100 | | -- Fork |
| 161 | +- [Full API Documentation](https://www.tcgdex.dev) |
| 162 | +- [Python SDK Guide](https://www.tcgdex.dev/sdks/python) |
101 | 163 |
|
102 | | -- Commit your changes |
| 164 | +## 💬 Community & Support |
103 | 165 |
|
104 | | -- Pull Request on this Repository |
| 166 | +- [Discord Server](https://discord.gg/peACSRMZ7V) - Get help and discuss features |
| 167 | +- [GitHub Issues](https://github.com/tcgdex/python-sdk/issues) - Bug reports and feature requests |
105 | 168 |
|
106 | | -## License |
| 169 | +## 📜 License |
107 | 170 |
|
108 | | -This project is licensed under the MIT License. A copy of the license is available at [LICENSE.md](https://github.com/tcgdex/python-sdk/blob/master/LICENSE.md) |
| 171 | +MIT © [TCGdex](https://github.com/tcgdex) |
0 commit comments