# PC² Version 9 API

This documentation describes the current draft of the PC2 API, which is subject to change.

See: Description

Packages
Package | Description
--- | ---
edu.csus.ecs.pc2.api | Classes related to pc2 API
edu.csus.ecs.pc2.api.exceptions | Classes related to pc2 API exceptions.
edu.csus.ecs.pc2.api.listener | Classes related to pc2 API listeners.

This documentation describes the current draft of the PC2 API, which is subject to change.

The API package provides the facilities necessary for user-written Client applications to directly access a PC2 Server. The API would typically be used by those wishing to write their own custom Clients; for example, specialized Team, Judge, or Scoreboard modules. Utilizing the facilities of the API package, such user-written modules can gain access to a wide variety of contest data for the contest being run by the targeted PC2 Server.

NOTE: while anyone can write a custom client module to access a PC2 Server, the ability to actually connect such a module to a Server is enforced at the Server side. In order for a Client to login to a Server and access its services, the Client must provide authentication credentials in the form of a login account and password which has been created on the Server by the Contest Administrator. In addition, access provided to such a logged-in client is limited to the privileges granted by the Contest Administrator to that account.

Using the facilities in the API package requires that a PC2 Server already be running, and that the custom Client making use of the API be provided with a pc2v9.ini file just as with any other PC2 client. The API package documentation assumes the reader is already familiar with these concepts; see the separate PC2 Contest Administrator's Guide for additional details.

Writing a custom Client using the PC2 API involves three basic steps:

1. Creating a server connection
2. Logging in to the server via the server connection by providing valid authentication credentials. Successfully logging in to a server provides access to an object of type `IContest`, a representation of the contest being controlled by the server.
3. Invoking the various `IContest` methods to access server operations and obtain contest data.

The following links provide access to examples of how each of these basic steps is performed. Further examples can be found in the documentation for each of the API packages, classes, interfaces, and methods.

### Quick Samples

- Connect and login to a PC2 server
- Print data from all runs in the contest
- Print the name, site, and group of each team in the contest
- Print the names of all the currently defined contest languages
- Print the names of all the currently defined contest problems
- Print the names of all currently defined (allowable) judgements (that is, judgements which a Judge may choose to assign to a given submitted run)