edhrec-recs
v0.1.0
Published
A wrapper for making requests to EDHREC's recommendation API
Downloads
4
Maintainers
Readme
edhrec-recs
A TypeScript wrapper for the EDHREC recommendations API.
Installation
npm install edhrec-recs
Or with yarn:
yarn add edhrec-recs
Usage
import { getRecommendations } from 'edhrec-recs';
// Get recommendations for a commander deck
async function example() {
const recommendations = await getRecommendations({
cards: ['Sol Ring', 'Arcane Signet'],
commanders: ['Tinybones, Trinket Thief'],
excludeLands: true,
});
// Print the top 5 recommendations
recommendations.inRecs.slice(0, 5).forEach((card, index) => {
console.log(`${index + 1}. ${card.name} (Score: ${card.score}/100)`);
});
}
example();
API
getRecommendations(options)
Returns a Promise that resolves to card recommendations from EDHREC.
Options
cards
- An array of card names to include in the deckcommanders
- An array of commander card names for the deckexcludeLands
- (Optional) Whether to exclude land cards from recommendations (default: false)offset
- (Optional) Offset for pagination (default: 0)name
- (Optional) Custom name for the deck
Response Structure
The response contains:
commanders
- Array of commander informationdeck
- Object mapping included card names to quantityinRecs
- Array of recommended cards with scoresmore
- Boolean indicating if more recommendations are availableoutRecs
- Cards that were passed in but not included in recommendations
Example:
{
commanders: [
{
name: 'Tinybones, Trinket Thief',
oracle_id: '008eda1f-b913-4f04-8c29-5e87c270149e',
primary_type: 'Creature',
salt: 0.85,
names: ['Tinybones, Trinket Thief']
}
],
deck: { 'Sol Ring': 1, 'Arcane Signet': 1 },
inRecs: [
{
name: 'Dark Ritual',
oracle_id: '53f7c868-b03e-4fc2-8dcf-a75bbfa3272b',
primary_type: 'Instant',
salt: 0.60,
names: ['Dark Ritual'],
score: 100
},
// ... more recommendations
],
more: true,
outRecs: []
}
License
MIT