Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wadm-js-client

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wadm-js-client

Client for connecting to the REST APIs via a JS library

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

OhMyPrints / WadM JavaScript Client

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.

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-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(id)

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(page)

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.

Keywords

FAQs

Package last updated on 22 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc