-
Notifications
You must be signed in to change notification settings - Fork 7
RESTful API endpoint
This is a DRAFT.
If you have any problems, please create an issue on GitHub.
The POST
and PUT
requests body must be JSON format and the Content-Type
header also set to application/json
. In addition, for authenticating request, the X-VMS-API-Key
set to your application key.
- Prefix URI:
/api/v1.0/
The HTTP status code 2XX
represents the request was executed successfully. Otherwise, the HTTP status code 4XX
represents the request unable to execute.
Endpoint | Action | Description |
---|---|---|
/register |
POST | Create a new volunteer account |
Content-Type: application/json
X-VMS-API-Key: d6527aa8bcf55187490154283e4d2a1a268a94ead2322f883276a7c3cb52cd09
{
"username" : "jimlin",
"password" : "MYPASSW0RD",
"first_name" : "Lin",
"last_name" : "Jim",
"birth_year" : 2015,
"gender" : "male",
"city" : "Taipei City",
"address" : "128 Academia Road, Section 2, Nankang Dist.",
"phone_number" : "0912345678",
"email" : "[email protected]",
"emergency_contact" : "Jeremy Lin",
"emergency_phone" : "0919119119"
}
HTTP/1.1 201 Created
Content-Type: application/json;charset=UTF-8
Location: https://vms.app/api/v1.0/users/me
{
"href": "https://vms.app/api/v1.0/users/me",
"username": "jimlin",
"auth_access_token": "56f4da226eb22caa0633023bfdd402658e5c6501c972e83bfb2866f2112b103f"
}
HTTP/1.1 422 Unprocessable Entity
Content-Type: application/json;charset=UTF-8
{
"message": "Validation failed",
"errors": [
{
"resource": "Register",
"field": ["username", "password"],
"code": "missing_field"
}
]
}
Endpoint | Action | Description |
---|---|---|
/auth |
POST | Volunteer logs in the system |
Content-Type: application/json
X-VMS-API-Key: d6527aa8bcf55187490154283e4d2a1a268a94ead2322f883276a7c3cb52cd09
{
"username": "jimlin",
"password": "MYPASSW0RD"
}
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Location: https://vms.app/api/v1.0/users/me
{
"href": "https://vms.app/api/v1.0/users/me"
"auth_access_token": "56f4da226eb22caa0633023bfdd402658e5c6501c972e83bfb2866f2112b103f"
}
If the volunteer's credential is wrong, it will return the following response:
HTTP/1.1 401 Unauthorized
Content-Type: application/json;charset=UTF-8
{
"message": "Authentication failed",
"errors": [
{
"code": "incorrect_login_credentials"
}
]
}
HTTP/1.1 422 Unprocessable Entity
Content-Type: application/json;charset=UTF-8
{
"message": "Validation failed",
"errors": [
{
"resource": "Login",
"field": ["username", "password"],
"code": "missing_field"
}
]
}
Endpoint | Action | Description |
---|---|---|
/auth |
DELETE | Volunteer logs out the system |
Content-Type: application/json
X-VMS-API-Key: d6527aa8bcf55187490154283e4d2a1a268a94ead2322f883276a7c3cb52cd09
X-VMS-AUTH-ACCESS-TOKEN: jimlin:d6527aa8bcf55187490154283e4d2a1a268a94ead2322f883276a7c3cb52cd09
HTTP/1.1 204 No Content
If the volunteer's auth_access_token
doesn't exist, it will return the following response:
HTTP/1.1 404 Not Found
Content-Type: application/json;charset=UTF-8
{
"message": "Failed to logout",
"errors": [
{
"code": "no_existing_auth_access_token"
}
]
}
Endpoint | Action | Description |
---|---|---|
/users/me |
GET | Authenticate volunteer and get volunteer information |
Content-Type: application/json
X-VMS-API-Key: d6527aa8bcf55187490154283e4d2a1a268a94ead2322f883276a7c3cb52cd09
X-VMS-AUTH-ACCESS-TOKEN: jimlin:d6527aa8bcf55187490154283e4d2a1a268a94ead2322f883276a7c3cb52cd09
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
{
"username": "jimlin",
"first_name": "Lin",
"last_name": "Jim",
"birth_year": 2015,
"gender": "male",
"city": "Taipei City",
"address": "128 Academia Road, Section 2, Nankang Dist.",
"phone_number" : "0912345678",
"email": "[email protected]",
"emergency_contact": "Jeremy Lin",
"emergency_phone": "0919119119",
"introduction": "I’m a genius. I Work on Data science/analytics and have excellent skills with Matlab and Ruby programming. My hobbies is sporting.",
"experience":[
{
"company": "Academia Sinica",
"job_title": "Research assistant",
"start_year": 2014,
"end_year": null,
}
],
"education": [
{
"school": "NCKU",
"degree": "master",
"start_year": 2012,
"end_year": 2014
}
],
"projects": {
"href": "https://vms.app/api/v1.0/users/me/projects"
},
"processes": {
"participating_number": 3,
"participated_number": 8,
"href": "https://vms.app/api/v1.0/users/me/proccesses"
}
}
If the volunteer doesn't have right to access, it will return the following response:
HTTP/1.1 403 Forbidden
Content-Type: application/json;charset=UTF-8
{
"message": "Forbidden to access",
"errors": [
{
"code": "cannot_access"
}
]
}
Endpoint | Action | Description |
---|---|---|
/email_verification/[EMAIL_ADDRESS] |
POST | Resend a verification email. A new verification email will send to volunteer's mailbox. |
Content-Type: application/json
X-VMS-API-Key: d6527aa8bcf55187490154283e4d2a1a268a94ead2322f883276a7c3cb52cd09
X-VMS-AUTH-ACCESS-TOKEN: jimlin:d6527aa8bcf55187490154283e4d2a1a268a94ead2322f883276a7c3cb52cd09
None
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
{
"message": "Resend verification email successfully"
}
If the volunteer doesn't have right to access, it will return the following response:
HTTP/1.1 403 Forbidden
Content-Type: application/json;charset=UTF-8
{
"message": "Forbidden to access",
"errors": [
{
"code": "cannot_access"
}
]
}
Endpoint | Action | Description |
---|---|---|
/email_verification/[EMAIL_ADDRESS]/[VERIFICATION_TOKEN] |
PUT | Verify volunteer's email. The volunteer must be authenticated successfully. |
-
EMAIL_ADDRESS
: Volunteer's email address -
VERIFICATION_TOKEN
: A unique token for identifying
Content-Type: application/json
X-VMS-API-Key: d6527aa8bcf55187490154283e4d2a1a268a94ead2322f883276a7c3cb52cd09
X-VMS-AUTH-ACCESS-TOKEN: jimlin:d6527aa8bcf55187490154283e4d2a1a268a94ead2322f883276a7c3cb52cd09
None
HTTP/1.1 200 Ok
{
"message": "Successful email verification"
}
If the volunteer doesn't have right to access, it will return the following response:
HTTP/1.1 403 Forbidden
Content-Type: application/json;charset=UTF-8
{
"message": "Forbidden to access",
"errors": [
{
"code": "cannot_access"
}
]
}
If the verification token is unvalidated or expired, it will return the following response:
HTTP/1.1 404 Not Found
Content-Type: application/json;charset=UTF-8
{
"message": "Unvalidated or expired verification token",
"errors" [
{
"code": "unvalidated_expired_verification_token"
}
]
}
Endpoint | Action | Description |
---|---|---|
/request_password_reset |
POST | Volunteer forgot his/her password. It sends a password reset email to the volunteer |
Content-Type: application/json
X-VMS-API-Key: d6527aa8bcf55187490154283e4d2a1a268a94ead2322f883276a7c3cb52cd09
The /request_password_reset
API accepts two kinds of fields
email:
{
"email": "[email protected]"
}
username:
{
"username": "[email protected]"
}
HTTP/1.1 204 No Content
If the field is misssing, it will return the following response:
HTTP/1.1 422 Unprocessable Entity
Content-Type: application/json;charset=UTF-8
{
"message": "Validation failed",
"errors": [
{
"resource": "Request password reset",
"field": ["username"],
"code": "missing_field"
}
]
}
If the email is unvalidated, it will return the following response:
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8
{
"message": "Validation failed",
"errors": [
{
"resource": "Request password reset",
"field": ["username"],
"code": "unvalidated_username"
}
]
}
Endpoint | Action | Description |
---|---|---|
/reset_password/[EMAIL_ADDRESS]/[REST_PASSWORK_TOKEN] |
POST | Use reset password token to valdiate the reuqest |
Content-Type: application/json
X-VMS-API-Key: d6527aa8bcf55187490154283e4d2a1a268a94ead2322f883276a7c3cb52cd09
{
"password": "password"
}
HTTP/1.1 204 No Content
If the field is misssing, it will return the following response:
HTTP/1.1 422 Unprocessable Entity
Content-Type: application/json;charset=UTF-8
{
"message": "Validation failed",
"errors": [
{
"resource": "Password reset",
"field": ["password"],
"code": "missing_field"
}
]
}
If the volunteer's password is unsecure, it will return the following response:
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8
{
"message": "Validation failed",
"errors": [
{
"resource": "Password reset",
"field": ["password"],
"code": "unsecure_password"
}
]
}
If the volunteer's email or reset passowrd are unvalidated, it will return the following response:
HTTP/1.1 403 Forbidden
Content-Type: application/json;charset=UTF-8
{
"message": "Not validated token",
"errors": [
{
"code": "cannot_access"
}
]
}