uHunt API real-time statistics service |
Please subscribe to uhunt-api mailing list to receive updates and discuss about the API.
You can call any of the service URL in the next sections directly from a client browser (it allows AJAX requests from any origin). It will return a JSON formatted results. Only the Live Events API uses long polling (i.e., it will wait for a while until new data arrives or it will return empty result if no new data arrives within 1 minute), the rest of the APIs returns immediately.
With uHunt API, you can re-create the entire uHunt website. See the uHunt component.
URL : /api/uname2uid/{uname}.
The {uname} is the username to be converted. The service will return the user ID of that username.
URL : /api/p.
Returns the list of problems at UVa in Javascript array format. Each problem is defined as an array of 21 values:
URL : /api/p/id/{problem-id}.
To view specific problem by {problem-id}.
URL : /api/p/num/{problem-number}.
To view specific problem by {problem-number}.
URL : /api/p/subs/{pids-csv}/{start-sbt}/{end-sbt}.
To view submissions to specific problems on a given submission date range. {pids-csv} is a list of problem ids encoded in comma separated values. {start-sbt} and {end-sbt} are the date range in unix timestamp. Note that the submissions are returned in no particular order. This API is suitable for virtual contests that run for a specific date range on a number of problems.
URL : /api/p/rank/{pid}/{rank}/{count}.
Returns submissions to a problem {pid} ranked from {rank} to {rank} + {count} - 1.
URL : /api/p/ranklist/{pid}/{uid}/{nabove}/{nbelow}.
Returns nearby submissions (by runtime) for a particular user submission to a problem. {pid} is the problem id. {uid} is the UVa user id. {nabove} is the number of (faster) submissions ranked above the user to be shown. {nbelow} is the number of (slower) submissions ranked below the user to be shown.
This service is using long polling. It can hold the request for at most 1 minute for a new event. It will return immediately if there are at least one new event. The server will only keep track the last 100 submissions events. Thus, if the client is not polling after a while, it may lose some events.
URL : /api/poll/{poll-id}.
The {poll-id} is the minimum requested id. For the first call, you can use value 0 (zero) to get the last 100 events. After receiving the events, keep track of the latest "id" of the events returned and use it to call the service again with {poll-id} = the_last_id to get the next, etc.
Returns all of the submissions of a particular user.
DEPRECATED URL : /api/subs/{user-id}.
URL : /api/subs-user/{user-id}.
URL : /api/subs-user/{user-id}/{min-sid}.
The {user-id} is the user id of the user. The {min-sid} is optional (i.e., if specified, it will return submissions with submission id greater than {min-sid}). The service return a JSON formatted object with 3 attributes:
URL : /api/subs-user-last/{user-id}/{count}.
The service return the last {count} submissions from user {user-id} in the same format as subs-user above.
The subs array length is the same as the number of submissions of the user. Each element is one submission with values:
Verdict ID can be one of the following values:
Returns all the submissions of the users on specific problems.
URL : /api/subs-pids/{user-ids-csv}/{pids-csv}/{min-subs-id}.
The {user-ids-csv} is the user ids presented as comma-separated-values. Similarly, the {pids-csv} is the problem ids presented in comma-separated-values. The numbers in the both csvs are limited to 100 numbers. The {min-subs-id} is the minimum submission id to be returned (that is, to show all submissions set this value to zero, to see latest submissions, set it higher as appropriate).
The result is a hash map with the key is the user id and the value is the submissions of that user that associated with one of the specified problem ids. The format of the submissions is identical with the above description.
URL : /api/subs-nums/{user-ids-csv}/{nums-csv}/{min-subs-id}.
This is exactly the same as before, except that the problems is given in problem numbers, not problem ids.
URL : /api/solved-bits/{user-ids-csv}.
Returns an array each contains: { uid:the-user-id, solved:[bit-encoded-solved-pids] }.
The bit-encoded-solved-pids is an array where the ith bit of the jth element (0-based) represents whether the particular user has solved the problem with pid = (j*32)+i.
Returns the user's ranklist and their neighbors.
URL : /api/ranklist/{user-id}/{nabove}/{nbelow}.
The {nabove} is the number of users above the {user-id} that you want to display. Similarly for the {nbelow}. Both {nabove} and {nbelow} is capped to 100. The result is a JSON formatted array where each element is a single user's rank with attributes:
Returns the user ranklist from a certain position.
URL : /api/rank/{pos}/{count}.
Returns the users ranked from {pos} to {pos} + {count} - 1.
URL : /api/cpbook/{edition}.
The {edition} is the book edition (e.g., 1, 2, or 3). The exercises is an array of chapter. Each chapter has a title and arr attribute which contains the sub-chapters. Each sub-chapter also has a title and arr attribute which contains the sub-sub-chapters. Each sub-sub-chapter is formatted as an array where the first element is the title of the sub-sub-chapter and the second element onwards are the problem numbers associated with it. The negative problem number signify that it is a starred problem.
URL : /api/contests.
List down all past UVa contests as an array of:
URL : /api/contests/id/{contest-id}.
List all submissions of a particular contest {contest-id}. It has a "subs" field containing an array of submission, each formatted as:
Contact me : felix.halim at gmail if you want something new.