API route feature request/suggestion: `GET /v2/projects/{project_id}/branches/{branch_id}/endpoints`

Use case: obtaining an endpoint hostname programatically when I have the branch_id. Specifically in my case for applying migrations to a parent branch once I have created + successfully applied them to a child branch.

I observe this information is returned in the response on branch creation (POST /v2/projects/{project_id}/branches.endpoints[] - but to retrieve later I only see the route for listing all endpoints across all branches in a project (/v2/projects/{project_id}/endpoints).

This is of course a workable solution, just less nice to use - I’d have to filter the response by branch_id - starts to get more complex under a shell environment such as GitHub Actions for someone like myself who doesn’t do much shell scripting. (Plus vague FUD around potential future requirement for pagination of this response if the number of branches in a project grows particularly large.)

For my use case (CI, with env vars referring to credentials / project_id / parent_branch_id) I will instead create an additional environment variable populated with the parent branch endpoint hostname. However strictly speaking this additional env var duplicates the one with branch_id - it would be nice to be able to automate this without having to perform the filtering mentioned above.

1 Like

This sounds totally reasonable to me, so I’ve just opened a PR implementing this endpoint with a following swagger spec:

  /projects/{project_id}/branches/{branch_id}/endpoints:
    parameters:
      - name: project_id
        in: path
        required: true
        schema:
          type: string
      - name: branch_id
        in: path
        required: true
        schema:
          type: string

    get:
      summary: Get list of branch endpoints
      tags:
        - Branch
      operationId: listProjectBranchEndpoints
      responses:
        200:
          description: Successfully returned a list of endpoints for the specified branch
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/EndpointsResponse"
        default:
          $ref: "#/components/responses/GeneralError"

If there will be no objections, I really hope to see it in production soon.

1 Like

The new API endpoint is on prod, you can give it a try: https://neon.tech/api-reference/v2/#/Branch/listProjectBranchEndpoints

2 Likes

Works great, big thanks! I now have fewer env vars to configure for CI which is good.

1 Like