A simple typescript wrapper for Nekoweb's API, This package also serves as a dependency for our build scripts.
$ npm i @indiefellas/nekoweb-api
$ bun i @indiefellas/nekoweb-api
$ pnpm add @indiefellas/nekoweb-api
$ yarn add @indiefellas/nekoweb-api
To get a website info, you can use this:
import NekoAPI from '@indiefellas/nekoweb-api';
// const { default: NekowebAPI } = require("@indiefellas/nekoweb-api");
// ^^ CommonJS support
let neko = new NekoAPI({
apiKey: 'YOUR_API_KEY_HERE',
});
let response = await neko.getSiteInfo('jbcarreon123');
console.log(response)
Uploading a file:
import NekoAPI from '@indiefellas/nekoweb-api';
import fs from 'node:fs'
let neko = new NekoAPI({
apiKey: 'YOUR_API_KEY_HERE',
});
let file = fs.readFileSync('./README.md')
let response = await neko.upload('/README.md', file);
console.log(response)
You can interface with the Nekoweb API using this library.
First, we need to initialize the API:
import NekoAPI from '@indiefellas/nekoweb-api';
let neko = new NekoAPI({
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
username
, but without it, it will request the site info of the owner of the API key specified - Returns a
SiteInfo
class
await neko.getSiteInfo(); // returns info of the API key owner
await neko.getSiteInfo('jbcarreon123'); // returns info for user jbcarreon123
- Returns a
Limits
class
await neko.getFileLimits();
- Accepts a directory path, defaults to / if nothing provided
- Returns a
Folder[]
array
await neko.listDir(); // returns contents of /
await neko.listDir('/dist'); // returns contents of /dist
- Accepts a
path
of the file/folder, and ifisFolder
(defaults to false).
await neko.create('/nekoweb.html'); // Creates a file named nekoweb.html
await neko.create('/hello', true); // Creates a folder named hello
await neko.create('/hello/hi.txt'); // Creates a file named hi.txt inside of the hello folder
- Accepts a
path
for the file's path, and afile
buffer 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 neko.upload('/hello/hi.txt', file);
- Accepts the
oldPath
of the file/folder you wanna rename/move, andnewPath
of the new path you wanna rename/move.
await neko.rename('/hello/hi.txt', '/hello/hai.txt'); // Renames hi.txt to hai.txt
await neko.rename('/hello/hai.txt', '/hai.txt'); // Moves hai.txt to /
- Accepts a
path
for the file you wanna edit andcontent
for the content of that file.
await neko.edit('/hai.txt', 'Haaaiiiiiiiii!!!!!')
- Accepts the
path
you want to delete.
await neko.delete('/hai.txt');
- Returns a BigFile object you can use to upload files more than 100MB.
let bigfile = await neko.createBigFile();
- Accepts a
file
to append. This will automatically split it to 100MB chunks if needed.
let file = fs.readFileSync('./reallybigfile.zip');
await bigfile.append(file)
- Basically
append
but 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
filepath
for the path of the file you just appended.
await bigfile.move('/reallybigfile.zip')
- Imports the file you just appended. Only works on ZIP files.
await bigfile.import()
This library uses Nekoweb's API.