Skip to content

Towards a draft Codidact API

trichoplax edited this page Jul 20, 2026 · 8 revisions

See also the previous Meta discussion How should a Codidact public API work?


Semantic versioning

The API version follows Semantic Versioning 2.0.0.

Each API request uses a URL that begins with api.codidact.com/MAJOR.MINOR.PATCH/. For example, api.codidact.com/0.1.0.

The Codidact API is currently at version 0.1.0.

Bugs and feature requests

You can raise problems or suggest improvements by posting to Codidact Meta.

Answers

Endpoints

Could have a new route that only returns answers to a question:

  • api.codidact.com/question/{id}/answers?community={community}

Should this instead follow the URL route used for browsers, which returns both the question and its answers:

  • api.codidact.com/posts/{id}?community={community}

Maybe the existing URL route could be used, modified by URL parameters:

  • api.codidact.com/posts/{id}?community={community}&posts={top_level|answers|both}

Example usage

All answers to a specified question on Code Golf Codidact:

  • api.codidact.com/question/123456/answers?community=codegolf

The question and its answers:

  • api.codidact.com/posts/123456?community=codegolf

Only the answers:

  • api.codidact.com/posts/123456?community=codegolf&posts=answers

Comments

Endpoints

Following the URL route already used for browsers:

  • api.codidact.com/comments/thread/{id}

Example usage

All comments under a specified thread on Cooking Codidact:

  • api.codidact.com/comments/thread/654321?community=cooking

Use cases to cover

  • Answers: Given a question id, return the ids of all of the answers to that question.
  • Post content: Given a post id, return the content of that post.
  • Threads: Given a post id, return all of the threads under that post.
  • Comments: Given a thread id, return all of the comments under that thread.
  • Votes: Given a post id, return the total upvotes, total downvotes, and score.

Pagination

Should a call that does not mention pagination return the first page of results along with an indication of how many pages there are, so calling code knows whether to request the next page?

Should calling code be able to specify the page size, up to some defined maximum, or should the page size be fixed?


Sorting and filters

Should these follow the same pattern as for viewing a page in a browser, with URL parameters specifying any sorting and filtering to be applied to the results?

Could be useful where the caller does not want all pages, and not being able to sort or filter through the API would result in needing to request all pages in order to sort or filter manually.

Comment threads

It would be useful to be able to request comments under a post based on thread title.

  • api.codidact.com/posts/123456/threads?community=codegolf&thread_title=Feedback

It might be more useful to request comments by thread id (rather than thread title) in case 2 threads are given the same title, and because the title can change over time.

Clone this wiki locally