Feature Request An API

Back to General discussions forum

Moriarty     2014-11-12 18:46:25
User avatar

I suggest having a secret API key for each user, (to avoid OAuth) and having an open API where we can obtain the testcase (with maybe a sessionid) from the api by providing the taskid and then submit answers using the api.

Would let you write new kinds of problem with a time sensitive deadlines. :) (like the Binary Search one, without the manual copy-paste)

Rodion (admin)     2014-11-13 03:34:41
User avatar

Hi! thanks for suggestion!

I thought of it some time ago because there is one special advantage of this idea: it will allow to create problems which are to be solved in several steps.

These may be some turn-based games, simulations etc - so user's program fetches initial data, submits its first move, receives updated data, submits next move etc...

Main reason for this functionality still not exist is that I do not know how many people will use it. :)
However now I'll add your idea to our "issues" so I may think of its implementation more thoroughly...
Well, we'll also need code samples for working with this API - but it is not complicated while most people use only Python, C++, Java and C#...

Rodion (admin)     2014-11-19 07:12:54
User avatar

I thought of this idea a bit more and here is how I see it now:

  • we probably need not ability to solve existing problems via some HTTP-based protocol (too few people will use it just out of fancy);
  • rather it would be interesting to create problems which require using of some custom-made HTTP-client;
  • solving such problems should involve several request-response steps (otherwise they will not differ from existing ones);
  • typical example of such problem could be playing some game against server.

Now how, I think, this should work. Imagine the problem is about playing "tic-tac-toe":

  1. The problem will specify some server endpoint (url) to which requests should be sent.
  2. Instead of "input data" on the problem page you get some mysterious token.
  3. You send the token to given endpoint, and server returns you initial state of the board (either with its first move, or empty).
  4. You decide what move to make and send it to server again (also along with the same token).
  5. Server makes its move and responds to you with updated state of the board or something like this.
  6. So the game is continued until either of players win or some error occurs.
  7. If after your move server determines that you win, it returns (for example) the word win and another victory token.
  8. You submit this victory token as the "answer" to the problem.
  9. If you fail or make error move the server will tell you fail and probably some error message.
  10. Your moves should be limited in time, say 5 seconds for each new request, otherwise server also will tell you that you lose the game.

What do you think - will it be interesting?

Please login and solve 5 problems to be able to post at forum