AlanOC91 / YGOPRODeck

Yu-Gi-Oh! Card Database and Deck Share Site
81 stars 4 forks source link

Random card endpoint response changed from object to array #505

Open Doarakko opened 3 months ago

Doarakko commented 3 months ago

All the tools I developed using this endpoint have resulted in errors. When I checked, the response was an array.

Is this change intentional? It's a breaking change, so please version the api if possible.

https://db.ygoprodeck.com/api/v7/cardinfo.php?num=1&offset=0&sort=random&cachebust

{
  "data": [
    {
      "id": 72860663,
      "name": "Vampire Fascinator",
      "typeline": [
        "Zombie",
        "Link",
        "Effect"
      ],
      "type": "Link Monster",
      "humanReadableCardType": "Link Effect Monster",
      "frameType": "link",
      "desc": "2+ monsters, including a Zombie monster\r\nIf this card is Link Summoned: You can target 1 monster in your opponent's GY; Special Summon it to your field in Defense Position, also you cannot Special Summon monsters for the rest of this turn, except Zombie monsters. You can Tribute 1 \"Vampire\" monster, then target 1 monster your opponent controls; take control of it until the End Phase. You can only use each effect of \"Vampire Fascinator\" once per turn.",
      "race": "Zombie",
      "atk": 2400,
      "def": null,
      "level": null,
      "attribute": "DARK",
      "archetype": "Vampire",
      "linkval": 3,
      "linkmarkers": [
        "Top",
        "Bottom-Left",
        "Bottom-Right"
      ],
      "ygoprodeck_url": "https://ygoprodeck.com/card/vampire-fascinator-12680",
      "card_sets": [
        {
          "set_name": "Battle of Chaos",
          "set_code": "BACH-EN048",
          "set_rarity": "Super Rare",
          "set_rarity_code": "(SR)",
          "set_price": "0"
        }
      ],
      "card_images": [
        {
          "id": 72860663,
          "image_url": "https://images.ygoprodeck.com/images/cards/72860663.jpg",
          "image_url_small": "https://images.ygoprodeck.com/images/cards_small/72860663.jpg",
          "image_url_cropped": "https://images.ygoprodeck.com/images/cards_cropped/72860663.jpg"
        }
      ],
      "card_prices": [
        {
          "cardmarket_price": "0.39",
          "tcgplayer_price": "0.34",
          "ebay_price": "0.99",
          "amazon_price": "49.99",
          "coolstuffinc_price": "0.79"
        }
      ]
    }
  ],
  "meta": {
    "generated": "2024-08-21T14:20:12+00:00",
    "current_rows": 1,
    "total_rows": 13305,
    "rows_remaining": 13304,
    "total_pages": 13305,
    "pages_remaining": 13304,
    "next_page": "https://db.ygoprodeck.com/api/v7/cardinfo.php?num=1&offset=1&sort=random&cachebust=",
    "next_page_offset": 1
  }
}
AlanOC91 commented 3 months ago

Hello,

Apologies for the issues. We've recently made massive structural changes to our database structure which affected all our endpoints. We've implemented complete backwards compatibility on the cardinfo.php endpoint which is why that endpoint continues to work.

The random card endpoint was old, poorly coded, poorly documented and volatile and wasn't included in our backwards compatible changes. It made more sense to us to funnel the request into the much more complete cardinfo.php endpoint to give more accurate and up to date card information in a safe manner.

However, I understand that this change has affected you so I do apologize.

My main recommendation would be to update your code to utilize cardinfo.php which is non-volatile and will be protected going forward as it always has been.

I can potentially look into reimplementing the original randomcard endpoint (although the url may differ) if you can't change over to cardinfo.php.

Our apologies for how this change has affected your usage.

Doarakko commented 3 months ago

Thank you for your quick reply.

I understand the background behind the breaking change and the recommended course of action going forward. I will be changing to using the cardinfo.php endpoint.

Finally, I always enjoy working with your api, thank you!