Tài liệu mô tả các Endpoint của API cho ứng dụng Threads bởi Unicode.
https://threads-api.unicode.vn/api
Tài liệu này cung cấp cái nhìn tổng quan về các endpoint của API. Vui lòng liên hệ với bộ phận hỗ trợ nếu bạn có bất kỳ câu hỏi nào.
Phương thức: POST
Endpoint: /auth/login
Mô tả: Đăng nhập với email và password.
Tham số:
email (string, bắt buộc): Username, email hoặc số điện thoại.password (string, bắt buộc): Mật khẩu.
{
"email": "[email protected]",
"password": "unicode"
}
200 OK:
{
"status": "success",
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ...",
"refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2l...",
"token_type": "bearer"
}
Phương thức: POST
Endpoint: /auth/register
Mô tả: Đăng ký tài khoản.
Tham số:
name (string, bắt buộc): Tên.username (string, bắt buộc): Username.email (string, bắt buộc): Email.phone (string, bắt buộc): Số điện thoại.description (text): Mô tả.link (string): Đường dẫn liên kết.avatar_path (file): Ảnh đại diện người dùng.password (string, bắt buộc): Mật khẩu.password_confirmation (string, bắt buộc): Xác nhận mật khẩu.url_target (string, bắt buộc): Đường dẫn đích.
{
"name": "Unicode Academy",
"username": "unicode_academy",
"email": "[email protected]",
"phone": "0912345678",
"description": "Unicode Academy Description",
"link": "https://unicode.vn",
"avatar_path": {file_avatar},
"password": "unicode",
"password_confirmation": "unicode",
"url_target": "https://test.com"
}
201 Created:
{
"status": "success",
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOi...",
"refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX...",
"token_type": "bearer"
}
Phương thức: POST
Endpoint: /auth/social/{provider}
Mô tả: Đăng nhập bằng mạng xã hội.
Tham số:
provider (google, github): Google hoặc Github.access_token (string, bắt buộc): Access token của google.
{
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ..."
}
200 OK:
{
"status": "success",
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ...",
"refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2l...",
"token_type": "bearer"
}
Phương thức: GET
Endpoint: /auth/profile
Mô tả: Lấy thông tin profile của người dùng.
Tham số: Không có
Authorization: Bearer {your_token}
200 OK:
{
"status": "success",
"data": {
"id": 1,
"name": "Unicode Academy",
"email": "[email protected]",
"avatar_path": {avatar_path}
}
}
Phương thức: POST
Endpoint: /auth/profile
Tham số:
name (string): Tên.username (string): Username.email (string): Email.phone (string): Số điện thoại.link (string): Đường dẫn liên kết.description (string): Mô tả.password_current (string): Mật khẩu hiện tại.password (string): Mật khẩu mới.avatar_path (file): Ảnh đại diện người dùng.
Authorization: Bearer {your_token}
{
"name": "Unicode Academy Update",
"username": "unicode_academy_update",
"phone": "0912345678",
"email": "[email protected]",
"link": "https://unicode.vn",
"description": "Unicode Academy Update",
"password_current": "unicode",
"password": "unicode_new",
"avatar_path": {file_avatar}
}
200 OK:
{
"status": "success",
"message": "User updated successfully!"
}
Phương thức: POST
Endpoint: /auth/refresh
Mô tả: Cấp lại Access Token và Refresh Token mới.
Tham số:
refresh_token (string, bắt buộc): Refresh Token.
{
"refresh_token": {your_token},
}
200 OK:
{
"status": "success",
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwO...",
"refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjox...",
"token_type": "bearer"
}
Phương thức: POST
Endpoint: /auth/logout
Mô tả: Đăng xuất.
Tham số: Không có
Authorization: Bearer {your_token}
200 OK:
{
"status": "success",
"message": "Successfully logged out"
}
Phương thức: PATCH
Endpoint: /confirm-account
Mô tả: Xác Email đăng ký tài khoản.
Tham số:
token (string, bắt buộc): Token.
{
"token": {your_token},
}
200 OK:
{
"status": "success",
"message": "Your account has been activated"
}
Phương thức: POST
Endpoint: /forgot-password
Mô tả: Gửi yêu cầu lấy lại mật khẩu.
Tham số:
email (string, bắt buộc): Email.url_target (string, bắt buộc): Đường dẫn đích.
{
"email" : "[email protected]",
"url_target" : "https://www.google.com.vn"
}
200 OK:
{
"status": "success",
"message": "Email sent successfully"
}
Phương thức: PATCH
Endpoint: /reset-password
Mô tả: Thực hiện lấy lại mật khẩu.
Tham số:
password (string, bắt buộc): Mật khẩu.password_confirmation (string, bắt buộc): Xác nhận mật khẩu.token (string, bắt buộc): Token.
{
"password": "123123",
"password_confirmation": "123123",
"token": "your_token"
}
200 OK:
{
"status": "success",
"message": "Password reset successfully"
}
Phương thức: POST
Endpoint: auth/email/send-verification
Mô tả: Gửi lại mail kích hoạt tài khoản.
Tham số:
url_target (string, bắt buộc): Đường dẫn đích.
Authorization: Bearer {your_token}
{
"url_target": "https://test.com"
}
200 OK:
{
"status": "success",
"message": "Email sent successfully"
}
Phương thức: DELETE
Endpoint: /auth/user/{email}
Mô tả: Dùng để xóa user trong quá trình test mà không có Token
Tham số:
email (string): Email user.200 OK:
{
"success": true
}
Phương thức: GET
Endpoint: /users
Mô tả: Lấy danh sách tất cả người dùng.
Tham số:
page (string, integer): Lấy dữ liệu từng trang, mặc định là trang 1.limit (string, integer): Users ở mỗi trang, mặc định là 10.keyword (string): Từ khóa tìm kiếm.
Authorization: Bearer {your_token}
200 OK:
{
"status": "success",
"message": "Users fetched successfully.",
"data": {
"current_page": 1,
"last_page": {last_page},
"per_page": {user_per_page},
"total": {total_users},
"data": [
{
"id": 1,
"name": "Unicode Academy",
"email": "[email protected]",
"avatar_path": null
},
...
]
}
}
Phương thức: GET
Endpoint: /users/{id}
Mô tả: Lấy thông tin chi tiết người dùng.
Tham số:
id (string): ID người dùng.
Authorization: Bearer {your_token}
200 OK:
{
"status": "success",
"message": "User fetched successfully.",
"data": {
"id": 1,
"name": "Unicode Academy",
"email": "[email protected]",
"avatar_path": null
},
}
Phương thức: POST
Endpoint: /users/{id}
Mô tả: Cập nhật thông tin người dùng.
Tham số:
name (string): Tên.email (string): Email.password (string): Mật khẩu.avatar_path (file): Ảnh đại diện người dùng._method (PUT/PATCH, bắt buộc): phương thức thực hiện.
Authorization: Bearer {your_token}
{
"name": "Unicode Academy Update",
"email": "[email protected]",
"password": "unicode",
"avatar_path": {file_avatar},
"_method": PUT/PATCH
}
200 OK:
{
"status": "success",
"message": "User updated successfully!",
"data": {
"id": 1,
"name": "Unicode Academy Update",
"email": "[email protected]",
"avatar_path": {avatar_path}
}
}
Phương thức: DELETE
Endpoint: /users/{id}
Mô tả: Xóa người dùng.
Tham số:
id (string): ID người dùng.
Authorization: Bearer {your_token}
200 OK:
{
"status": "success",
"message": "User deleted successfully!",
"data": null
}
Phương thức: GET
Endpoint: /follows
Mô tả: Lấy danh sách những người mình đã follow.
Authorization: Bearer {your_token}
200 OK:
{
"status": "success",
"message": "Follow fetched successfully.",
"data": [
{
"id": 2,
"name": "Unicode Academy 2",
"email": "[email protected]",
"avatar_path": null
}
]
}
Phương thức: POST
Endpoint: /follows/{id}
Mô tả: Follow hoặc hủy follow user, nếu chưa follow thì sẽ follow và ngược lại.
Tham số:
id (string): ID user.
Authorization: Bearer {your_token}
201 OK:
{
"status": "success",
"message": "Unfollowed successfully.",
"data": null
}
Phương thức: GET
Endpoint: /posts
Mô tả: Lấy danh sách tất cả bài viết.
Tham số:
page (string, integer): Lấy dữ liệu từng trang, mặc định là trang 1.limit (string, integer): Posts ở mỗi trang, mặc định là 10.keyword (string): Từ khóa tìm kiếm.
Authorization: Bearer {your_token}
200 OK:
{
"status": "success",
"message": "Retrieve all posts successfully!",
"data": {
"current_page": 1,
"last_page": {last_page},
"per_page": {post_per_page},
"total": {total_posts},
"data": [
{
"id": 1,
"content": "Post 1",
"total_favorites": 0,
"total_comments": 0,
},
...
]
}
}
Phương thức: GET
Endpoint: /posts/user/{user_id}
Mô tả: Lấy danh sách tất cả bài viết của 1 user cụ thể.
Tham số:
user_id (string, integer): ID user.page (string, integer): Lấy dữ liệu từng trang, mặc định là trang 1.limit (string, integer): Posts ở mỗi trang, mặc định là 10.keyword (string): Từ khóa tìm kiếm.
Authorization: Bearer {your_token}
200 OK:
{
"status": "success",
"message": "Retrieve all posts successfully!",
"data": {
"current_page": 1,
"last_page": {last_page},
"per_page": {post_per_page},
"total": {total_posts},
"data": [
{
"id": 1,
"content": "Post 1",
"total_favorites": 0,
"total_comments": 0,
},
...
]
}
}
Phương thức: GET
Endpoint: /posts/{post_id}
Mô tả: Lấy chi tiết bài viết.
Tham số:
post_id (string, integer): ID bài viết.
Authorization: Bearer {your_token}
200 OK:
{
"status": "success",
"message": "Retrieve all posts successfully!",
"data": {
"id": 1,
"content": "Post 1",
"total_favorites": 0,
"total_comments": 0,
"user": null
}
}
Phương thức: POST
Endpoint: /posts
Mô tả: Tạo bài viết.
Authorization: Bearer {your_token}
Tham số:
content (string, bắt buộc): Refresh Token.images (array): Mảng chứa các file ảnh.videos (array): Mảng chứa các file video.
{
"content": Unicode Academy,
"images": [{file_image}],
"videos": [{file_video}]
}
200 OK:
{
"status": "success",
"message": "Post published successfully!",
"data": null
}
Phương thức: POST
Endpoint: /posts/{post_id}
Mô tả: Cập nhật bài viết.
Tham số:
post_id (string, integer, bắt buộc): ID bài viết._method (PUT/PATCH, bắt buộc): Phương thức thực hiện.content (string): Nội dung bài viết.images (array): Mảng chứa các file ảnh.videos (array): Mảng chứa các file video.keep_images (string): Mảng chứa các id ảnh cần giữ lại, không có sẽ xóa.keep_videos (string): Mảng chứa các id video cần giữ lại, không có sẽ xóa.
Authorization: Bearer {your_token}
200 OK:
{
"status": "success",
"message": "Post updated successfully.",
"data": null
}
Phương thức: DELETE
Endpoint: /posts/{post_id}
Mô tả: Xóa bài viết.
Tham số:
post_id (string, integer): ID bài viết muốn xóa.
Authorization: Bearer {your_token}
200 OK:
{
"status": "success",
"message": "Post deleted successfully.",
"data": null
}
Phương thức: GET
Endpoint: /like/list
Mô tả: Lấy danh sách những bài viết đã thêm vào yêu thích của mình.
Authorization: Bearer {your_token}
200 OK:
{
"status": "success",
"message": "Retrieve post successfully!",
"data": [
"current_page": 1,
"last_page": {last_page},
"per_page": {post_per_page},
"total": {total_posts},
"data": [
{
"id": 1,
"content": "Post 1",
"favorites_count": 0,
"comments_count": 0,
},
...
]
]
}
Phương thức: POST
Endpoint: /posts/{post_id}/like
Mô tả: Thích hoặc bỏ thích bài viết, nếu bài viết chưa thích thì sẽ thêm vào yêu thích và ngược lại.
Tham số:
post_id (string, integer): ID bài viết.
Authorization: Bearer {your_token}
201 OK:
{
"status": "success",
"message": "Post liked successfully.",
"data": null
}
Phương thức: GET
Endpoint: /like/list
Mô tả: Lấy danh sách những bài viết đã lưu của mình.
Authorization: Bearer {your_token}
200 OK:
{
"status": "success",
"message": "Retrieve post successfully!",
"data": [
"current_page": 1,
"last_page": {last_page},
"per_page": {post_per_page},
"total": {total_posts},
"data": [
{
"id": 1,
"content": "Post 1",
"favorites_count": 0,
"comments_count": 0,
},
...
]
]
}
Phương thức: POST
Endpoint: /posts/{post_id}/saved
Mô tả: Thích hoặc bỏ thích bài viết, nếu bài viết chưa thích thì sẽ thêm vào yêu thích và ngược lại.
Tham số:
post_id (string, integer): ID bài viết.
Authorization: Bearer {your_token}
201 OK:
{
"status": "success",
"message": "Post saved successfully.",
"data": null
}
Phương thức: GET
Endpoint: /posts/comment/{comment_id}
Mô tả: Lấy chi tiết bình luận.
Tham số:
comment_id (string, integer): ID Comment.
Authorization: Bearer {your_token}
200 OK:
{
"status": "success",
"message": "Comment fetched successfully.",
"data": {
"id": 18,
"content": "hihi",
"favorites_count": 1
}
}
Phương thức: POST
Endpoint: /posts/{post_id}/comment
Mô tả: Tạo bình luận.
Tham số:
post_id (string, integer): ID Bài viết.
Authorization: Bearer {your_token}
Tham số:
parent_id (number): Bình luận cha (Mặc định là 0).content (string, bắt buộc): Refresh Token.images (array): Mảng chứa các file ảnh.videos (array): Mảng chứa các file video.
{
"parent_id": 0,
"content": Unicode Academy,
"images": [{file_image}],
"videos": [{file_video}]
}
201 OK:
{
"status": "success",
"message": "Comment published successfully.",
"data": null
}
Phương thức: POST
Endpoint: /posts/comment/{comment_id}
Mô tả: Cập nhật comment.
Tham số:
comment_id (string, integer, bắt buộc): ID Comment._method (PUT/PATCH, bắt buộc): Phương thức thực hiện.content (string): Nội dung comment.images (array): Mảng chứa các file ảnh.videos (array): Mảng chứa các file video.keep_images (string): Mảng chứa các id ảnh cần giữ lại, không có sẽ xóa.keep_videos (string): Mảng chứa các id video cần giữ lại, không có sẽ xóa.
Authorization: Bearer {your_token}
200 OK:
{
"status": "success",
"message": "Comment updated successfully.",
"data": null
}
Phương thức: DELETE
Endpoint: /posts/comment/{comment_id}
Mô tả: Xóa bình luận.
Tham số:
comment_id (string, integer): ID Comment.
Authorization: Bearer {your_token}
200 OK:
{
"status": "success",
"message": "Comment deleted successfully.",
"data": null
}
Phương thức: POST
Endpoint: /posts/comment/{comment_id}/like
Mô tả: Thích hoặc bỏ thích bình luận, chưa thích sẽ thêm vào danh sách yêu thích và ngược lại.
Tham số:
comment_id (string, integer): ID Comment.
Authorization: Bearer {your_token}
200 OK:
{
"status": "success",
"message": "Comment liked successfully.",
"data": null
}