npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sxcu.api

v2.0.6

Published

Node.js library to interact with the sxcu.net API.

Downloads

40

Readme

sxcu.api

Node.js library to interact with the sxcu.net API. (A cli is also included!)

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!

Links

sxcu.api: Docs / Github / npm

sxcu.net: Website / API Docs / Discord / Donate

Updating to v2.0.0 from v1.x.x

The guide for doing so can be found here.

Installation

You can install sxcu.api using npm.

npm install sxcu.api

If you would like to install the latest developer build, you can install from the dev-build branch.

npm install "https://github.com/jacobhumston/sxcu.api.git#dev-build"

Documentation

The documentation includes api information and guides/tutorials.

Example Usage

Here is an example of uploading a file.

// 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.

// 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.

// 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.

// 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).

// 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