Created
December 31, 2024 14:18
-
-
Save IMB11/95e344cd7ed7ddf1e1c6bb0bfb906c69 to your computer and use it in GitHub Desktop.
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
const axios = require('axios'); | |
async function getProjects() { | |
const url = "https://api.modrinth.com/v2/search"; | |
let page = 0; | |
const projectsInfo = []; | |
while (true) { | |
const params = { | |
index: "relevance", | |
offset: page * 10, | |
limit: 10 | |
}; | |
try { | |
const response = await axios.get(url, { params }); | |
const data = response.data; | |
if (data.hits.length === 0) { | |
break; | |
} | |
for (const project of data.hits) { | |
const projectName = project.title; | |
const supportedVersions = project.versions; | |
const fabricSupported = project.display_categories.includes("fabric"); | |
const forgeSupported = project.display_categories.includes("forge"); | |
projectsInfo.push({ | |
name: projectName, | |
supportedVersions: supportedVersions, | |
fabricSupported: fabricSupported, | |
forgeSupported: forgeSupported | |
}); | |
} | |
page++; | |
} catch (error) { | |
console.error("Error fetching projects:", error); | |
break; | |
} | |
} | |
return projectsInfo; | |
} | |
(async () => { | |
const projects = await getProjects(); | |
projects.forEach(project => { | |
console.log(`Project Name: ${project.name}`); | |
console.log(`Supported Versions: ${project.supportedVersions.join(', ')}`); | |
console.log(`Supports Fabric: ${project.fabricSupported ? 'Yes' : 'No'}`); | |
console.log(`Supports Forge: ${project.forgeSupported ? 'Yes' : 'No'}`); | |
console.log(); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment