This API is designed to work with the Pose2Pose web application. The endpoints are designed for user management, video storage and content creation using machine learning models.
The API is implemented in Node and Express, using MongoDB as a database.
Register a user with a username and password.
POST /api/register
body {
username,
password
}
Get authorization for a user.
POST /api/auth
body {
username,
password
}
returns the user id and a valid token.
Update username.
PUT /api/users/:id/updateUsername
authorization: Bearer TOKEN
body {
newUsername,
password
}
Update password.
PUT /api/users/:id/updatePassword
authorization: Bearer TOKEN
body {
newPassword,
password
}
Delete user
DELETE /api/users/:id
authorization: Bearer TOKEN
body {
password
}
Save video.
PUT /api/users/:id/videos
authorization: Bearer TOKEN
FormData: file
Delete video.
DELETE /api/users/:id/videos/:videoId
authorization: Bearer TOKEN
Retrieve all videos for a user
GET /api/users/:id/videos
authorization: Bearer TOKEN
returns an array with the ids of all the users' videos.
Download a video
GET /api/users/:id/videos/:videoId
authorization: Bearer TOKEN
returns the stream object of the video.
Create dataset.
PUT /api/users/:id/datasets
authorization: Bearer TOKEN
body {
videoId,
settings
}
Delete dataset.
DELETE /api/users/:id/datasets/:datasetId
authorization: Bearer TOKEN
Retrieve all datasets for a user
GET /api/users/:id/datasets
authorization: Bearer TOKEN
returns an array with the ids of all the users' datasets.
Download a dataset
GET /api/users/:id/datasets/:datasetId
authorization: Bearer TOKEN
returns the stream object of the dataset.
Create result.
PUT /api/users/:id/results
authorization: Bearer TOKEN
body {
datasetId,
modelId,
settings
}
Delete result.
DELETE /api/users/:id/results/:resultId
authorization: Bearer TOKEN
Retrieve all results for a user
GET /api/users/:id/results
authorization: Bearer TOKEN
returns an array with the ids of all the users' results.
Download a result
GET /api/users/:id/results/:resultId
authorization: Bearer TOKEN
returns the stream object of the result.
Retrieve all models
GET /api/users/:id/models
authorization: Bearer TOKEN
returns an array with the ids of all the users' models.
Download a model
GET /api/users/:id/models/:modelId
authorization: Bearer TOKEN
returns the stream object of the model.
The API uses Node and Express to set up the server. The routes are defined in routes.js. Files are stored locally inside the data and model folders. User and files information is stored in MongoDB. The business logic controlls the data flow between the API endpoints, the local storage and the database.
The API uses mongoose to define schemas and models. Files information are stored in the User model as arrays of ids, linking the different collections.