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

wykop-nodejs

v1.0.8

Published

Simple Wykop API v2

Downloads

7

Readme

Simple Wykop API v2

Small library for making requests to Wykop API v2.

Content

  1. Install
  2. Requirements
  3. Usage
  4. Documentation
  5. Examples

Install

npm i wykop-nodejs

Requirements

There are few things thaht Wykop API requires to work:

  1. Register new app: https://www.wykop.pl/dla-programistow/nowa-aplikacja/
  2. Connect App to your account: https://www.wykop.pl/dla-programistow/twoje-aplikacje/

App Conection

Now you have:

  • Klucz[appKey]
  • Sekret[appSecret]
  • Połącznie[accountkey]

Usage

Import

const Wykop = require('wykop-nodejs')
const API = new Wykop({
  appSecret: 'your-appsecret',
  appKey: 'your-appkey'
})

Request - returns promise

API.request({
  requestMethod: 'POST' | 'GET',
  urlParams: String[],
  fullData?: Boolean, // Response with full data or compact
  apiParams?: String[],
  postParams?: Object,
  namedParams?: Object
})

Check out expamples below for details.

Documentation

Ok first of all quick explanation.

Lets say we wanna fetch some hot entires. Endpoint url in documntation looks like that:

https://a2.wykop.pl/Entries/Hot/page/int/period/int/

We can omit base api url so we get:

Entries/Hot/page/int/period/int/

All uppercase words are our urlParams so we have to pass them to the request as an Array of strings:

urlParams: ['Entries', 'Hot']

And our namedParams are:

page/int/period/int/

So we pass them as an Object:

namedParams: {
  page: 1,
  period: 6
}

Some methods require apiParams like:

https://a2.wykop.pl/Tags/Index/page/int/tag/ - tag is apiParam

We pass them also as an Arry of strings:

apiParams: ['rozdajo']

Check out https://www.wykop.pl/dla-programistow/apiv2docs/ for all methods list.

Examples

User Login

const Wykop = require('wykop-nodejs')

const API = new Wykop({
  appSecret: 'your-appsecret',
  appKey: 'your-appkey'
})

/* UserKey will be stored in API.userKey so if you chain next request there is no need to provide it.

Ypu can always handle userKey by your code just grab it from res.data in .then block and when you need it asign it to API.userKey */

API.request({
  requestMethod: 'POST',
  urlParams: ['Login', 'Index'],
  postParams: {
    accountkey: 'your-accountkey'
  }
})
.then(res => console.log(res)) 
.catch(err => console.log(err))

Hot Entries

const Wykop = require('wykop-nodejs')

const API = new Wykop({
  appSecret: 'your-appsecret',
  appKey: 'your-appkey'
})

API.request({
  requestMethod: 'POST',
  urlParams: ['Login', 'Index'],
  postParams: {
    accountkey: 'your-accountkey'
  }
})
.then(() => {
  API.request({
    requestMethod: 'GET',
    urlParams: ['Entries', 'Hot'],
    fullData: true,
    namedParams: {
      page: 1,
      period: 6
    }
  })
  .then(res => console.log(res))
  .catch(err => console.log(err))
})
.catch(err => console.log(err))

Post New Entrie

const Wykop = require('wykop-nodejs')

const API = new Wykop({
  appSecret: 'your-appsecret',
  appKey: 'your-appkey'
})

API.request({
  requestMethod: 'POST',
  urlParams: ['Login', 'Index'],
  postParams: {
    accountkey: 'your-accountkey'
  }
})
.then(() => {
  API.request({
    requestMethod: 'POST',
    urlParams: ['Entries', 'Add'],
    postParams: {
      body: 'Content of your entrie.',
    }
  })
  .then(res => console.log(res))
  .catch(err => console.log(err))
})
.catch(err => console.log(err))

Get Upvoters

const Wykop = require('wykop-nodejs')

const API = new Wykop({
  appSecret: 'your-appsecret',
  appKey: 'your-appkey'
})

API.request({
  requestMethod: 'POST',
  urlParams: ['Login', 'Index'],
  postParams: {
    accountkey: 'your-accountkey'
  }
})
.then(() => {
  API.request({
    requestMethod: 'GET',
    urlParams: ['Entries', 'Upvoters'],
    apiParams: ['43874835']
  })
  .then(res => console.log(res))
  .catch(err => console.log(err))
})
.catch(err => console.log(err))

Async Await

(async function() {
  const Wykop = require('wykop-nodejs')
  try {
    const API = new Wykop({
      appSecret: 'your-appsecret',
      appKey: 'your-appkey'
    })
    await API.request({
      requestMethod: 'POST',
      urlParams: ['Login', 'Index'],
      postParams: {
        accountkey: 'your-accountkey'
      }
    })
    const response = await API.request({
      requestMethod: 'POST',
      urlParams: ['Profiles', 'Observe'],
      apiParams: ['schriker'],
    })
    console.log(response)
  } catch (err) {
    console.log(err)
  }
})()