Spoofy API
Spoofy API Documentation
0. API
- Type: API RESTful
- CORS: [*]
- API Url:
https://spoofy-api.onrender.com
1. About
Spoofy is a website where users can locate their favorite song lyrics, as well as translate them and dedicate the lyrics to other users via email. This documentation is intended to guide potential developers on the path of the API.
2. Routes
2.1 Sign Up
Route: {baseUrl}/user/sign-up
HTTP request methods: POST
Description: The Sign Up Route plays a crucial role in our API's user registration procedure, offering a balance between user convenience and robust password security. Upon receiving a POST request, the route rigorously assesses the provided password for compliance with predefined criteria, mandating the inclusion of numbers and special characters. Successful adherence to these standards triggers the generation of a secure hash for the password, adding an extra layer of protection. This hashed password, along with other registration details, is then seamlessly integrated into the database, creating a new user entry. By leveraging the Sign Up Route, developers can seamlessly guide users through the registration process while upholding stringent password security measures, ensuring the creation of strong and well-protected user accounts.
Authorization: No
Body Base: {
"email": "user@spoofy.com",
"password": "123456781#",
"avatar": "pic_url"
}
Response Status - 200 OK: {
"message": "User created successfully!",
"promise": true
}
2.2 Login
Route: {baseUrl}/user/login
HTTP request methods: POST
Description: The Login Route plays a pivotal role in our API's user authentication process. It meticulously validates incoming parameters, queries the database using the provided email to locate the user's record, and subsequently compares the hashed password from the database with the hashed password supplied in the request. Successful completion of these steps leads to the generation of a session, including the creation of a JSON Web Token (JWT) that encapsulates user-specific details and permissions. The ultimate outcome is the issuance of an encrypted JWT token, serving as a secure access credential with a limited time span, empowering users with authorized and controlled access to various endpoints within the API.
Authorization: No
Body Base: {
"email": "user@spoofy.com",
"password": "123456781#",
}
Response Status - 200 OK:
{
"message": "Login successful!",
"token": {
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.
eyJpZCI6ODg2MjEzLCJkYXRlQ3JlYXRlZCI6MTY5MjcxNDUwOTA1
MywidXNlcm5hbWUiOiJ0ZXN0ZTAwOUBnbWFpbC5jb20iLCJpc3N1Z
WQiOjE2OTI3MTQ1MDkwNTMsImV4cGlyZXMiOjE2OTI3MTQ1OTU0NTN9.
rdu_7YfPsVl0UjOjWItPlV5Doz9kYX88yP3vZ4zKPwlRy7AJ6jYMyBGX1
vbMMREGGG99nSq2LZ-XFL0HLBY15Q",
"issued": 1692714509053,
"expires": 1692714595453
},
"userId": "64e4c5e1c671354022660a4a",
"email": "user@spoofy.com",
"promise": true
}
2.3 Authentication
Route: {baseurl}/user/auth
HTTP request methods: GET
Description: A Validation Route is a pivotal component of our API, designed to assess the validity of a user session. This route expects a schema for data representation and a JSON Web Token (JWT) received through the headers. It meticulously evaluates the token's authenticity and expiration, cross-referencing it with the user's stored session data. Subsequently, the route determines whether the user's session is valid or not. By employing the Validation Route, developers can seamlessly confirm the legitimacy of user sessions, enhancing security and ensuring that authorized actions are performed within the API.
Authorization: Yes
Headers Base: {
"Authorization": {schema} {jwt}
}
Response Status - 200 OK:
{
"message": "Session is valid",
"promise": true
}