Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Codidact Meta!

Codidact Meta is the meta-discussion site for the Codidact community network and the Codidact software. Whether you have bug reports or feature requests, support questions or rule discussions that touch the whole network – this is the site for you.

Post History

75%
+4 −0
Q&A How should a Codidact public API work?

I'd like to host contests that read code directly from answers Here's what I'd like to see in an API to allow me to host coding contests on Code Golf Codidact. Essential This is the only feature...

posted 1y ago by trichoplax‭  ·  edited 1y ago by trichoplax‭

Answer
#2: Post edited by user avatar trichoplax‭ · 2023-08-10T01:06:54Z (over 1 year ago)
Add finer detail
  • # I'd like to host contests that read code directly from answers
  • Here's what I'd like to see in an API to allow me to host coding contests on Code Golf Codidact.
  • ## Essential
  • This is the only feature I would need in order to start hosting contests.
  • ### The answer content for each answer to a specified question
  • This allows extracting the code block that constitutes a contest entrant from an answer programmatically, rather than needing to manually paste code into the contest controller each time there is a new answer or an edit to an existing one. This allows anyone to run a tournament in their browser without needing to download or install anything, and without needing to wait for the contest host to update anything.
  • I can imagine this working in one of two ways:
  • 1. A single API call including the question id, which returns all answers to that post. These could be in the form of a JSON object with answer ids as keys and answer raw text content as values.
  • 1. Two types of API call:
  • - First a call including the question id, which returns a list of all the answer ids under that question.
  • - Then a call including an answer id, which returns the answer raw text content for that answer.
  • This would mean one API call to get the list of answer ids, then one API call for each answer to get its content.
  • ## Nice-to-have optional extras
  • For me, these are not necessary in order for me to start hosting contests, but I would be likely to use them if they existed.
  • ### The comments on a specified answer
  • This allows the contest host to add comments to answers that then affect the behaviour of the contest controller. For example, adding a comment containing the word "disqualified" could cause the contest controller to exclude that answer from tournaments.
  • I can imagine this working in one of two ways:
  • 1. A single API call including the answer id, which returns all comments to that post. These could be in the form of a JSON object with thread ids as keys and thread objects as values, with each thread object having comment ids as keys and comment raw text content as values.
  • 1. Three types of API call:
  • - First a call including the answer id, which returns a list of all the thread ids under that answer.
  • - Then a call including a thread id, which returns the thread title and a list of all the comment ids under that thread[^1].
  • - Then a call including a comment id, which returns the raw text content for that comment.
  • This would mean one API call to get the list of thread ids, then one API call for each thread to get the list of comment ids, then one API call for each comment to get its content.
  • ### The edit history of a specified answer
  • This would allow specifying a date in the contest controller, and running a tournament with the answers as they were at that date. This could be interesting for contests where the answers evolved over time and watching a tournament play out with the latest versions only tells half the story. It would also allow showing a chart of different answers rising and falling over time, rather than just a final leaderboard.
  • I can imagine this working in one of two ways:
  • 1. A single API call including the post id, which returns all versions of that post. These could be in the form of a JSON object with version ids as keys and post raw text content as values.
  • 1. Two types of API call:
  • - First a call including the post id, which returns a list of all the version ids in the edit history.
  • - Then a call including a version id, which returns the raw text content for that version of the post[^2].
  • This would mean one API call to get the list of version ids, then one API call for each version to get its content.
  • [^1]: Would this be better split into two calls - one for the title and one for the comment ids?
  • [^2]: For me, the content for that version is what is required, but for other purposes it might be useful to have the before and after comparison as shown in the user interface. Should this be split into two separate API calls?
  • # I'd like to host contests that read code directly from answers
  • Here's what I'd like to see in an API to allow me to host coding contests on Code Golf Codidact.
  • ## Essential
  • This is the only feature I would need in order to start hosting contests.
  • ### The answer content for each answer to a specified question
  • This allows extracting the code block that constitutes a contest entrant from an answer programmatically, rather than needing to manually paste code into the contest controller each time there is a new answer or an edit to an existing one. This allows anyone to run a tournament in their browser without needing to download or install anything, and without needing to wait for the contest host to update anything.
  • I can imagine this working in one of two ways:
  • 1. A single API call including the question id, which returns all answers to that post. These could be in the form of a JSON object with answer ids as keys and answer objects as values. Each answer object could have keys "user_id", "user_name", and "content", showing the raw text content of the answer.
  • 1. Two types of API call:
  • - First a call including the question id, which returns a list of all the answer ids under that question.
  • - Then a call including an answer id, which returns the answer object for that answer (similarly, with keys "user_id", "user_name", and "content").
  • This would mean one API call to get the list of answer ids, then one API call for each answer to get its content.
  • ## Nice-to-have optional extras
  • For me, these are not necessary in order for me to start hosting contests, but I would be likely to use them if they existed.
  • ### The comments on a specified post
  • This allows the contest host to add comments to answers that then affect the behaviour of the contest controller. For example, adding a comment containing the word "disqualified" could cause the contest controller to exclude that answer from tournaments.
  • I can imagine this working in one of two ways:
  • 1. A single API call including the post id, which returns all comments to that post. These could be in the form of a JSON object with thread ids as keys and thread objects as values, with each thread object having comment ids as keys and comment objects as values. A comment object could have keys "user_id", "user_name", and "content" for the raw text content.
  • 1. Three types of API call:
  • - First a call including the answer id, which returns a list of all the thread ids under that answer.
  • - Then a call including a thread id, which returns the thread title and a list of all the comment ids under that thread[^1].
  • - Then a call including a comment id, which returns the comment object for that comment (similarly, with keys "user_id", "user_name", and "content").
  • This would mean one API call to get the list of thread ids, then one API call for each thread to get the list of comment ids, then one API call for each comment to get its content. This would be more calls to the server, but each would be smaller and also this would allow terminating early if a comment containing "disqualified" is found.
  • ### The edit history of a specified answer
  • This would allow specifying a date in the contest controller, and running a tournament with the answers as they were at that date. This could be interesting for contests where the answers evolved over time and watching a tournament play out with the latest versions only tells half the story. It would also allow showing a chart of different answers rising and falling over time, rather than just a final leaderboard.
  • I can imagine this working in one of two ways:
  • 1. A single API call including the post id, which returns all versions of that post. These could be in the form of a JSON object with version ids as keys and version objects as values. A version object could have keys "user_id", "user_name", and "content" for the post raw text content.
  • 1. Two types of API call:
  • - First a call including the post id, which returns a list of all the version ids in the edit history.
  • - Then a call including a version id, which returns a version object including the raw text content for that version of the post[^2].
  • This would mean one API call to get the list of version ids, then one API call for each version to get its content.
  • [^1]: Would this be better split into two calls - one for the title and one for the comment ids?
  • [^2]: For me, the content for that version is what is required, but for other purposes it might be useful to have the before and after comparison as shown in the user interface. Should this be split into two separate API calls so that people can request just the one they need?
#1: Initial revision by user avatar trichoplax‭ · 2023-08-10T00:32:58Z (over 1 year ago)
# I'd like to host contests that read code directly from answers

Here's what I'd like to see in an API to allow me to host coding contests on Code Golf Codidact.

## Essential

This is the only feature I would need in order to start hosting contests.

### The answer content for each answer to a specified question

This allows extracting the code block that constitutes a contest entrant from an answer programmatically, rather than needing to manually paste code into the contest controller each time there is a new answer or an edit to an existing one. This allows anyone to run a tournament in their browser without needing to download or install anything, and without needing to wait for the contest host to update anything.

I can imagine this working in one of two ways:

1. A single API call including the question id, which returns all answers to that post. These could be in the form of a JSON object with answer ids as keys and answer raw text content as values.
1. Two types of API call:
    - First a call including the question id, which returns a list of all the answer ids under that question.
    - Then a call including an answer id, which returns the answer raw text content for that answer.

    This would mean one API call to get the list of answer ids, then one API call for each answer to get its content.

## Nice-to-have optional extras

For me, these are not necessary in order for me to start hosting contests, but I would be likely to use them if they existed.

### The comments on a specified answer

This allows the contest host to add comments to answers that then affect the behaviour of the contest controller. For example, adding a comment containing the word "disqualified" could cause the contest controller to exclude that answer from tournaments.

I can imagine this working in one of two ways:

1. A single API call including the answer id, which returns all comments to that post. These could be in the form of a JSON object with thread ids as keys and thread objects as values, with each thread object having comment ids as keys and comment raw text content as values.
1. Three types of API call:
    - First a call including the answer id, which returns a list of all the thread ids under that answer.
    - Then a call including a thread id, which returns the thread title and a list of all the comment ids under that thread[^1].
    - Then a call including a comment id, which returns the raw text content for that comment.

    This would mean one API call to get the list of thread ids, then one API call for each thread to get the list of comment ids, then one API call for each comment to get its content.

### The edit history of a specified answer

This would allow specifying a date in the contest controller, and running a tournament with the answers as they were at that date. This could be interesting for contests where the answers evolved over time and watching a tournament play out with the latest versions only tells half the story. It would also allow showing a chart of different answers rising and falling over time, rather than just a final leaderboard.

I can imagine this working in one of two ways:

1. A single API call including the post id, which returns all versions of that post. These could be in the form of a JSON object with version ids as keys and post raw text content as values.
1. Two types of API call:
    - First a call including the post id, which returns a list of all the version ids in the edit history.
    - Then a call including a version id, which returns the raw text content for that version of the post[^2].

    This would mean one API call to get the list of version ids, then one API call for each version to get its content.

[^1]: Would this be better split into two calls - one for the title and one for the comment ids?

[^2]: For me, the content for that version is what is required, but for other purposes it might be useful to have the before and after comparison as shown in the user interface. Should this be split into two separate API calls?