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

scpper.js

v3.0.3

Published

NodeJS API wrapper for ScpperDB API

Downloads

20

Readme

What the fuck is this ?

The SCP Foundation is a fictional organization that is the subject of a web-based collaborative writing project of the same name. The stories generated by the project describe the exploits of the Foundation, supposedly responsible for containing individuals, entities, locations, and objects that violate natural law (referred to as SCPs).

This module has been built to communicate and retrieve information from the Scpper project, which is the centralization of data and page's statistics From all branches of the Foundation.

Documentation

Create an instance of Scpper

You create an instance of Scpper by calling new Scpper() and passing in a configuration object

const api = new Scpper({ site: 'en' })

You must pass a valid abbreviation to "site" otherwise, an exception will be throw. Scpper class also accepts as property limit, which defines how many items the API should return for queries, and baseUrl if you want to use your own Scpper installation.

The Scpper class also accepts as second parameter an Axios configuration object(optional).

Calling the Scpper API

You can now call it like this:

api.getPage('1956234')
api.getUser('966960')

getPage and getUser accept 1 parameter:

id - string - the id of the requested ressource, wikidot user ID or user page ID (required)

api.findPages('scp-002')

findPages accept 2 parameters:

search - the name of the page you are looking for in ScpperDB (required)

options - Object (optional)

  • site - Overwrite site property for this request (optional)
  • limit - Overwrite limit property for this request (optional)
  • random - boolean - indicating whether resulting list of pages should be randomized (optional)
api.findUsers('Anqxyr')

findUsers accept 2 parameters:

search - the name of the user you are looking for in ScpperDB (required)

options - Object (optional)

  • site - Overwrite site property for this request (optional)
  • limit - Overwrite limit property for this request (optional)
api.findTag('+keter')
// or
api.findTag(['-keter', '+euclide'])

tag - string or array - the tag search you want to perform (required)

options - Object (optional)

  • site - Overwrite site property for this request (optional)
  • limit - Overwrite limit property for this request (optional)
  • method - ("and"|"or") - How to combine provided tags for the query (optional)
  • random - boolean - indicating whether resulting list of pages should be randomized (optional)

The list of tags (array) must be prefixed with "+" or "-" "+" indicates that pages containing this tag must be included in the query "-" indicates that pages containing this tag must be excluded from the query Each tag MUST be prefixed by only ONE of those options.

You can also change "site" property, which is the abbreviation of the site whose data you want to use with a valid initial, otherwise, it will throw an error.

api.site = 'fr'

api.site = 'ca'
// Error: ca is not a valid wiki site

Response

The responses are promise-based, so you you'll need to handle things in a .then() function or await if you use ES7.

api
  .findPages('173')
  .then(i => console.log(i))
  .catch(console.log)

// or if you are more ES7

try {
  const result = await api.findPages('173')
  console.log(result.data)
} catch (err) {
  // See constant below
  console.log(err)
}

To see in detail what each method returns, see this page.

The promised is resolved if no error has occurred (see below).

Constant        VALUE               Status Code   Explanation
----------------------------------------------------------------------------------------
NONE             null               200-299       No problems. The promise is resolved.
CLIENT_ERROR     'CLIENT_ERROR'     400-499       Any non-specific 400 series error.
SERVER_ERROR     'SERVER_ERROR'     500-599       Any 500 series error.
TIMEOUT_ERROR    'TIMEOUT_ERROR'    ---           Server didn't respond in time.
CONNECTION_ERROR 'CONNECTION_ERROR' ---           Server not available, bad dns.
NETWORK_ERROR    'NETWORK_ERROR'    ---           Network not available.
CANCEL_ERROR     'CANCEL_ERROR'     ---           Request has been cancelled. Only possible if `cancelToken` is provided in config, see axios `Cancellation`.

A response will always have these 2 properties:

ok      - Boolean - True is the status code is in the 200's; false otherwise.
problem - String  - One of 6 different values (see problem codes)

If the response don't have ok true, the promise will be rejected.

If the request made it to the server and got a response of any kind, response will also have these properties:

data     - Object - this is probably the thing you're after, with the response of the Scpper.
status   - Number - the HTTP response code
headers  - Object - the HTTP response headers
config   - Object - the `axios` config object used to make the request
duration - Number - the number of milliseconds it took to run this request

From api-sauce


List of available sites (API names in quotes) from ScpperDB:

SCP Foundation and all related works were created by SCP creative community and are available under CC BY-SA 3.0 license.

Thanks

Thanks to FiftyNine for the API and for his infinite patience during our exchanges !

Thanks also to all my friends of the french Foundation branch, and for the unconditional love of Boule De Neige <3