Skip to content

the scryfall API wants to know who is using it #32

@Valur2000

Description

@Valur2000

the scryfall API sometimes stops generic requests and wants some form of identification (not a full key just an identifier)

adding a few lines to the code worked for me:

const HEADER_OPTIONS = {
    "method": "get",
    "headers": {
      // 1. Name of your project / version
      // 2. A way to contact you (highly recommended for "good citizenship")
      "User-Agent": "MyMtgProject/1.0 (Contact: yourname@example.com)",
      
      // Scryfall specifically asks for this header
      "Accept": "application/json"
    },
      // Good for debugging option
    "muteHttpExceptions": true
  };

then change:

response = JSON.parse(UrlFetchApp.fetch(`${scryfall_url}&page=${page}`).getContentText());

into:

response = JSON.parse(UrlFetchApp.fetch(`${scryfall_url}&page=${page}`,HEADER_OPTIONS).getContentText());

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions