A simple typescript wrapper for Nekoweb's API, This package also serves as a dependency for our build scripts.
To install this library, use one of these commands (depending on your package manager of choice)
$ npm i @indiefellas/nekoweb-api
$ bun i @indiefellas/nekoweb-api
$ pnpm add @indiefellas/nekoweb-api
$ yarn add @indiefellas/nekoweb-apiThen, get an API key on https://nekoweb.org/api, and put it on YOUR_API_KEY_HERE, like this below:
import NekowebAPI from '@indiefellas/nekoweb-api';
// const { default: NekowebAPI } = require("@indiefellas/nekoweb-api");
// ^^ CommonJS support
let nekoweb = new NekowebAPI({
apiKey: 'YOUR_API_KEY_HERE',
});To get your main website info, you can use this:
import NekowebAPI from '@indiefellas/nekoweb-api';
// const { default: NekowebAPI } = require("@indiefellas/nekoweb-api");
// ^^ CommonJS support
let nekoweb = new NekowebAPI({
apiKey: 'YOUR_API_KEY_HERE',
});
let response = await nekoweb.getSiteInfo();
console.log(response)
// Returns a Site object. Example:
// > {
// > main: true,
// > domain: "jbcarreon123.nekoweb.org",
// > title: "jb's site",
// > folder: "/jbcarreon123.nekoweb.org",
// > updates: 848,
// > followers: 120,
// > views: 78336,
// > created_at: 1739759280871,
// > updated_at: 1754100370383
// > }Uploading a file:
import NekowebAPI from '@indiefellas/nekoweb-api';
import fs from 'node:fs'
let nekoweb = new NekowebAPI({
apiKey: 'YOUR_API_KEY_HERE',
});
let file = fs.readFileSync('./README.md')
let response = await nekoweb.upload('/README.md', file);
console.log(response)
// Returns the response of the server. Example:
// > File uploadedYou can interface with the Nekoweb API using this library.
First, we need to initialize the API:
import NekowebAPI from '@indiefellas/nekoweb-api';
let nekoweb = new NekowebAPI({
apiKey: 'YOUR_API_KEY_HERE',
appName: 'Nekoweb API', // (recommended) optional, defaults to NekowebAPI
request: {} // optional, additional request config to pass for all requests
});- Accepts a
domain, but without it, it will request the site info of the main site of the API key specified - Note that if you specify a domain and you don't own it, you will not get the extra information like if it's your main domain, or the folder.
- Returns a
SiteInfoclass
await nekoweb.getSiteInfo(); // returns info of the API key owner
// > {
// > main: true,
// > domain: "jbcarreon123.nekoweb.org",
// > title: "jb's site",
// > folder: "/jbcarreon123.nekoweb.org",
// > updates: 848,
// > followers: 120,
// > views: 78336,
// > created_at: 1739759280871,
// > updated_at: 1754100370383
// > }
await nekoweb.getSiteInfo('thinliquid.dev'); // returns info for domain thinliquid.dev
// > {
// > domain: "thinliquid.dev",
// > title: "thinliquid's [studio]",
// > updates: 1080,
// > followers: 175,
// > views: 148426,
// > created_at: 1720120891411,
// > updated_at: 1720120891411
// > }- Returns a array of
SiteInfo
await nekoweb.getAllSiteInfo(); // returns info of all sites on the specified API key
// > [
// > {
// > main: true,
// > domain: "jbcarreon123.nekoweb.org",
// > title: "jb's site",
// > id: 0,
// > folder: "/jbcarreon123.nekoweb.org",
// > updates: 848,
// > followers: 120,
// > views: 78336,
// > created_at: 1739759280871,
// > updated_at: 1754100370383
// > },
// > {
// > "main": false,
// > "domain": "nekobox.nekoweb.org",
// > "folder": "/nekobox.nekoweb.org",
// > "title": "Redirecting to: https://jbc.lol/utils/nekobox/",
// > "updates": 90,
// > "followers": 8,
// > "views": 1550,
// > "created_at": 1742393898675,
// > "updated_at": 1753927835577
// > }
// > ]- Returns a
Limitsclass
await nekoweb.getFileLimits();
// > {
// > "general": {
// > "limit": 225,
// > "remaining": 225,
// > "reset": -1
// > },
// > "big_uploads": {
// > "limit": 10,
// > "remaining": 10,
// > "reset": -1
// > },
// > "zip": {
// > "limit": 3,
// > "remaining": 3,
// > "reset": -1
// > }
// > }- Accepts a directory path, defaults to / if nothing provided
- Returns a
Folder[]array
await nekoweb.listDir(); // returns contents of /
// > [
// > {
// > "name": "%2Ftest.md",
// > "dir": false
// > },
// > {
// > "name": ".svelte-adapter-nekoweb.html",
// > "dir": false
// > },
// > {
// > "name": "TestingFolder",
// > "dir": true
// > }
// > }
await nekoweb.listDir('/build'); // returns contents of /build- Accepts a
pathof the file/folder, and ifisFolder(defaults to false).
await nekoweb.create('/nekoweb.html'); // Creates a file named nekoweb.html
await nekoweb.create('/hello', true); // Creates a folder named hello
await nekoweb.create('/hello/hi.txt'); // Creates a file named hi.txt inside of the hello folder- Accepts a
pathfor the file's path, and afilebuffer for the actual file itself. - If the file is 100MB or over, it will use BigFile for uploads automatically.
let file = fs.readFileSync('./hi.txt');
await nekoweb.upload('/hello/hi.txt', file);- Accepts the
oldPathof the file/folder you wanna rename/move, andnewPathof the new path you wanna rename/move.
await nekoweb.rename('/hello/hi.txt', '/hello/hai.txt'); // Renames hi.txt to hai.txt
await nekoweb.rename('/hello/hai.txt', '/hai.txt'); // Moves hai.txt to /- Accepts a
pathfor the file you wanna edit andcontentfor the content of that file.
await nekoweb.edit('/hai.txt', 'Haaaiiiiiiiii!!!!!')- Accepts the
pathyou want to delete.
await nekoweb.delete('/hai.txt');- Returns a BigFile object you can use to upload files more than 100MB.
let bigfile = await nekoweb.createBigFile();- Accepts a
fileto append. This will automatically split it to 100MB chunks if needed.
let file = fs.readFileSync('./reallybigfile.zip');
await bigfile.append(file)- Basically
appendbut instead of the wrapper automatically splits it, you do the job of splitting it.
let file = fs.readFileSync('./reallybigfile.zip');
await bigfile.appendChunk(file)- Accepts a
filepathfor the path of the file you just appended.
await bigfile.move('/reallybigfile.zip')- Imports the file you just appended. Only works on ZIP files.
- Accepts a
pathbut defaults to/
await bigfile.import()In errors, the library throws an AxiosError class if it's a network/API issue, and a generic Error class if it's something else (e.g. missing API keys)