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

kilometrikisa

v0.6.0

Published

Provides access to Kilometrikisa.fi information

Downloads

6

Readme

Kilometrikisa

This module will enable you to easily access information on the Kilometrikisa site.

Usage

Setup the cookie jar

Before using the library, you might need to configure a cookie jar for storing the cookies needed for logging in.

import * as Kilometrikisa from 'kilometrikisa';
import axiosCookieJarSupport from '@3846masa/axios-cookiejar-support';
import * as tough from 'tough-cookie';

// Setup cookie jar
const cookieJar = new tough.CookieJar();
Kilometrikisa.setupAxiosCookieJar(axiosCookieJarSupport, cookieJar);

// Use library
Kilometrikisa.login('username', 'password')
  .then(user => ...);

Log in and fetch basic user information

const user = await Kilometrikisa.login('username', 'password');
console.log(user);

Fetch results for user

Kilometrikisa.login(kktestLogin, kktestPw)
  .then(() => Kilometrikisa.getUserResults())
  .then(results => {
    const totalKm = results.reduce((s, v) => s + v.km, 0);
    console.log(totalKm + " km driven");
});
// Example output
[
  ...
  { date: '2017-06-27', km: 10.7 },
  { date: '2017-06-28', km: 28 },
  { date: '2017-06-29', km: 24.6 },
  { date: '2017-06-30', km: 0 },
  { date: '2017-07-01', km: 21.7 },
  { date: '2017-07-02', km: 26.2 },
  { date: '2017-07-03', km: 12.4 },
  ...
]

Fetch top 100 statistics

const n = 2;
const page = await Kilometrikisa.allTeamsTopListPage();
const teams = await Kilometrikisa.getTeamInfoPages(page, n);
console.log(teams);

Fetch detailed information for the team where the user belongs to

Kilometrikisa.login('username', 'password')
  .then(() => Kilometrikisa.getContests())
  .then((contests) => Kilometrikisa.fetchTeamResults(contests[0]))
  .then(teamResults => {
    console.log(teamResults.name);
    console.log(teamResults.results);
});

Update information to the contest log

Note that this API will only work when the contest is active.

Kilometrikisa.login('username', 'password')
  .then(() => Kilometrikisa.updateLog('2021-08-22', 100.5))
  .then(() => console.log('Log updated'));

Get the contests user has participated in

Kilometrikisa.login('username', 'password')
  .then(() => Kilometrikisa.getContests())
  .then((result) => {
    console.log(result[0].teamName + ' ' result[0].contest + ' ' + result[0].time);
    console.log(result[0].link);
});

Get the latest contest information

const contests = await Kilometrikisa.getAllContests();
const latest = contests[0];
console.log(latest.name); //  Talvikilometrikisa 2021
console.log(latest.link); // /contests/talvikilometrikisa-2021/teams/