-
Notifications
You must be signed in to change notification settings - Fork 0
Users
Get a list of verified users.
GET /api/users
Parameters:
Attribute | Type | Required | Description |
---|---|---|---|
search | string | no | Search keyword |
Example request:
curl "https://julia-api-server.codes/api/users/?search=example"
Example response:
{
"count": 6,
"next": null,
"previous": null,
"results": [
{
"id": 2,
"username": "arcturus5340",
"date_joined": 1618175902,
"last_login": 1618238711
},
{
"id": 37,
"username": "artem_barsov",
"date_joined": 1618238031,
"last_login": null
},
{
"id": 39,
"username": "abinba",
"date_joined": 1618238363,
"last_login": null
},
{
"id": 40,
"username": "аrtem_barsov",
"date_joined": 1618239447,
"last_login": null
},
{
"id": 41,
"username": "real_artem_barsov",
"date_joined": 1618240085,
"last_login": null
},
{
"id": 42,
"username": "lilproskater",
"date_joined": 1618240685,
"last_login": null
}
]
}
Authenticated users also see the "email" field - the email address of each other user
Get a specific user identified by the user id.
GET /api/users/:id
Parameters:
Attribute | Type | Required | Description |
---|---|---|---|
id | int | yes | The user ID |
Example request:
curl "https://julia-api-server.codes/api/users/2"
Example response:
{
"id": 2,
"username": "arcturus5340",
"date_joined": 1618175902,
"last_login": 1618238711
}
Authenticated users also see the "email" field - the email address of each other user
Create a new user by posting a JSON payload.
POST /api/users
Parameters:
Attribute | Type | Required | Description |
---|---|---|---|
username | string | yes | User nickname |
password | string | yes | User password |
string | yes | User email |
Example request:
PAYLOAD=$(cat << 'JSON'
{
"username": "new_user",
"password": "password",
"email": "[email protected]",
}
JSON
)
curl --request POST --header "Content-Type: application/json" --data "$PAYLOAD" "https://julia-api-server.codes/api/users/"
Example response:
{
"id": 1,
"username": "user",
"password": "password",
"email": "[email protected]",
}
Partial update a user data.
PATCH /api/users/:id
Parameters:
Attribute | Type | Required | Description |
---|---|---|---|
id | int | yes | The user ID |
username | string | no | User nickname |
password | string | no | User password |
string | no | User email |
Example request:
PAYLOAD=$(cat << 'JSON'
{
"username": "new_user"
}
JSON
)
curl --request PATCH --header "Authorization: JWT <access_token>" --header "Content-Type: application/json" --data "$PAYLOAD" "https://julia-api-server.codes/api/users/1"
Example response:
{
"id": 1,
"username": "new_user",
"password": "password",
"email": "[email protected]",
}
Update a user data. Only for staff!
PUT /api/users/:id
Parameters:
Attribute | Type | Required | Description |
---|---|---|---|
id | int | yes | The user ID |
username | string | yes | User nickname |
password | string | yes | User password |
string | yes | User email |
Example request:
PAYLOAD=$(cat << 'JSON'
{
"username": "new_user",
"password": "password",
"email": "[email protected]",
}
JSON
)
curl --request PUT --header "Authorization: JWT <access_token>" --header "Content-Type: application/json" --data "$PAYLOAD" "https://julia-api-server.codes/api/users/1"
Example response:
{}
Reset a user's password. In an e-mail the user will receive a secret key of the following form: {id}_{activation key}. This data is used to confirm the password reset.
POST /api/users/reset_password
Parameters:
Attribute | Type | Required | Description |
---|---|---|---|
username | string | no | User nickname |
string | no | User email |
Example request:
PAYLOAD=$(cat << 'JSON'
{
"username": "new_user",
}
JSON
)
curl --request POST --header "Content-Type: application/json" --data "$PAYLOAD" "https://julia-api-server.codes/api/users/reset_password"
Example response:
{}
Confirms and applies the password reset.
POST /api/users/:id/reset_password/:activation_key/confirm
Parameters:
Attribute | Type | Required | Description |
---|---|---|---|
id | int | yes | The user ID |
activation_key | string | yes | Activation key from email |
password | string | yes | New user password |
Example request:
PAYLOAD=$(cat << 'JSON'
{
"password": "new_password",
}
JSON
)
curl --request POST --header "Content-Type: application/json" --data "$PAYLOAD" "https://julia-api-server.codes/api/users/1/reset_password/0278641a94644e5aa21a53715d42dedb/confirm"
Example response:
{}
Delete a user.
DELETE /api/users/:id
Parameters:
Attribute | Type | Required | Description |
---|---|---|---|
id | int | yes | The user ID |
Example request:
curl --request DELETE --header "Authorization: JWT <access_token>" --header "Content-Type: application/json" "https://julia-api-server.codes/api/users/1"
Example response:
{}