Skip to content
Browse files

Draft for IS code checker post

  • Loading branch information...
1 parent 0f6874a commit 3daa89d831232a9a821556abe07cd059a0de5d39 @crodjer committed Apr 5, 2012
Showing with 77 additions and 0 deletions.
  1. +77 −0 drafts/2012-04-05-access-interviewstreets-code-checker-over-http.mkd
View
77 drafts/2012-04-05-access-interviewstreets-code-checker-over-http.mkd
@@ -0,0 +1,77 @@
+---
+title: "Access Interviewstreet's Code Checker over HTTP"
+slug: "access-interviewstreets-code-checker-over-http"
+tags: api, interviewstreet
+author: crodjer
+---
+
+It is nowadays customary of companies to expose parts of their infrastructure to
+the public, in the form of an (API) Application Programming Interface. Hackers
+can utilize these to develop innovative apps and products.
+
+I have been working over exposing an API to the internal codecheckers for
+[Interviewstreet][is] for some time. A beta version of this is up now and we are
+accepting registrations on an invite basis.
+
+#The API
+The API is up at [api.interviewstreet.org][api]. It provides a HTTP based format
+agnostic interface. You can use any of these popular formats: json, xml, yaml,
+pickle. JSON is the default. Format can be specified by appending `.<format>` to
+the url. Eg:
+`http://api.interviewstreet.org/v1.0/submission.yaml?key=2&token=snr34je9n52tY32fJh8teLRl3z4h0wbl`
+for talking to the API in yaml format.
+
+##Functionality
+The functionality provided is straight forward. It asks for the programming
+language (supporting over 15 languages), the program to evaluate and the
+testcases to run that code against.
+As results to the evaluation, it will tell you if the code was successfully
+compiled, how it ran against all your test cases and the outputs it generated.
+
+##Reliability
+This API is pretty reliable. It is a [django][django] front end to the system
+that is used internally. It is well maintained and regularly tested. In fact,
+it has already had a successful run with Overnite, a night long programming
+event conducted under [Kshitj][ktj] (IIT Kharagpur technical Fest).
+
+#Developing a client
+If the language you are using supports basic HTTP request, developing a client
+to interact with the API is simple. The documentation explains how to use it
+against curl. Here is a python implementation using urllib2:
+
+```python
+import urllib2
+import json
+import random
+
+url = 'http://api.interviewstreet.org/v1.0/submission.json?token=your-api-token'
+
+# A demo submission
+submission_data = {
+ 'source': 'print 111' #prints 111 in python,
+ 'hash': "your-random-submission-unique-hash",
+ 'testcases': [
+ 'case1\n',
+ 'case2\n'
+ ],
+ 'lang': 5 #This is python
+}
+
+request = urllib2.Request(url)
+request.add_header('Content-type', 'application/json')
+response = urllib2.urlopen(request, json.dumps(submission_data)).read()
+key = json.loads(response)['key']
+
+
+# Getting the result
+
+response = urllib2.urlopen("%s&key=%s" %(url, key))
+result = json.loads(response.read())['result']
+
+## Do whatever with the result
+```
+
+[is]: http://www.interviewstreet.org/
+[api]: http://api.interviewstreet.org/
+[django]: https://www.djangoproject.com/
+[ktj]: http://ktj.in/

0 comments on commit 3daa89d

Please sign in to comment.
Something went wrong with that request. Please try again.