Skip to content

Document an API Endpoint: First time OSS contributors welcome! #1190

Open
@yakkomajuri

Description

@yakkomajuri

Motivation

Our API can definitely use some better documentation, and we'd love to get some help doing it.

First time contributors welcome!

This is a great way to get your first open source contribution (to PostHog or ever!).

If you get a pull request merged for this, we will:

Endpoints needing documentation

Here are some endpoints we could use documentation for:

  • /api/projects
  • /api/action
  • /api/insight
  • /api/organizations 📖 Example Request & Response
  • /api/insight/trend
  • /api/insight/session
  • /api/insight/retention
  • /api/insight/path
  • /api/event/sessions

And some that could use better/more structured docs:

Important

These endpoints refer to the PostHog platform. The easiest way to get started with PostHog and try these is by creating an account at https://app.posthog.com. Inspecting network requests on the PostHog UI is a great way to understand how our API works - and so is looking at the code.

Using our API requires a Personal API Key.

How to write documentation for an endpoint

When you pick an endpoint, you don't need to write documentation for all possible request types. We'd definitely appreciate you doing so, but we'll accept PRs that document a specific request type for an endpoint. It's more important that the documentation is good and well-structured than poorly documenting a lot of stuff.

💡 To write the docs, you should follow the example of our annotations endpoint docs.

Structure

<Endpoint endpoint='/api/annotation' allowedMethods={['get']} />

Description of the endpoint. 

<HiddenSection headingType='h4' title='Query Parameters'>

A table of parameters goes here.

</HiddenSection>

<HiddenSection headingType='h4' title='Example'>

Example request and response go here.

</HiddenSection>

<hr /><br />

The following structure should be used for documenting an endpoint. Refer to this file for more insight.

GET requests should have a 'Query Parameters' section (if applicable), and POST and PATCH requests should have 'Request Body' instead. Both should provide an example request and response.

Questions?

If you have any questions, feel free to reach out on Slack or leave a comment on this issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions