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

wadm-js-client

v1.0.2

Published

Client for connecting to the REST APIs via a JS library

Downloads

1

Readme

OhMyPrints / WadM JavaScript Client

Table of Contents

Introduction

This package exposes the API of Werkaandemuur via a JavaScript wrapper. It is pretty basic but should help you get started in combining data for your own use. It might also work for data that's exposed on OhMyPrints (sibling company), but I haven't had a usecase nor tested it.

The package is meant and tested to use (preferably) on a NodeJs environment. It could work well on the client side, but I strongly recommend against it, since you'll be exposing either your own API key to the interwebs and it also implies you are making an API call on every possible request, which conflicts with the fair use policy.

Fair use

The REST API is exposed based by WadM on a fair usage policy. I've added a specific User Agent marker on the headers of every request it makes. With unfair usage, the package may get throttled or blocked.

Please consider caching the result one way or another (it's not that you'd need live connection since uploading is a manual task).

The API only exposes your own data, so don't bother trying to access some other profiles' data.

Requirements

Make sure you have a personal API key. You can register one via your dashboard via the WordPress plugin page, since we piggyback on the methods the WordPress plugin exposes. Store the Artist ID and API Key somewhere safe (secrets 🤫).

Usage

Start a new instance of the client with the following:

const WadmClient = require('./wadm-js-client')

const client = new WadmClient(USER_ID, API_KEY)

For a mock implementation, take peek at example.js

Methods

All methods return a promise (prefer async/await notation):

connectionTest

Checks whether the API is reachable. Returns true or false:

async () => {
    const isConnected = await client.connectionTest()
}

authenticationTest

Checks whether the protected part of the API is reachable (all other endpoints). Use this the verify that the User Id and API Key are valid. Returns true or false:

async () => {
    const isAuthenticated = await client.authenticationTest()
}

getArtworkById

Returns the JSON object of a particular artwork based on the provided Id. Returns an object artwork: {}:

async () => {
    const artwork = await client.getArtworkById(SOME_ID)
}

getPagedArtworks

Returns an object containing artworks and stats. The artworks contain an array of JSON objects of a particular page of artworks based on the provided page number. If page number is not provided, it wil default to return page 1. The stats give you the paging properties which can be used to get a different page. The maximum number of items per page is 33. The client is set to 25. Returns an object { artworks: [{}], stats }:

async () => {
    const artworks = await client.getPagedArtworks(SOME_PAGE_NUMBER)
}

getArtworks

Uses the paged result and maps the pages to a single array. Returns the array of all artworks based for the user. Returns an Array [ { artwork } ]:

async () => {
    const artworks = await client.getArtworks()
}

Contributing

If you want to contribute, feel free to drop me a line or open up an Issue on the repo. Then we can discuss how the change would fit in with the client.

Disclaimer

I am not affiliated with WadM or OhMyPrints. If the API changes, this wrapper will inevitably fail and will need some manual updating. Feel free to contribute to this repo if you like.