https://github.com/jacobhumston/sxcu.api
Node.js library to interact with the sxcu.net API.
https://github.com/jacobhumston/sxcu.api
javascript library node nodejs npm sxcu
Last synced: 4 months ago
JSON representation
Node.js library to interact with the sxcu.net API.
- Host: GitHub
- URL: https://github.com/jacobhumston/sxcu.api
- Owner: jacobhumston
- License: mit
- Created: 2023-01-14T05:46:33.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2026-02-28T21:09:05.000Z (4 months ago)
- Last Synced: 2026-03-01T00:23:06.976Z (4 months ago)
- Topics: javascript, library, node, nodejs, npm, sxcu
- Language: TypeScript
- Homepage: https://sxcu.api.lovelyjacob.com/
- Size: 3.99 MB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README

# sxcu.api
Node.js library to interact with the sxcu.net API. _([A cli is also included!](https://github.com/jacobhumston/sxcu.api/blob/main/src/cli/README.md))_
sxcu.api was created to allow any developer of any skill set to easily create images, links, etc on sxcu.net without the hassle of learning the sxcu.net documentation directly.
> This module has **0** dependencies. _(excluding dev)_ [Check for yourself!](https://github.com/jacobhumston/sxcu.api/blob/main/package.json)
## Links
**sxcu.api:** [Docs](https://sxcu.api.lovelyjacob.com) / [Github](https://github.com/Lovely-Experiences/sxcu.api) / [npm](https://www.npmjs.com/package/sxcu.api)
**sxcu.net:** [Website](https://sxcu.net/) / [API Docs](https://sxcu.net/api/docs/) / [Discord](https://discord.gg/ZBcYQwMWTG) / [Donate](https://paypal.me/MisterFix)
### Updating to v2.0.0 from v1.x.x
The guide for doing so can be found [here](https://sxcu.api.lovelyjacob.com/guides/updating-to-v2.html).
## Installation
You can install sxcu.api using npm.
```bash
npm install sxcu.api
```
If you would like to install the latest developer build, you can install from the `dev-build` branch.
```bash
npm install "https://github.com/jacobhumston/sxcu.api.git#dev-build"
```
## Documentation
The documentation includes api information and guides/tutorials.
- Latest version: [sxcu.api.lovelyjacob.com](https://sxcu.api.lovelyjacob.com)
- Development version: [sxcu.api.lovelyjacob.com/dev](https://sxcu.api.lovelyjacob.com/dev/)
## Example Usage
Here is an example of uploading a file.
```js
// Import the package.
import * as sxcu from 'sxcu.api';
// Set the request user agent to the default.
// This will be done for you on the first request if you don't do it yourself.
sxcu.UserAgent.useDefault();
// Upload the file and log the response.
sxcu.uploadFile('image.png')
.then((response) => console.log(response))
.catch((err) => console.log(err));
```
In `v2.0.0` we made the switch to ESM and TypeScript. **However, we still support CommonJS.**
```js
// Use CommonJS's require method.
const { uploadFile, UserAgent, categorizeImports } = require('sxcu.api');
UserAgent.useDefault();
uploadFile('your-img')
.then((response) => console.log(response))
.catch((err) => console.log(err));
```
If you preferred categorized imports, then you can use `categorizeImports`. This works with ESM and CommonJS.
```js
// Import the package.
import { categorizeImports } from 'sxcu.api';
// Categorize imports.
const sxcu = categorizeImports();
// Set the request user agent to the default.
sxcu.userAgent.useDefault();
// Upload the file and log the response.
sxcu.files
.uploadFile('image.png')
.then((response) => console.log(response))
.catch((err) => console.log(err));
```
Respecting rate limits has been made extremely easy, all you need to do is enable the request queue.
```js
// Import methods.
import { toggleRequestQueue } from 'sxcu.api';
// Enable the request queue.
toggleRequestQueue(true, true);
```
Need to make a custom request? It's pretty simple as well. The request method allows you to make requests that respect rate limits as well (as long as `toggleRequestQueue` is used beforehand).
```js
// Import methods.
import { request, toggleRequestQueue, resolveError } from 'sxcu.api';
// Enable the request queue.
toggleRequestQueue(true, true);
// Create your own request.
const response = await request({
type: 'GET',
statusErrors: [400, 429],
baseUrl: 'https://sxcu.net/api/',
path: `files/abc123`,
}).catch((error) => {
throw resolveError(error);
});
```
## Contributors