he-sdk-nodejs
Version:
node.js SDK for HackerEarth API
92 lines (74 loc) • 3.02 kB
Markdown
Node.js SDK for HackerEarth API.
This SDK helps you to compile your code with the [HackerEarth API v2](https://www.hackerearth.com/docs/api/developers/code/legacy/)
You can implement an online code compiling site in Node.js ( like [Code Table](https://code.hackerearth.com) ) with the help of this SDK.
Refer to the official [HackerEarth API v2 Guide](https://www.hackerearth.com/docs/api/developers/code/legacy/) for the details on using the API effectively.
```bash
npm install he-sdk-nodejs
```
```javascript
var he = require('he-sdk-nodejs');
```
Fetch your client secret from the [HackerEarth API Dashboard](http://www.hackerearth.com/api/register/)
```javascript
var settings = {
'client_secret': 'type your client secret' ,
'async': 0 ,
'lang': 'CSHARP' ,
'time_limit': 5,
'memory_limit': 262144
};
```
Input your source program as a string like this
```javascript
var source = "using System;class MyClass{static void Main(string[] args) {System.Console.WriteLine(\"Hello World!\\n\");}}";
```
or input the program from a source file by mentioning the file path like this
```javascript
var filepath = "E:\\E\\temporary files\\MyClass.cs";
```
```javascript
he.compile(settings , source , function(err , result){
console.log(result);
});
```
```javascript
he.run(settings , source , function(err , result){
console.log(result);
});
```
```javascript
he.compileFile(settings , filepath , function(err,result){
console.log(result);
});
```
```javascript
he.runFile(settings , filepath , function(err,result){
console.log(result);
});
```
This package lets you compile code belonging to various programming languages via the HackerEarth API. However, If you want to implement your own code compiling server , you may take a look at [compilex](https://www.npmjs.com/package/compilex)
Here are few samples built with this SDK. If you have got one , feel free to add it here and send a pull request or contact me.
- [collab-and-code](https://github.com/mithunkumarnallu/collab-and-code) by [@mithunkumarnallu](https://github.com/mithunkumarnallu)
Contributions are more than welcomed !
You can
- Report a Bug
- Write Tests
- Help write the command line package using this SDK
- Write an Example app and spread the word.
The [HackerEarth API v2](https://www.hackerearth.com/docs/api/developers/code/legacy/) is a copyright of HackerEarth Inc. and this is an unofficial SDK that acts as wrapper for accessing the service provided by HackerEarth Inc.
This repository is licensed under the [MIT License](https://github.com/scriptnull/he-sdk-nodejs/blob/master/LICENSE) .