Saber2pr's Blog


API interface

ging query parameters page and per_page

1. Search for items


Parameters: (1) Q: name of the warehouse to be searched

two。 Read user activity


3. Read the list of user warehouses


4. Read the list of user followers





5. Read user Star list


6. Read a file or folder


Such as:


7. Create a new file

PUT /repos/:userId/:repo/contents/:path

Send body format:

type Commit = {
  message: string
  content: string
  sha?: string

The content field requires base64 transcoding. Commit needs to be serialized by JSON and sent as body.

sha in commit can be omitted. If you update an existing file, the sha field is required. Note: body, not parameter

8. Delete a file

DELETE /repos/:userId/:repo/contents/:path

Body transmission is also required. Format:

type Commit = {
  message: string
  sha: string

The sha field is required.

9. Read file submission


Such as:


submission time can be obtained through

10. Read warehouse language type


the corresponding number of bytes for different languages in the returned value

11. Recursively get directory tree

export const getContentTree = async (
  root = { path: "", type: "dir" }
) => {
  if (root.type === "dir") {
    const children = await request(
    root.children = await Promise.all( => getContentTree(repo, node))
  return root