Skip to content

bradtaniguchi/codewars-node-api

Repository files navigation

codewars-node-api

Utility to call the codewars' public api from nodejs.

Not affiliated with codewars.

npm

license

github workflow

github issues

Installation

Using npm:

npm i codewars-node-api

Note: add --save if you are using npm < 5.0.0

Example Usage

node.js

const { CodewarsV1Api } = require('codewars-node-api');

const cwApi = new CodewarsV1Api();

const userId = 'bradtaniguchi';
cwApi.getUser(userId).then((user) => {
  console.log(user.name); // Brad
});

TypeScript

import { CodewarsV1Api } from 'codewars-node-api';

const cwApi = new CodewarsV1Api();

const userId = 'bradtaniguchi';
cwApi.getUser(userId).then((user) => {
  console.log(user.name); // Brad
});

Documentation

All code documentation is available here: https://bradtaniguchi.dev/codewars-node-api/

Tooling Scripts

Below is docs on using the tools scripts directly by using the npm scripts. Useful for testing, or just getting raw data directly outputted directly into stdout. These scripts can be used after cloning this repo locally and testing against the actual api calls your making.

note all npm run commands can be passed the --silent flag to suppress the first 2 lines printed, leaving only the raw JSON data being printed out to stdout. This could be useful if your want to save a given request to a file, or "pipe" it in your shell.

get-user

Returns a single user.

npm run get:user <username | userId>

get-completed-challenges

Returns the list of completed challenges for the given user. Includes pagination.

npm run get:completed-challenges <username | userId> [page = 0]

get-authored-challenges

Returns a list of authored challenges made by the user.

npm run get:authored-challenges <username | userId>

get-code-challenge

Returns a single code challenge.

npm run get:code-challenge <challengeId | challenge-slug>

Contributing

See CONTRIBUTING and review the CODE_OF_CONDUCT.

License

See LICENSE