Skip to content

Saved replies does indeed have an API #60

Description

@EDM115

Clear and concise description of the problem

I read in the readme this :

GitHub's own user "saved replies" (at github.com/settings/replies) have no public REST API, so ghfs can't sync them — global templates are managed entirely through ghfs.

And I thought to myself "surely there must be an API somewhere, right ?"
So I saved a random reply and checked on an issue what it does. And bingo, here it is !

Suggested solution

The endpoint is https://github.com/settings/replies?context=issue. So yes, it does require the user to be logged in. You also need to specify the content type as JSON. It's an array, the one with no id is probably something already set by github but the rest is custom made (also there's probably no way to query random IDs but they seem to just be autoincrementing numbers 😬).
Example request :

fetch("https://github.com/settings/replies?context=issue", {
  method: "GET",
  headers: {
    "Accept": "application/json",
    "Content-Type": "application/json",
    "X-Requested-With": "XMLHttpRequest",
  }
})
  .then(response => {
    if (!response.ok) {
      throw new Error(`HTTP error, status ${response.status}`)
    }
    return response.json()
  })
  .then(data => {
    console.log('Saved replies data :', data)
  })
  .catch(error => {
    console.error('Failed to fetch saved replies :', error)
  });

Example response :

[
  {
    "id": null,
    "title": "Duplicate issue",
    "body": "Duplicate of #",
    "default": true
  },
  {
    "id": 290580,
    "title": "test",
    "body": "hello !!!!",
    "default": false
  }
]

Note : if you switch issue with pull as the context query param, it drops the no-id default one

Alternative

No response

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions