Created
August 11, 2025 13:14
-
-
Save RussellBishop/4ed703591643b72014a431c7da3f69f9 to your computer and use it in GitHub Desktop.
Search Discogs via API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let inputConfig = input.config(); | |
| console.log(`The value of artistName is ${inputConfig.artistName}`); | |
| console.log(`The value of releaseName is ${inputConfig.releaseName}`); | |
| // Replace with your actual artist name, API token, and User-Agent | |
| let artistName = inputConfig.artistName; | |
| let releaseName = inputConfig.releaseName; | |
| // let discogsToken = "YOUR_DISCOGS_TOKEN"; // Securely store and retrieve this via Airtable's secret manager if needed | |
| let userAgent = "MyAirtableApp/1.0"; | |
| // Construct the API URL. Here we're using the search endpoint. | |
| // Construct the Discogs API URL using consumer key and secret for authentication | |
| let url = `https://api.discogs.com/database/search?q=${encodeURIComponent(releaseName)}&type=master&artist=${encodeURIComponent(artistName)}&key=KEY&secret=TOKEN`; | |
| try { | |
| // Make the HTTP request to the Discogs API | |
| let response = await fetch(url, { | |
| headers: { | |
| "User-Agent": userAgent | |
| } | |
| }); | |
| // Check if the request was successful | |
| if (!response.ok) { | |
| throw new Error(`Request failed with status ${response.status}`); | |
| } | |
| // Parse the JSON response | |
| let data = await response.json(); | |
| // Log or process the returned data | |
| console.log("Discogs API response:", data); | |
| // For example, if you wanted to update a record in your Airtable base with some of this data, | |
| // you could add code here to use the Airtable API. | |
| } catch (error) { | |
| console.error("Error fetching data from Discogs:", error); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment