This is a recreation REST API for iMessage. It allows you to send and receive messages, edit, and react to messages.
- Install dependencies
npm install
- Configure the PostgreSQL database
- Open a terminal at the project root.
- Connect to your database:
psql -U <username> -d <database_name>
- Execute the schema script:
\i sql/schema.sql
- Seed the database
npm run seed
- Start the server
npm start
Once the server is running (default: http://localhost:3000), you can exercise the API routes using Insomnia or Postman:
Insomnia
- Create a new request.
- Select the HTTP method and enter the endpoint URL (e.g.,
GET http://localhost:3000/users). - For
POST/PUTrequests, switch to the Body tab, choose JSON, and supply the payload. - Click Send and review the JSON response in the preview panel.
Postman
- Create a new request or collection.
- Set the HTTP method and URL (e.g.,
GET http://localhost:3000/users). - Under the Body tab, select raw and JSON.
- Paste your request payload, then click Send.
- Inspect the response in the Response pane.
| Method | Endpoint | Description |
|---|---|---|
| GET | /users |
Retrieve all users |
| GET | /users/:appleId |
Retrieve a user by Apple ID |
| POST | /users |
Create a new user |
| PUT | /users/:appleId |
Update an existing user by Apple ID |
| DELETE | /users/:appleId |
Delete a user by Apple ID |
| GET | /users/:appleId/conversations |
Retrieve all conversations for a user |
All endpoints accept and return JSON with standard HTTP status codes.
π Show full request/response examples
Request
- Method: GET
- URL:
/users
Response
- Status: 200
- Body: Array of user objects
Request
- Method: GET
- URL:
/users/:appleId
Parameters
appleId(string) β Apple ID of the user
Response
- Status: 200 if found, 404 if not found
- Body: User object
Request
- Method: POST
- URL:
/users - Body: JSON payload with user fields
Response
- Status: 201
- Body: Created user object
Request
- Method: PUT
- URL:
/users/:appleId - Parameters:
appleId(string) β Apple ID of the user
- Body: JSON payload with fields to update
Response
- Status: 200 if updated, 404 if not found
- Body: Update count or updated user
Request
- Method: DELETE
- URL:
/users/:appleId - Parameters:
appleId(string) β Apple ID of the user
Response
- Status: 200 if deleted, 404 if not found
- Body: Success message
Request
- Method: GET
- URL:
/users/:appleId/conversations - Parameters:
appleId(string) β Apple ID of the user
Response
- Status: 200 if user found
- Body: Array of conversation objects
| Method | Endpoint | Description |
|---|---|---|
| GET | /messages |
Retrieve all messages with nested replies |
| GET | /messages/search?q=<query> |
Search messages by content |
| GET | /messages/:id |
Retrieve a message thread by message ID |
| POST | /messages |
Create a new message and start a conversation |
| PUT | /messages/:id |
Update a message by ID |
| DELETE | /messages/:id |
Delete a message by ID |
| PATCH | /messages/:id/read |
Mark a message as read |
| PATCH | /messages/:id/delivered |
Mark a message as delivered |
All endpoints accept and return JSON with standard HTTP status codes.
π Show full request/response examples
Request
- Method: GET
- URL:
/messages
Response
- Status: 200
- Body: Array of threaded message objects
Request
- Method: GET
- URL:
/messages/search - Query Parameters:
q(string) β search query
Response
- Status: 200
- Body: Array of threaded message objects matching the query
Request
- Method: GET
- URL:
/messages/:id
Parameters
id(integer) β ID of the message
Response
- Status: 200 if found, 404 if not found
- Body: Threaded message object with nested replies
Request
- Method: POST
- URL:
/messages - Body: JSON payload including:
AppleID(string) β sender's Apple IDrecipientAppleID(string) β recipient's Apple IDcontent(string) β message contentparentMessageId(integer, optional)
Response
- Status: 201
- Body: Created message object with recipients list
Request
- Method: PUT
- URL:
/messages/:id - Parameters:
id(integer) β ID of the message
- Body: JSON payload with fields to update
Response
- Status: 200 if updated, 404 if not found
Request
- Method: DELETE
- URL:
/messages/:id - Parameters:
id(integer) β ID of the message
Response
- Status: 200 if deleted, 404 if not found
Request
- Method: PATCH
- URL:
/messages/:id/read - Parameters:
id(integer) β ID of the message
Response
- Status: 200 if marked, 404 if not found
Request
- Method: PATCH
- URL:
/messages/:id/delivered - Parameters:
id(integer) β ID of the message
Response
- Status: 200 if marked, 404 if not found
| Method | Endpoint | Description |
|---|---|---|
| GET | /conversations |
Retrieve all conversations |
| GET | /conversations/:id |
Retrieve a conversation by ID |
| GET | /conversations/user/:appleId |
Retrieve all conversations for a user |
| DELETE | /conversations/:id |
Delete a conversation by ID |
All endpoints accept and return JSON with standard HTTP status codes.
π Show full request/response examples
Request
- Method: GET
- URL:
/conversations
Response
- Status: 200
- Body: Array of conversation objects with nested messages
Request
- Method: GET
- URL:
/conversations/:id
Parameters
id(integer) β ID of the conversation
Response
- Status: 200 if found, 404 if not found
- Body: Conversation object with nested messages
Request
- Method: GET
- URL:
/conversations/user/:appleId - Parameters:
appleId(string) β Apple ID of the user
Response
- Status: 200
- Body: Array of conversation objects for the user
Request
- Method: DELETE
- URL:
/conversations/:id - Parameters:
id(integer) β ID of the conversation
Response
- Status: 200 if deleted, 404 if not found
| Method | Endpoint | Description |
|---|---|---|
| GET | /reactions |
Retrieve all reactions |
| GET | /reactions/:id |
Retrieve a single reaction by ID |
| POST | /reactions |
Create a new reaction |
| PUT | /reactions/:id |
Update a reaction by ID |
| DELETE | /reactions/:id |
Delete a reaction by ID |
All endpoints accept and return JSON with standard HTTP status codes.
π Show full request/response examples
Request
- Method: GET
- URL:
/reactions
Response
- Status: 200
- Body: Array of reaction objects with associated message info
Request
- Method: GET
- URL:
/reactions/:id
Parameters
id(integer) β ID of the reaction
Response
- Status: 200 if found, 404 if not found
- Body: Reaction object with nested message details
Request
- Method: POST
- URL:
/reactions - Body: JSON payload including:
messageId(integer) β ID of the message being reacted toAppleID(string) β userβs Apple ID who reactedtype(string) β reaction type (e.g., βlikeβ, βloveβ, βlaughβ)
Response
- Status: 201
- Body: Created reaction object
Request
- Method: PUT
- URL:
/reactions/:id - Parameters:
id(integer) β ID of the reaction
- Body: JSON payload with fields to update
Response
- Status: 200 if updated, 404 if not found
Request
- Method: DELETE
- URL:
/reactions/:id - Parameters:
id(integer) β ID of the reaction
Response
- Status: 200 if deleted, 404 if not found