Coder Social home page Coder Social logo

api's Introduction

What is this?

BitRun API is a project that provides ability to execute code snippets written in various languages (Ruby, Pythong, Node, PHP, Go, ...). Under the hood it used Docker to run the code and provides process and filesystem isolation. API service is written in Go and could be easily installed on the server and only requires Docker to run.

API

To execute the code you must provide filename and content.

POST https://bit.run/api/v1/run

Parameters:

  • filename - Name of the file to run. This is needed to determine the language. Required.
  • content - Code to execute. Required.

Example:

curl \
  -i \
  -X POST "https://bit.run/api/v1/run" \
  -d "filename=test.rb&content=puts 'Hello World'"

Output:

HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 13
X-Run-Command: ruby test.rb
X-Run-Duration: 261.752379ms
X-Run-Exitcode: 0

Hello World

If request is successful, API will respond with plaintext of the executed command. Extra meta data will be included in the headers:

  • X-Run-Command - full command that was executed
  • X-Run-Duration - how long it took to process the request (not to run the code)
  • X-Run-Exitcode - exit code of executed command

Each run is limited by 10 seconds. If your code runs longer than 10s API will respond with 400 and provide error message:

{
  "error": "Operation timed out after 10s"
}

Command override

By default, bitrun will execute code snippet with a default command. For example, ruby snippet will use the following command: "ruby main.rb". To override the command, you can specify command parameter when making an API call:

curl \
  -i \
  -X POST "https://bit.run/api/v1/run" \
  -d "filename=test.rb&content=puts 'Hello World'&command=ruby -v"

Response:

HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 59
X-Run-Command: ruby test.rb
X-Run-Duration: 126.436286ms
X-Run-Exitcode: 0

ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]

Supported languages

To check which languages are currently supported, make a call:

GET https://bit.run/api/v1/config

Response will include supported languages along with commands used to run scripts:

{
  ".rb": {
    "image": "ruby:2.2",
    "command": "ruby %s",
    "format": "text/plain"
  },
  ".py": {
    "image": "python:2.7",
    "command": "python %s",
    "format": "text/plain"
  },
  ".php": {
    "image": "php:5.6",
    "command": "php %s",
    "format": "text/plain"
  }
}

License

MIT

api's People

Contributors

lanastasov avatar sosedoff avatar

Watchers

 avatar  avatar  avatar

Forkers

aleee1333

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.