Skip to content
This repository has been archived by the owner on Oct 26, 2022. It is now read-only.

jamesrweb/codewars-api-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Codewars API Client

Test coverage Mutation testing badge GitHub license GitHub contributors GitHub issues GitHub pull requests

A library built to interact with the Codewars API and platform.

Installation

Use the package manager composer to install the library using the following command.

composer require jamesrweb/codewars-api-client

Basic Usage

Once the package has been installed, we can create the required clients like.

<?php

declare(strict_types=1);

require __DIR__ . '/vendor/autoload.php';

use CodewarsApiClient\Client;

$client = new Client("your-api-key");

The Client

A Client instance allows us to interact with the codewars API in a consistent manner.

Methods

Get information about the user

To get information regarding the user, you can run:

$client->user(string $username);

Get challenges created by the user

To get a list of challenges the user created, you can run:

$client->authored(string $username);

Get challenges completed by the user

To get a list of challenges the user completed, you can run:

$client->completed(string $username);

Get information about a specific challenge

To get an overview regarding a specific challenge, you can run:

$client->challenge(string $id);

Get information about multiple challenges

To get an overview of multiple challenges at once, you can run:

$client->challenges(array<string> $ids);

Interfaces

There are a number of interfaces exposed for you to use if required. These are namespaced under the CodewarsApiClient\Interfaces namespace.

The ChallengeInterface

This interface is for the methods that access challenge specific data.

The UserInterface

This interface is for the methods that access user specific data.

The ClientInterface

This interface is for the methods that are accessible to use via a Client instance and is contains all methods defined in the ChallengeInterface and UserInterface interfaces.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

This project uses an MIT license. If you wish to view the license, it can be found in the project root.