curseforge-studios-api
v1.0.0
Published
- [Description](#description) - [Usage](#usage) - [Requirements](#requirements) - [License](#license)
Downloads
2
Readme
CurseForge for Studios API
Contents
Description
Easy to use JavaScript package for fetching data from the CurseForge for Studios API.
Usage
Install the curseforge-studios-api package with NPM:
npm install curseforge-studios-api
You can then use the API by importing the package, creating a client and calling a function:
import { createCurseForgeClient } from "curseforge-studios-api";
const { mods } = createCurseForgeClient(fetch, "YOUR-API-KEY");
mods.search(432).then(response => {
console.log(response);
}).catch(error => {
console.log(error);
})
Custom Fetch
In some frameworks, you have a custom fetch function for fetching data. If that function is available, you can pass it in the client. For example, if you have a SvelteKit load function:
import { createCurseForgeClient } from "curseforge-studios-api";
import type { PageServerLoad } from "./$types";
import { API_KEY } from "$env/static/private";
import { error } from "@sveltejs/kit";
export const load: PageServerLoad = async ({ fetch }) => {
const { mods } = createCurseForgeClient(fetch, API_KEY);
try {
return {
mods: mods.search(423)
}
} catch {
error(400, { message: "Something went wrong" });
}
}
Requirements
The curseforge-studios-api uses @sveltejs/kit for easier types with Numeric Ranges.
License
The curseforge-studios-api script is released under the MIT license.