Skip to content

Towards a draft Codidact API

trichoplax edited this page Jan 2, 2026 · 3 revisions

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


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

  • Given a question id, return all of the answers to that question (including their ids).
  • Given a post id, return all of the threads under that post.
  • Given a thread id, return all of the comments under that thread.

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

Clone this wiki locally