XXXCreate Events
Events¶
Setting up events for your competition require a bit more detail than the basic calendar entry example, however an example of a running event can be seen below.
General Structure¶
"events": [
{
"age_groups": ["ALL"],
"event_id": "003",
"event_code": "100",
"name": "100 metres MEN",
"genders": "M",
"category": "M",
"rounds": "1",
"units": [
{
"status": "finished",
"heat": 1,
"round": 1,
"results_status": "official",
"results": [
{
"place": 1,
"points": 0,
"bib": "1",
"performance": "10.37"
},
]
}
]
}
]
If you are setting up a competition before it happens, YOU DO NOT NEED to drill down and define the units
. If you save an event
structure with a round structure of "8,3,1", then OpenTrack will create the necessary 12 units in our database - 8 heats, 3 semi-finals and 1 final. However, if you do want to upload results, you need to include them.
The structure of the units varies between running, horizontal jumps and throws, and vertical jumps.
A Running Event¶
JSON Structure¶
The structure for a 100 meter run can be found below, this is the kind of event structure you'd expect to see in the JSON.
{
"age_groups": [
"ALL"
],
"event_id": "003",
"event_code": "100",
"name": "100 metres MEN",
"genders": "M",
"category": "M",
"rounds": "2,1",
"units": [
{
"status": "finished",
"heat": 1,
"round": 1,
"results_status": "official",
"results": [
{
"place": 1,
"points": 0,
"bib": "1",
"performance": "10.37"
},
{
"place": 2,
"points": 0,
"bib": "2",
"performance": "10.48"
}
]
},
{
"status": "finished",
"heat": 2,
"round": 1,
"results_status": "official",
"results": [
{
"place": 1,
"points": 0,
"bib": "3",
"performance": "10.26"
}
]
},
{
"status": "finished",
"heat": 1,
"round": 2,
"results_status": "official",
"results": [
{
"place": 1,
"points": 0,
"bib": "1",
"performance": "10.07"
},
{
"place": 2,
"points": 0,
"bib": "3",
"performance": "10.37"
},
{
"place": 3,
"points": 0,
"bib": "2",
"performance": "10.47"
}
]
}
]
}
]
Example¶
Below is a fully implemented code snippet that can be used to create a competition through the API, it is worth noting that the competitor has events_entered removed as that field is generally used for start lists or information no longer needed once the results are out.
It is worth noting this implemented example has the competitors included simple to demonstrate that putting the bib in the results section alone is enough to automatically link a competitor to an event as can be seen when this event is tested and created with the API.
The following example show multiple rounds as there is a distinction between singular round/heat competitions and several, if you have several it should be set up in the form "1,1" or "2,1" etc. whilst with singular rounds you must have rounds as "1" otherwise this causes an error when loading the data.
{
"full_name": "api-test running event",
"short_name": "api-test",
"slug": "api-test-slug-2a",
"name_local": "api-test",
"country_id": "GBR",
"address": "Kingsmeadow, Jack Goodchild Way, Kingston Road, Kingston upon Thames, UK",
"date": "2020-08-10",
"finish_date": "2020-08-15",
"wa_rankings_category_id": "DF",
"age_groups": ["ALL"],
"basic_description": "This is an opentrack api test",
"contact_details": "example@example.com",
"organiser_id": "6b2af700-0481-4f73-b9ae-8221ae619b55",
"website": "https://example.example",
"entry_link": "https://example.example/entry",
"results_link": "https://example.example/results",
"events": [
{
"age_groups": [
"ALL"
],
"event_id": "003",
"event_code": "100",
"name": "100 metres MEN",
"genders": "M",
"category": "M",
"rounds": "2,1",
"units": [
{
"status": "finished",
"heat": 1,
"round": 1,
"results_status": "official",
"results": [
{
"place": 1,
"points": 0,
"bib": "1",
"performance": "10.37"
},
{
"place": 2,
"points": 0,
"bib": "2",
"performance": "10.48"
}
]
},
{
"status": "finished",
"heat": 2,
"round": 1,
"results_status": "official",
"results": [
{
"place": 1,
"points": 0,
"bib": "3",
"performance": "10.26"
}
]
},
{
"status": "finished",
"heat": 1,
"round": 2,
"results_status": "official",
"results": [
{
"place": 1,
"points": 0,
"bib": "1",
"performance": "10.07"
},
{
"place": 2,
"points": 0,
"bib": "3",
"performance": "10.37"
},
{
"place": 3,
"points": 0,
"bib": "2",
"performance": "10.47"
}
]
}
]
}
]
}
Below is a screenshot of the resulting JSON being uploaded, though we've added some competitors so you can get an idea of how it looks with real data.
Method¶
A code example can be found at https://github.com/openath/opentrack-api-examples/blob/main/results_upload/api_create_events_running.py.
The only change to be made to make this example runnable is to replace the EMAIL and PASSWORD string with your OpenTrack email and password that has authorisation to create competitions. The linked example has competitors added, without these results would be hidden temporarily.
Horizontal Event¶
JSON Structure¶
Below is an example of a horizontal jump event (in this case long jump).
It is broken down into overall data at the different hierarchy levels, unit data, results data and trials data. The trials allow us to see all the performances achieved whilst the results show the overall results in the end, along with who achieved which result.
"events": [
{
"age_groups": [
"ALL"
],
"category": "M_ALL",
"event_code": "LJ",
"event_id": "H3",
"genders": "M",
"name": "LJ M",
"rounds": "3",
"units": [
{
"day": 1,
"event_id": "H3",
"event_name": "LJ M",
"heat": 1,
"results": [
{
"bib": "1",
"catpos": 1,
"order": 1,
"performance": "5.74",
"place": 1
},
{
"bib": "2",
"catpos": 2,
"order": 2,
"performance": "5.72",
"place": 2
}
],
"results_status": "official",
"round": 1,
"rounds": 3,
"status": "finished",
"trials": [
{
"bib": "1",
"result": "5.74",
"round": 1
},
{
"bib": "1",
"result": "x",
"round": 2
},
{
"bib": "1",
"result": "5.60",
"round": 3
},
{
"bib": "2",
"result": "5.72",
"round": 1
},
{
"bib": "2",
"result": "5.51",
"round": 2
},
{
"bib": "2",
"result": "x",
"round": 3
}
]
}
]
}
]
Example¶
Here is the JSON structure of an implemented example. This example contains several records, so you can see how multiple people have to be defined along with their results. It is of note once again that we have not yet filled in competitors as the method to do so will be described in the next page of our documentation.
{
"full_name": "api-test events horizontal",
"short_name": "api-test",
"slug": "api-test-slug-2b",
"name_local": "api-test",
"country_id": "GBR",
"address": "Kingsmeadow, Jack Goodchild Way, Kingston Road, Kingston upon Thames, UK",
"date": "2020-08-10",
"finish_date": "2020-08-15",
"wa_rankings_category_id": "DF",
"age_groups": ["ALL"],
"basic_description": "This is an opentrack api test",
"contact_details": "example@example.com",
"organiser_id": "6b2af700-0481-4f73-b9ae-8221ae619b55",
"website": "https://example.example",
"entry_link": "https://example.example/entry",
"results_link": "https://example.example/results",
"events": [
{
"age_groups": [
"ALL"
],
"category": "M_ALL",
"event_code": "LJ",
"event_id": "H3",
"genders": "M",
"name": "LJ M",
"rounds": "3",
"units": [
{
"day": 1,
"event_id": "H3",
"event_name": "LJ M",
"heat": 1,
"results": [
{
"bib": "1",
"catpos": 1,
"order": 1,
"performance": "5.74",
"place": 1
},
{
"bib": "2",
"catpos": 2,
"order": 2,
"performance": "5.72",
"place": 2
}
],
"results_status": "official",
"round": 1,
"rounds": 3,
"status": "finished",
"trials": [
{
"bib": "1",
"result": "5.74",
"round": 1
},
{
"bib": "1",
"result": "x",
"round": 2
},
{
"bib": "1",
"result": "5.60",
"round": 3
},
{
"bib": "2",
"result": "5.72",
"round": 1
},
{
"bib": "2",
"result": "5.51",
"round": 2
},
{
"bib": "2",
"result": "x",
"round": 3
}
]
}
]
}
]
}
As we'll see with other example in the docs, here is the photo of the output event created with the above JSON. The information about the competitors jumps and their best are right here. The example includes competitors to give you a real-data example.
For events like these the rounds default to 6 however this can be changed, if you edit the event and make both the "rounds" and "max field events" equal to three, it should remove any extra columns.
Method¶
A code example can be found at https://github.com/openath/opentrack-api-examples/blob/main/results_upload/api_create_events_horizontal.py.
The only change to be made to make this example runnable is to replace the EMAIL and PASSWORD string with your OpenTrack email and password that has authorisation to create competitions. The linked example has competitors added, without these results would be hidden temporarily.
Throwing Event¶
JSON Structure¶
Below is an example of a throwing event (in this case javelin throw).
It is broken down into overall data at the different hierarchy levels, unit data, results data and trials data. The trials allow us to see all the performances achieved whilst the results show the overall results in the end, along with who achieved which result.
"events": [
{
"age_groups": [
"ALL"
],
"category": "MF_ALL",
"event_code": "JT",
"event_id": "F3",
"genders": "MF",
"name": "Javelin",
"rounds": "1",
"units": [
{
"day": 1,
"event_id": "F3",
"event_name": "Javelin",
"heat": 1,
"results": [
{
"bib": "1",
"catpos": 1,
"order": 1,
"performance": "47.03",
"place": 2
},
{
"bib": "2",
"catpos": 1,
"order": 2,
"performance": "47.04",
"place": 1
},
{
"bib": "3",
"catpos": 2,
"order": 3,
"performance": "46.93",
"place": 3
}
],
"results_status": "official",
"round": 1,
"rounds": 6,
"status": "finished",
"trials": [
{
"bib": "1",
"result": "47.03",
"round": 1
},
{
"bib": "1",
"result": "46.32",
"round": 2
},
{
"bib": "1",
"result": "45.13",
"round": 3
},
{
"bib": "1",
"result": "43.01",
"round": 4
},
{
"bib": "1",
"result": "45.42",
"round": 5
},
{
"bib": "1",
"result": "x",
"round": 6
},
{
"bib": "2",
"result": "41.61",
"round": 1
},
{
"bib": "2",
"result": "47.04",
"round": 2
},
{
"bib": "2",
"result": "x",
"round": 3
},
{
"bib": "2",
"result": "44.07",
"round": 4
},
{
"bib": "2",
"result": "43.08",
"round": 5
},
{
"bib": "2",
"result": "45.93",
"round": 6
},
{
"bib": "3",
"result": "45.53",
"round": 1
},
{
"bib": "3",
"result": "46.08",
"round": 2
},
{
"bib": "3",
"result": "45.17",
"round": 3
},
{
"bib": "3",
"result": "46.63",
"round": 4
},
{
"bib": "3",
"result": "46.93",
"round": 5
},
{
"bib": "3",
"result": "41.04",
"round": 6
}
]
}
]
}
]
Example¶
Here is the JSON structure of an implemented example. This example contains several records, so you can see how multiple people have to be defined along with their results. It is of note once again that we have not yet filled in competitors as the method to do so will be described in the next page of our documentation.
{
"full_name": "api-test events throw",
"short_name": "api-test",
"slug": "api-test-slug-2d",
"name_local": "api-test",
"country_id": "GBR",
"address": "Kingsmeadow, Jack Goodchild Way, Kingston Road, Kingston upon Thames, UK",
"date": "2020-08-10",
"finish_date": "2020-08-15",
"wa_rankings_category_id": "DF",
"age_groups": ["ALL"],
"basic_description": "This is an opentrack api test",
"contact_details": "example@example.com",
"organiser_id": "6b2af700-0481-4f73-b9ae-8221ae619b55",
"website": "https://example.example",
"entry_link": "https://example.example/entry",
"results_link": "https://example.example/results",
"events": [
{
"age_groups": [
"ALL"
],
"category": "MF_ALL",
"event_code": "JT",
"event_id": "F3",
"genders": "MF",
"name": "Javelin",
"rounds": "1",
"units": [
{
"day": 1,
"event_id": "F3",
"event_name": "Javelin",
"heat": 1,
"results": [
{
"bib": "1",
"catpos": 1,
"order": 1,
"performance": "47.03",
"place": 2
},
{
"bib": "2",
"catpos": 1,
"order": 2,
"performance": "47.04",
"place": 1
},
{
"bib": "3",
"catpos": 2,
"order": 3,
"performance": "46.93",
"place": 3
}
],
"results_status": "official",
"round": 1,
"rounds": 6,
"status": "finished",
"trials": [
{
"bib": "1",
"result": "47.03",
"round": 1
},
{
"bib": "1",
"result": "46.32",
"round": 2
},
{
"bib": "1",
"result": "45.13",
"round": 3
},
{
"bib": "1",
"result": "43.01",
"round": 4
},
{
"bib": "1",
"result": "45.42",
"round": 5
},
{
"bib": "1",
"result": "x",
"round": 6
},
{
"bib": "2",
"result": "41.61",
"round": 1
},
{
"bib": "2",
"result": "47.04",
"round": 2
},
{
"bib": "2",
"result": "x",
"round": 3
},
{
"bib": "2",
"result": "44.07",
"round": 4
},
{
"bib": "2",
"result": "43.08",
"round": 5
},
{
"bib": "2",
"result": "45.93",
"round": 6
},
{
"bib": "3",
"result": "45.53",
"round": 1
},
{
"bib": "3",
"result": "46.08",
"round": 2
},
{
"bib": "3",
"result": "45.17",
"round": 3
},
{
"bib": "3",
"result": "46.63",
"round": 4
},
{
"bib": "3",
"result": "46.93",
"round": 5
},
{
"bib": "3",
"result": "41.04",
"round": 6
}
]
}
]
}
]
}
As we'll see with other example in the docs, here is the photo of the output event created with the above JSON. The information about the competitors throws and their best are right here. The example includes competitors to give you a real-data example.
Method¶
A code example can be found at https://github.com/openath/opentrack-api-examples/blob/main/results_upload/api_create_events_throw.py.
The only change to be made to make this example runnable is to replace the EMAIL and PASSWORD string with your OpenTrack email and password that has authorisation to create competitions. The linked example has competitors added, without these results would be hidden temporarily.
Vertical Events¶
JSON Structure¶
Below is an example of the kind of JSON structure we might expect.
It is of note that the fields treated as missing or unknown will be filled in appropriately when an athlete with a matching bib (in this case 302) is created and added to the competitors list.
"events": [
{
"age_groups": ["SEN"],
"category": "SEN",
"event_code": "PV",
"event_id": "F2",
"genders": "MF",
"name": "Pole Vault",
"rounds": "1",
"status": "complete",
"units": [
{
"event_id": "F2",
"event_name": "Pole Vault",
"heat": 1,
"heights": [
"3.10",
"3.25",
"3.40",
"3.55",
"3.70"
],
"results": [
{
"bib": "302",
"performance": "3.55",
"place": 1
}
],
"results_status": "official",
"round": 1,
"status": "finished",
"trials": [
{
"bib": "302",
"height": "3.10",
"result": "o"
},
{
"bib": "302",
"height": "3.25",
"result": "o"
},
{
"bib": "302",
"height": "3.40",
"result": "o"
},
{
"bib": "302",
"height": "3.55",
"result": "x"
},
{
"bib": "302",
"height": "3.55",
"result": "x"
},
{
"bib": "302",
"height": "3.55",
"result": "o"
},
{
"bib": "302",
"height": "3.70",
"result": "x"
},
{
"bib": "302",
"height": "3.70",
"result": "x"
},
{
"bib": "302",
"height": "3.70",
"result": "x"
}
]
}
]
}
]
Example¶
Here is the JSON structure of an implemented example. This example contains several records, so you can see how multiple people have to be defined along with their results. It is of note once again that we have not yet filled in competitors as the method to do so will be described in the next page of our documentation.
Here we can see a vertical event, a pole vault, broken down into different components. Within the units are the heights, results, and trials. The heights are all the heights hit, it should be of note that this needs to be reflected in both the results, and trial heights. These are also the heights that will appear in the heading of the web page. The results list the bib, best performance and place achieved by the athlete. If the bib is correct much of the athlete information should auto-fill. The trials represent each jump attempt and the outcome of that jump for that athlete.
{
"full_name": "api-test events vertical",
"short_name": "api-test",
"slug": "api-test-slug-2c",
"name_local": "api-test",
"country_id": "GBR",
"address": "Kingsmeadow, Jack Goodchild Way, Kingston Road, Kingston upon Thames, UK",
"date": "2020-08-10",
"finish_date": "2020-08-15",
"wa_rankings_category_id": "DF",
"age_groups": ["ALL"],
"basic_description": "This is an opentrack api test",
"contact_details": "example@example.com",
"organiser_id": "6b2af700-0481-4f73-b9ae-8221ae619b55",
"website": "https://example.example",
"entry_link": "https://example.example/entry",
"results_link": "https://example.example/results",
"events": [
{
"age_groups": ["SEN"],
"category": "SEN",
"event_code": "PV",
"event_id": "F2",
"genders": "MF",
"name": "Pole Vault",
"rounds": "1",
"status": "complete",
"units": [
{
"event_id": "F2",
"event_name": "Pole Vault",
"heat": 1,
"heights": [
"3.10",
"3.25",
"3.40",
"3.55",
"3.70"
],
"results": [
{
"bib": "371",
"performance": "3.40",
"place": 2
},
{
"bib": "302",
"performance": "3.55",
"place": 1
}
],
"results_status": "official",
"round": 1,
"status": "finished",
"trials": [
{
"bib": "371",
"height": "3.10",
"result": "o"
},
{
"bib": "302",
"height": "3.10",
"result": "o"
},
{
"bib": "371",
"height": "3.25",
"result": "o"
},
{
"bib": "302",
"height": "3.25",
"result": "o"
},
{
"bib": "371",
"height": "3.40",
"result": "o"
},
{
"bib": "302",
"height": "3.40",
"result": "o"
},
{
"bib": "371",
"height": "3.55",
"result": "x"
},
{
"bib": "302",
"height": "3.55",
"result": "x"
},
{
"bib": "371",
"height": "3.55",
"result": "x"
},
{
"bib": "302",
"height": "3.55",
"result": "x"
},
{
"bib": "371",
"height": "3.55",
"result": "x"
},
{
"bib": "302",
"height": "3.55",
"result": "o"
},
{
"bib": "302",
"height": "3.70",
"result": "x"
},
{
"bib": "302",
"height": "3.70",
"result": "x"
},
{
"bib": "302",
"height": "3.70",
"result": "x"
}
]
}
]
}
]
}
Here is the photo of the output event created with the above JSON. The information about the competitors jumps and their best are right here. The example includes competitors to give you a real-data example.
Method¶
A code example can be found at https://github.com/openath/opentrack-api-examples/blob/main/results_upload/api_create_events_vertical.py.
The only change to be made to make this example runnable is to replace the EMAIL and PASSWORD string with your OpenTrack email and password that has authorisation to create competitions. The linked example has competitors added, without these results would be hidden temporarily.
Relay event¶
Please see the relay page
Combined event¶
Event JSON¶
Below is a highly minimal example of the JSON needed to create the appropriate event, combined with the reference JSON this is all that is needed to set up a highly basic athlon event, however more realistic examples may have fields such as performance by event or points by event, place and team information along with the results, however using the bib will fetch the relevant athlete information so for loading this information may not be necessary.
{
"age_groups": [
"ALL"
],
"category": "M_ALL",
"event_code": "TRI",
"event_id": "M01",
"genders": "M",
"name": "Triathlon",
"results": [
{
"bib": "1"
},
{
"bib": "2"
},
{
"bib": "3"
}
],
"rounds": "1",
"units": []
},
Reference JSON¶
This section is about other events linked to the athlon, all you need to do to link this to the athlon is add a parent field which has the value equal to the event id of the athlon.
"event_id": "003",
"event_code": "100",
"name": "100 metres MEN",
"genders": "M",
"parent": "M01",
"units": [
Example¶
The script containing the JSON can be found at this link.
This is a complete competition, this contains all the above events including the new Combined Event JSON. The full JSON has been left off of this page as it is lengthy however this JSON can be loaded into the API right away.
Here is a screenshot of the full triathlon after all the bibs have lined up with competitors; after other events referencing this event as a "parent", after the other events have results and are completed. The one thing of note is in this case Andy Weir has not actually participated in the Pole Vault, meaning they have no score for this. If Andy had participated in this event and was given a DNS or something similar their total would be set to 0, regardless of previous values, in case you wanted to make this event stricter.
Method¶
A runnable code example can be found at https://github.com/openath/opentrack-api-examples/blob/main/results_upload/api_create_full_competition.py.
The only change to be made to make this example runnable is to replace the EMAIL and PASSWORD string with your OpenTrack email and password that has authorisation to create competitions. The linked example contains everything, including the sections to come on competitors, teams and relays.