This document describes the REST API endpoints used by the Crossed mobile application for peer management, messaging, and profile operations.
The API is accessed via POST requests to api.php with form-encoded parameters.
Currently, no authentication is implemented. User IDs are passed as parameters.
Retrieves the profile image for a specific user.
Parameters:
getpeer(required): Set to1id(required): User ID string
Response:
{
"image": "base64_encoded_image_data"
}Retrieves peer connections and pending message notifications for a user.
Parameters:
getstatus(required): Set to1id(required): User ID string
Response:
{
"peers": ["peer_id_1", "peer_id_2"],
"msgs": ["sender_id_1", "sender_id_2"]
}Establishes a bidirectional peer connection between two users.
Parameters:
mkpeer(required): Set to1fromid(required): Initiating user IDtoid(required): Target user ID
Response: Empty response. Updates peer lists for both users.
Removes a bidirectional peer connection and associated messages.
Parameters:
rmpeer(required): Set to1fromid(required): Initiating user IDtoid(required): Target user ID
Response: Empty response. Removes connections and deletes message history between users.
Sends a message from one user to another and returns the updated chat history.
Parameters:
sendmsg(required): Set to1fromid(required): Sender user IDtoid(required): Recipient user IDmsg(required): Message text
Response: Array of message objects representing the complete chat history:
[
{
"fromid": "sender_id",
"toid": "recipient_id",
"msg": "message text",
"datetime": "2023-01-01 12:00:00"
}
]Retrieves chat history between two users and marks messages as read.
Parameters:
getmsg(required): Set to1fromid(required): Current user IDtoid(required): Chat partner user ID
Response: Array of message objects:
[
{
"fromid": "sender_id",
"toid": "recipient_id",
"msg": "message text",
"datetime": "2023-01-01 12:00:00"
}
]Retrieves or creates a user profile based on device ID.
Parameters:
getprf(required): Set to1device(required): Unique device identifier
Response: If profile exists:
{
"id": "user_id",
"device": "device_id",
"image": "profile_image",
"peers": "[]",
"msgs": "[]",
"datetime": "2023-01-01 12:00:00"
}If new profile created:
{
"id": "generated_user_id",
"device": "device_id"
}Updates user profile information.
Parameters:
setprf(required): Set to1id(required): User IDdevice(required): Device IDimage(required): Base64 encoded image data
Response: Updated user object:
{
"id": "user_id",
"device": "device_id",
"image": "updated_image_data",
"peers": "[]",
"msgs": "[]",
"datetime": "2023-01-01 12:00:00"
}Completely removes a user profile and all associated data.
Parameters:
rmprf(required): Set to1id(required): User ID to remove
Response: Empty response. Removes user from all peer lists, deletes all messages, and removes profile.
| Column | Type | Description |
|---|---|---|
| id | VARCHAR | Unique user identifier |
| device | VARCHAR | Unique device identifier |
| image | TEXT | Base64 encoded profile image |
| peers | TEXT | JSON array of connected peer IDs |
| msgs | TEXT | JSON array of users with pending messages |
| datetime | DATETIME | Last update timestamp |
| Column | Type | Description |
|---|---|---|
| fromid | VARCHAR | Sender user ID |
| toid | VARCHAR | Recipient user ID |
| msg | TEXT | Message content |
| datetime | DATETIME | Message timestamp |
The API does not have standardized error responses. Database connection failures will terminate with a PHP error. Invalid parameters may result in empty responses or unexpected behavior.
- No input validation or sanitization
- No rate limiting
- No authentication
- SQL injection vulnerabilities present
- CORS allows all origins
Warning: This API is not production-ready and should not be exposed to untrusted networks without significant security improvements.