Get a public key¶
GET /api/v5/user/keys/{id}
Call this endpoint to get a public key.
Supported access tokens¶
- AtomGit user access token (AtomGit user access tokens)
Anonymous access¶
This endpoint does not allow anonymous access.
Request parameters¶
| Parameter | Location | Type | Required | Description |
|---|---|---|---|---|
id |
path | integer | Yes | Public key ID |
access_token |
query | string | Yes | User authorization code |
Response parameters¶
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
id |
integer | Yes | No | Public key ID |
title |
string | Yes | No | Public key title |
key |
string | Yes | No | SSH key |
created_at |
string | Yes | No | Creation time |
url |
string | Yes | No | Public key details URL |
Error response¶
401 Unauthenticated
400 Invalid parameters
HTTP status codes¶
| Status code | Description |
|---|---|
200 |
Success (OK) |
400 |
Bad request |
401 |
Requires authentication |
403 |
Forbidden |
404 |
Not found |
Request example¶
Parameter notes¶
<id>replace with the public key ID to retrieve;<token>replace with your AtomGit user access token.
cURL¶
curl -X GET 'https://api.atomgit.com/api/v5/user/keys/<id>?access_token=<token>' \
-H 'Accept: application/json'
JavaScript¶
// Native fetch (Node.js 18+ / browser)
const response = await fetch("https://api.atomgit.com/api/v5/user/keys/<id>?access_token=<token>", {
headers: {
"Accept": "application/json",
},
});
if (!response.ok) {
throw new Error(`Request failed: ${response.status}`);
}
const data = await response.json();
console.log(data);
Python¶
import requests
resp = requests.get(
"https://api.atomgit.com/api/v5/user/keys/<id>",
params={"access_token": "<token>"},
headers={"Accept": "application/json"},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
Response example¶
Status code: 200
{
"id": 308357,
"title": "xiaogang@csdn.net",
"key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCwT9UXXtGfLa16tbxV+0RQ6m+BaAG2wJvqApr+juVNEmnM0lKNt1tyxY/V9SsCRf38UprPLTp71+btRpFIH9TLrGhkvT3tJOouYDXVUpSaigi7OO+6eLc+Cn0TZSLj4RmwVe/w93kmsCUzgqkeHk14K3S+2oCCm1rbpBAvpPhSKHhAH9LcTBecDoZ+NA2dsEDyfsloVH5cMJQO9n2W1QYduMuuaVHHpehSdDohN7cDI799Rwofaqqyz6ZJrc6eBjSVi1W+JPDTT6NW0+eFBYXo3KWybffixH4cAWdbS1Ms5Pe9Xh+G4WqFuhFh9zCoXlRUUrArLo5pYfpy5gv4iUVmniM0Pb0/Y5x8RJyGaPdS/2c68s8LQsm/9Ees8aeE5TcT5isDEvh+wy7jp1xi5nONk9QvOy7EdYYeHQtkw/0rklsz7UvAIjjHObNNYpY6RLQRT+dqN/lAb7stT047FSxqcNMCX/cybapLygs1y2ClcgU42p16RfgCH0NKA5emRhM= xiaogang@csdn.net",
"created_at": "2024-07-23T10:29:42.119+00:00",
"url": "https://api.atomgit.com/v5/user/keys/308357"
}
Error codes¶
| Error code | Description |
|---|---|
401 |
Unauthenticated or invalid credentials (missing or invalid access token) |
400 |
Invalid parameters or unparseable request |
403 |
Forbidden |
404 |
Request resource not found |
405 |
Request method not supported |
429 |
Too many requests; rate limit triggered |
500 |
Internal system error |
Markdown source: View on AtomGit·Content from the open-source project gitcode-dev/atomgit-api-doc