来源: http://icpc.baylor.edu/community/cmsicterface

Be aware of existence of clics.ecs.baylor.edu for contest control systems

  • Web Service Spec
    • Authentication with Keycloak Token
    • Standings Upload
    • CLICS export
    • Contest export
    • CDP export
    • PC2 export
    • Attachments export
  • MyICPC Web Service
    • Ping
    • Contest details
    • Contest sites
    • Contest teams
    • Contest institutions
    • Contest staff-members
    • Contest staff-member institutions
    • Contest social info
    • Contest questionnaires
    • Team detail
    • Team Past Results
    • Institution detail
    • Institution WF attendance

Web Service Spec

注意

  • 首先,在 “竞赛>导出>网络服务令牌”(contest > exports > Web Services Tokens) 创建一个网络服务接入令牌。选择您想用token实施的功能,(如 导出、上传、MyICPC网络服务)(Export, Standings Upload, MyICPC web services)
  • 在URL中用比赛索引(Contest Key)指定比赛。比赛索引简如 <比赛 abbreviation>-<年份> ,例如:World-Finals-2017Central-Europe-2016CTU-Open-2016mcapgp-2016

使用 Keycloak 令牌认证

To authenticate you need to acquire temporary token from Keycloak, based on your webservice access token. This token is then used with every request as bearer authentication. For every request you need new token, so the following line will be part of every request you make.

  1. curl -d "client_id=cm5-token" -d "username=token:<webservice access token>" -d "password=" -d "grant_type=password" "https://icpc.baylor.edu/auth/realms/cm5/protocol/openid-connect/token"

请求返回是个JSON,内容如下:

  1. {
  2. "access_token": "<token>",
  3. "expires_in": 300,
  4. "refresh_expires_in":1800,
  5. "refresh_token":"<refresh_token>",
  6. "token_type":"bearer",
  7. "not-before-policy":0,
  8. "session_state":"<state>",
  9. "scope":"profile email"
  10. }

将返回($res)中的 access_token 提取出来存入 $token 中,以便后继使用

  1. token=`echo $res | sed 's/.*access_token":"//g' | sed 's/".*//g'`

Standings Upload

You can upload the stanfings through rest API. The supported format for now is .csv, you can download the template from Contest Dashboard -> Conclusion -> Export Template.

  1. curl https://icpc.baylor.edu/cm5-contest-rest/rest/contest/standings/upload/<contest key> -X POST -F "file=@<your standings file>" -H "Content-type:multipart/form-data" -H "Authorization: bearer $token"

CLICS export

Export to zip file, produces .tsv tables with contest, groups, institutions and teams.

  1. curl https://icpc.baylor.edu/cm5-contest-rest/rest/contest/export/CLICS/COMPOSITE/<contest key> -H "Authorization: bearer $token" > export_clics.zip

Export as Json:

  1. curl https://icpc.baylor.edu/cm5-contest-rest/rest/contest/export/CLICS/CONTEST/<contest key> -H "Authorization: bearer $token" > export_clics.json

Contest export

Export contest data to zip file, produces .tab tables with contest, participants, staff, schools, sites and teams

  1. curl https://icpc.baylor.edu/cm5-contest-rest/rest/contest/export/Contest/COMPOSITE/<contest key> -H "Authorization: bearer $token" > export_contest.zip

CDP export

  1. curl https://icpc.baylor.edu/cm5-contest-rest/rest/contest/export/CDP/COMPOSITE/<contest key> -H "Authorization: bearer $token" > export_CDP.zip

PC2 export

  1. curl https://icpc.baylor.edu/cm5-contest-rest/rest/contest/export/PC2/COMPOSITE/<contest key> -H "Authorization: bearer $token" > export_PC2.zip

Attachments export

  1. curl https://icpc.baylor.edu/cm5-contest-rest/rest/contest/export/Attachments/COMPOSITE/<contest key> -H "Authorization: bearer $token" > export_attachments.zip

MyICPC Web Service

Requires valid contest MyICPC token or contest manager credentials

Ping

  • GET : https://icpc.baylor.edu/cm5-contest-rest/rest/contest/myicpc/{param}/ping
  • param - contest key {CTU-Open-2018}
    1. curl https://icpc.baylor.edu/cm5-contest-rest/rest/contest/myicpc/{param}/ping -H "Authorization: bearer $token"
    样例输出:
    1. {
    2. "code": "200",
    3. "message": "OK - contest: 42nd Annual World Finals of the International Collegiate Programming Contest"
    4. }

Contest details

  • GET : https://icpc.baylor.edu/cm5-contest-rest/rest/contest/myicpc/{param}/details
  • param - contest key {CTU-Open-2018}
    1. curl https://icpc.baylor.edu/cm5-contest-rest/rest/contest/myicpc/{param}/details -H "Authorization: bearer $token"
    样例输出:
    1. {
    2. "2409": {
    3. "name": "39th Annual World Finals of the ACM International Collegiate Programming Contest",
    4. "fullName": "39th Annual World Finals of the ACM International Collegiate Programming Contest",
    5. "shortName": "ACM-ICPC World Finals",
    6. "start": "2015-05-16",
    7. "end": "2015-05-21",
    8. "registrationStart": "2015-05-16",
    9. "registrationEnd": "2015-05-22",
    10. "key": "World-Finals-2015",
    11. "timeZone": "UTC",
    12. "hashtag": "#test"
    13. "hosts": "Name of the Host University",
    14. "access" : [ {
    15. "externalPersonId" : 4568,
    16. "username" : "test@test.com"
    17. } ]
    18. }
    19. }

Contest sites

  • GET : https://icpc.baylor.edu/cm5-contest-rest/rest/contest/myicpc/{param}/sites
  • param - contest key {CTU-Open-2018}
    1. curl https://icpc.baylor.edu/cm5-contest-rest/rest/contest/myicpc/{param}/sites -H "Authorization: bearer $token"
    样例输出:
    1. {
    2. "sites": [
    3. {
    4. "id": 9574,
    5. "name": "Latin America",
    6. "location": "Marrakech",
    7. "type": "Normal"
    8. },
    9. {
    10. "id": 9571,
    11. "name": "North America",
    12. "location": "Marrakech",
    13. "type": "Normal"
    14. }
    15. ]
    16. }

Contest teams

  • GET : https://icpc.baylor.edu/cm5-contest-rest/rest/contest/myicpc/{param}/teams
  • param - contest key {CTU-Open-2018}
    1. curl https://icpc.baylor.edu/cm5-contest-rest/rest/contest/myicpc/{param}/teams -H "Authorization: bearer $token"
    样例输出:
    1. {
    2. "teams": [
    3. {
    4. "externalReservationId": 11111,
    5. "name": "while(true);",
    6. "institutionId": 1111,
    7. "institutionUnitAliasId": 1111,
    8. "siteId": 123,
    9. "workstationId" : 85,
    10. "persons": [
    11. {
    12. "personId": 11,
    13. "externalReservationId": 11,
    14. "firstname": "Name",
    15. "lastname": "Name",
    16. "publicURLKey": "Key",
    17. "role": "Contestant",
    18. "badgeRole": "",
    19. "sex": "M",
    20. "contests": []
    21. },
    22. {
    23. "personId": 11,
    24. "externalReservationId": 11,
    25. "firstname": "Name",
    26. "lastname": "Name",
    27. "role": "Contestant",
    28. "badgeRole": "",
    29. "sex": "M",
    30. "contests": []
    31. },
    32. {
    33. "personId": 11,
    34. "externalReservationId": 11,
    35. "firstname": "Name",
    36. "lastname": "Name",
    37. "role": "Coach",
    38. "badgeRole": "",
    39. "sex": "F",
    40. "contests": []
    41. },
    42. {
    43. "personId": 11,
    44. "externalReservationId": 11,
    45. "firstname": "Name",
    46. "lastname": "Name",
    47. "publicURLKey": "Key",
    48. "role": "Contestant",
    49. "badgeRole": "",
    50. "sex": "M",
    51. "contests": []
    52. },
    53. {
    54. "personId": 11,
    55. "externalReservationId": 11,
    56. "firstname": "Name",
    57. "lastname": "Name",
    58. "publicURLKey": "Key",
    59. "role": "Attendee",
    60. "badgeRole": "Next Year Contestant",
    61. "sex": "M",
    62. "contests": []
    63. }
    64. ],
    65. "results": [
    66. {
    67. "externalContestId": 11,
    68. "contestName": "The XX Collegiate Programming Contest",
    69. "teamName": "while(true);",
    70. "institutionName": "Inst",
    71. "rank": 1,
    72. "problemssolved": 1,
    73. "totaltime": 900,
    74. "lastproblemtime": 200
    75. }
    76. ]
    77. }
    78. ]
    79. }

Contest institutions

  • GET : https://icpc.baylor.edu/cm5-contest-rest/rest/contest/myicpc/{param}/institutions
  • param - contest key {CTU-Open-2018}
    1. curl https://icpc.baylor.edu/cm5-contest-rest/rest/contest/myicpc/{param}/institutions -H "Authorization: bearer $token"
    样例输出:
    1. {
    2. "institutions": [
    3. {
    4. "institutionId": 11,
    5. "institutionUnitAliasId": 11,
    6. "name": "My University",
    7. "shortName": "Mu U",
    8. "twittername": "@MyU",
    9. "twitterhash": "#MyU",
    10. "facebookpage": "",
    11. "homepageurl": "http://www.my.u",
    12. "addressline1": "Add",
    13. "addressline2": "Add",
    14. "addressline3": "",
    15. "city": "Prague",
    16. "state": "",
    17. "zip": "12500",
    18. "country": "Czech",
    19. "latitude": 43.87374,
    20. "longitude": 125.34865
    21. }
    22. ]
    23. }

Contest staff-members

  • GET : https://icpc.baylor.edu/cm5-contest-rest/rest/contest/myicpc/{param}/staff-members
  • param - contest key {CTU-Open-2015}
    1. curl https://icpc.baylor.edu/cm5-contest-rest/rest/contest/myicpc/{param}/staff-members -H "Authorization: bearer $token"
    样例输出:
    1. {
    2. "persons": [
    3. {
    4. "personId": 11,
    5. "firstname": "Bob",
    6. "lastname": "Man",
    7. "publicURLKey": "key",
    8. "role": "Staff",
    9. "badgeRole": "North Africa and Middle East Contests - Director",
    10. "institutionUnitAliasId": 11,
    11. "contests": []
    12. },
    13. {
    14. "personId": 22,
    15. "firstname": "Boba",
    16. "lastname": "Mann",
    17. "role": "Staff",
    18. "badgeRole": "Host Student Volunteer / COE",
    19. "institutionUnitAliasId": 11,
    20. "contests": []
    21. }
    22. ]
    23. }

Contest staff-member institutions

此接口尚不支持。如有需要请联系 manager@icpc.global 申请

  • GET : icpc.baylor.edu/ws/myicpc/contest/{param}/staff-institutions
  • param - contest key {CTU-Open-2015}

样例输出:

  1. {
  2. "institutions": [
  3. {
  4. "institutionId": 11,
  5. "institutionUnitAliasId": 11,
  6. "name": "My University",
  7. "shortName": "Mu U",
  8. "twittername": "@MyU",
  9. "twitterhash": "#MyU",
  10. "facebookpage": "",
  11. "homepageurl": "http://www.my.u",
  12. "addressline1": "Add",
  13. "addressline2": "Add",
  14. "addressline3": "",
  15. "city": "Prague",
  16. "state": "",
  17. "zip": "12500",
  18. "country": "Czech",
  19. "latitude": 43.87374,
  20. "longitude": 125.34865
  21. }
  22. ]
  23. }

Contest social info

  • GET : https://icpc.baylor.edu/cm5-contest-rest/rest/contest/myicpc/{param}/social-info
  • param - contest key {CTU-Open-2015}
    1. curl https://icpc.baylor.edu/cm5-contest-rest/rest/contest/myicpc/{param}/social-info -H "Authorization: bearer $token"

样例输出:

  1. [
  2. {
  3. "externalPersonId": "11",
  4. "twitterUsername": null,
  5. "linkedinOauthToken": null,
  6. "linkedinOauthSecret": null
  7. }
  8. ]

Contest questionnaires

此接口尚不支持。如有需要请联系 manager@icpc.global 申请

  • GET : icpc.baylor.edu/ws/myicpc/contest/{param}/questionnaires
  • param - contest key {CTU-Open-2015}

样例输出:

  1. [
  2. {
  3. "externalPersonId": "11",
  4. "questionnaire": [
  5. {
  6. "question": "Question 4",
  7. "answer": "I really have no idea."
  8. },
  9. {
  10. "question": "Question 5",
  11. "answer": "Highest point of my future career would be to learn and contribute alongside the leading experts of some field."
  12. }
  13. ]
  14. }
  15. ]

Team detail

  • GET : https://icpc.baylor.edu/cm5-contest-rest/rest/contest/myicpc/{param}/teams/123456
  • param - contest key {Team-ID}
    1. curl https://icpc.baylor.edu/cm5-contest-rest/rest/contest/myicpc/{param}/teams/123456 -H "Authorization: bearer $token"

样例输出:

  1. [
  2. {
  3. "externalReservationId": 11,
  4. "name": "Name",
  5. "institutionId": 11,
  6. "institutionUnitAliasId": 11,
  7. "siteId": 11,
  8. "workstationId": 11,
  9. "persons": [
  10. {
  11. "personId": 11,
  12. "externalReservationId": 11,
  13. "firstname": "Name",
  14. "lastname": "Name",
  15. "role": "Contestant",
  16. "badgeRole": "",
  17. "sex": "M",
  18. "publicURLKey" : "key"
  19. "contests": [
  20. {
  21. "externalContestId": 11,
  22. "contestName": "Past Contest",
  23. "homepageUrl": " http://) ",
  24. "year": 2014,
  25. "role": "Contestant"
  26. },
  27. {
  28. "externalContestId": 12,
  29. "contestName": "North America Qualifier",
  30. "homepageUrl": " http://) ",
  31. "year": 2013,
  32. "role": "Contestant"
  33. }, ......
  34. ]
  35. }
  36. ]
  37. }
  38. ]

Team Past Results

此接口尚不支持。如有需要请联系 manager@icpc.global 申请

  • GET : icpc.baylor.edu/ws/myicpc/team/{param}/past-results
  • param - contest key {Team-ID}

样例输出:

  1. [
  2. {
  3. "externalContestId": 11,
  4. "contestName": "The Programming Contest",
  5. "teamName": "Name",
  6. "institutionName": "Inst",
  7. "rank": 3,
  8. "problemssolved": 6,
  9. "totaltime": 1307,
  10. "lastproblemtime": 287
  11. }
  12. ]

Institution detail

此接口尚不支持。如有需要请联系 manager@icpc.global 申请

  • GET : icpc.baylor.edu/ws/myicpc/institution/{param}
  • param - contest key {Institution-ID}

样例输出:

  1. [
  2. {
  3. "institutionId": 1,
  4. "institutionUnitAliasId": 11,
  5. "name": "University",
  6. "shortName": "Uni",
  7. "homepageurl": "www",
  8. "state": "",
  9. "country": "US"
  10. }
  11. ]

Institution WF attendance

此接口尚不支持。如有需要请联系 manager@icpc.global 申请

  • GET : icpc.baylor.edu/ws/myicpc/institution/{param}/attend-wf
  • param - contest key {Institution-ID}

样例输出:

  1. [
  2. {
  3. "id": 2409,
  4. "name": "39th Annual World Finals of the ACM International Collegiate Programming Contest"
  5. },
  6. {
  7. "id": 1811,
  8. "name": "38th Annual World Finals of the ACM International Collegiate Programming Contest"
  9. }
  10. ]