Giter VIP home page Giter VIP logo

hackerrank-api's Introduction

HackerRank API

Latest Stable Version Latest Unstable Version License

HackerRank Code Checker API. Extremely simple REST API. Supports more than a dozen languages. All powered by reliable HackerRank servers. You can use your own scoring system or build your own online judge.

40+ programming languages support.

Installation

Themevel is a Laravel package so you can install it via Composer. Run this command in your terminal from your project directory:

composer require shipu/hackerrank-api

Wait for a while, Composer will automatically install Themevel in your project.

Laravel Configuration

When the download is complete, you have to call this package service in config/app.php config file. To do that, add this line in app.php in providers array:

Shipu\HackerRank\HackerRankServiceProvider::class,

To use facade you have to add this line in app.php to the aliases array:

'HackerRank' => Shipu\HackerRank\Facades\HackerRank::class,

Now run this command in your terminal to publish this package resources:

php artisan vendor:publish --provider="Shipu\HackerRank\HackerRankServiceProvider"

after publishing your config file then open config/hackerrank.php and add your hackerrank app key:

return [
    /*
    |--------------------------------------------------------------------------
    | HackerRank API KEY
    |--------------------------------------------------------------------------
    |
    | https://www.hackerrank.com/api/
    |
    */

    'api_key' => env('HACKERRANK_API_KEY', 'YOUR_HACKER_RANK_API_KEY'),
];

also you can add api key in .env :

 HACKERRANK_API_KEY = YOUR_HACKER_RANK_API_KEY

Thats it.

API List

  • languages()
  • submission($lang, $source, $testcases = [ "1" ], $format = 'json', $wait = true, $callback_url = '')

Usages

use Shipu\HackerRank\HackerRank;

$config = [
            "api_key"     => 'hackerrank_app_key',
        ];
        
 
 $hackerRank = new HackerRank($config);
 
 $allLanguages = $hackerRank->checker()->languages();
 
 var_dump($allLanguages->data);

For Laravel Usage

use Shipu\HackerRank\Facades\HackerRank;
//..
//..
$allLanguages = HackerRank::checker()->languages();

dd($allLanguages->data);

Code Submission

use Shipu\HackerRank\Facades\HackerRank;
//..
//..
$response = HackerRank::checker()->submission('php', '<?php echo "It's Working"; ?>');

dd($response->data);

Code Submission with TestCase

use Shipu\HackerRank\Facades\HackerRank;
//..
//..
// Problem is returns the sum of two integers.
// Problem link: https://www.hackerrank.com/challenges/solve-me-first
// Submit code with two tescase example.

$response = HackerRank::checker()->submission('php', '<?php
               function solveMeFirst($a,$b){
                 return $a+$b;
               }
               $handle = fopen ("php://stdin","r");
               $_a = fgets($handle);
               $_b = fgets($handle);
               $sum = solveMeFirst((int)$_a,(int)$_b);
               print ($sum);
               fclose($handle);
           ?>', 
           ["1\n2", "2\n3"]);

// output array respectively as test cases
dd($response->data->result->stdout);

Support on Beerpay

Hey dude! Help me out for a couple of ๐Ÿป!

Beerpay Beerpay

hackerrank-api's People

Contributors

shipu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.