📅  最后修改于: 2023-12-03 14:59:58.443000             🧑  作者: Mango
Codewars API is a RESTful API that allows developers to access codewars.com challenge data. With Codewars API, developers can integrate the challenge data into their applications, create their own clients and interact with Codewars data programmatically.
/users/:username
:username
. Includes user information such as username, clan, leaderboard position, honor, skills, and completed challenges.{
"username": "user123",
"clan": "Codewars",
"leaderboardPosition": 123,
"honor": 4567,
"skills": {
"ruby": {
"score": 1234,
"rank": 3
},
"javascript": {
"score": 5678,
"rank": 2
}
},
"codeChallenges": {
"totalAuthored": 12,
"totalCompleted": 89,
"languages": {
"ruby": {
"authored": 3,
"completed": 45
},
"javascript": {
"authored": 9,
"completed": 44
}
}
}
}
/users/:username/code-challenges/completed?page=:page&pageSize=:pageSize
{
"page": 1,
"pageSize": 20,
"totalPages": 5,
"totalItems": 100,
"data": [
{
"id": "123456abcdef",
"name": "Some challenge",
"slug": "some-challenge",
"completedAt": "2021-04-01T12:34:56Z",
"completedLanguages": ["ruby"]
},
{
"id": "7890ghijklmno",
"name": "Another challenge",
"slug": "another-challenge",
"completedAt": "2021-03-31T12:34:56Z",
"completedLanguages": ["javascript"]
}
]
}
/code-challenges/:id
:id
. Includes challenge information such as name, description, author, tags, and difficulty.{
"name": "Some challenge",
"slug": "some-challenge",
"description": "Some description of the challenge.",
"author": "user123",
"tags": ["tag1", "tag2"],
"rank": {
"id": 123,
"name": "3 kyu"
},
"language": "ruby",
"framework": "rspec",
"createdAt": "2021-04-01T12:34:56Z",
"totalAttempts": 100,
"totalCompleted": 50
}
/code-challenges/:id/solutions
:id
. Includes information such as author, language, and date submitted.{
"page": 1,
"pageSize": 20,
"totalPages": 5,
"totalItems": 100,
"data": [
{
"id": "solution123",
"author": "user456",
"language": "ruby",
"createdAt": "2021-04-02T12:34:56Z",
"url": "https://www.codewars.com/kata/some-challenge/ruby"
},
{
"id": "solution456",
"author": "user789",
"language": "javascript",
"createdAt": "2021-04-03T12:34:56Z",
"url": "https://www.codewars.com/kata/some-challenge/javascript"
}
]
}
To access the Codewars API, developers must first obtain an API key. This can be done by logging in to codewars.com, navigating to the API Documentation page, and following the instructions provided.
Once obtained, the API key can be included in requests by setting the Authorization
header as Bearer <API_KEY>
. For example:
Authorization: Bearer 123abc456def