A library built to interact with the Codewars API and platform.
Use the package manager composer to install the library using the following command.
composer require jamesrweb/codewars-api-client
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");
A Client
instance allows us to interact with the codewars API in a consistent manner.
To get information regarding the user, you can run:
$client->user(string $username);
To get a list of challenges the user created, you can run:
$client->authored(string $username);
To get a list of challenges the user completed, you can run:
$client->completed(string $username);
To get an overview regarding a specific challenge, you can run:
$client->challenge(string $id);
To get an overview of multiple challenges at once, you can run:
$client->challenges(array<string> $ids);
There are a number of interfaces exposed for you to use if required. These are namespaced under the CodewarsApiClient\Interfaces
namespace.
This interface is for the methods that access challenge specific data.
This interface is for the methods that access user specific data.
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.
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.
This project uses an MIT license. If you wish to view the license, it can be found in the project root.