https://api.github.com
ging query parameters page and per_page
1. Search for items
/search/repositories
Parameters: (1) Q: name of the warehouse to be searched
/users/:userId/events
/users/:userId/repos
Follower
/users/:userId/followers
Follow
/users/:userId/following
/users/:userId/starred
/repos/:userId/:repo/contents/:path
Such as:
GET https://api.github.com/repos/saber2pr/saber2pr.github.io/contents/blog
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.
/repos/:userId/:repo/commits?path=:path
Such as:
GET https://api.github.com/repos/saber2pr/saber2pr.github.io/commits?path=/blog
submission time can be obtained through commit.committer.date
10. Read warehouse language type
/repos/:userId/:repo/languages
the corresponding number of bytes for different languages in the returned value
11. Recursively get directory tree
export const getContentTree = async (
repo,
root = { path: "", type: "dir" }
) => {
if (root.type === "dir") {
const children = await request(
`https://api.github.com/repos/${username}/${repo}/contents/${root.path}`
)
root.children = await Promise.all(
children.map(node => getContentTree(repo, node))
)
}
return root
}