0.1.0 • Published 5 months ago

edhrec-recs v0.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months ago

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 deck
  • commanders - An array of commander card names for the deck
  • excludeLands - (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 information
  • deck - Object mapping included card names to quantity
  • inRecs - Array of recommended cards with scores
  • more - Boolean indicating if more recommendations are available
  • outRecs - 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