Skip to content

arturoa925/iMessage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

iMessage Rest API

This is a recreation REST API for iMessage. It allows you to send and receive messages, edit, and react to messages.


Installation

  1. Install dependencies
    npm install
  2. 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
  3. Seed the database
    npm run seed
  4. Start the server
    npm start

Usage

Once the server is running (default: http://localhost:3000), you can exercise the API routes using Insomnia or Postman:

Insomnia

  1. Create a new request.
  2. Select the HTTP method and enter the endpoint URL (e.g., GET http://localhost:3000/users).
  3. For POST/PUT requests, switch to the Body tab, choose JSON, and supply the payload.
  4. Click Send and review the JSON response in the preview panel.

Postman

  1. Create a new request or collection.
  2. Set the HTTP method and URL (e.g., GET http://localhost:3000/users).
  3. Under the Body tab, select raw and JSON.
  4. Paste your request payload, then click Send.
  5. Inspect the response in the Response pane.

Users Routes

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

Get All Users

Request

  • Method: GET
  • URL: /users

Response

  • Status: 200
  • Body: Array of user objects

Get User by Apple ID

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

Create a New User

Request

  • Method: POST
  • URL: /users
  • Body: JSON payload with user fields

Response

  • Status: 201
  • Body: Created user object

Update User by Apple ID

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

Delete User by Apple ID

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

Get User Conversations

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

Messages Routes

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

Get All Messages

Request

  • Method: GET
  • URL: /messages

Response

  • Status: 200
  • Body: Array of threaded message objects

Search Messages

Request

  • Method: GET
  • URL: /messages/search
  • Query Parameters:
    • q (string) – search query

Response

  • Status: 200
  • Body: Array of threaded message objects matching the query

Get Message by ID

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

Create a New Message

Request

  • Method: POST
  • URL: /messages
  • Body: JSON payload including:
    • AppleID (string) – sender's Apple ID
    • recipientAppleID (string) – recipient's Apple ID
    • content (string) – message content
    • parentMessageId (integer, optional)

Response

  • Status: 201
  • Body: Created message object with recipients list

Update Message by ID

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

Delete Message by ID

Request

  • Method: DELETE
  • URL: /messages/:id
  • Parameters:
    • id (integer) – ID of the message

Response

  • Status: 200 if deleted, 404 if not found

Mark Message as Read

Request

  • Method: PATCH
  • URL: /messages/:id/read
  • Parameters:
    • id (integer) – ID of the message

Response

  • Status: 200 if marked, 404 if not found

Mark Message as Delivered

Request

  • Method: PATCH
  • URL: /messages/:id/delivered
  • Parameters:
    • id (integer) – ID of the message

Response

  • Status: 200 if marked, 404 if not found

Conversations Routes

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

Get All Conversations

Request

  • Method: GET
  • URL: /conversations

Response

  • Status: 200
  • Body: Array of conversation objects with nested messages

Get Conversation by ID

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

Get User Conversations

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

Delete Conversation by ID

Request

  • Method: DELETE
  • URL: /conversations/:id
  • Parameters:
    • id (integer) – ID of the conversation

Response

  • Status: 200 if deleted, 404 if not found

Reactions Routes

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

Get All Reactions

Request

  • Method: GET
  • URL: /reactions

Response

  • Status: 200
  • Body: Array of reaction objects with associated message info

Get Reaction by ID

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

Create a New Reaction

Request

  • Method: POST
  • URL: /reactions
  • Body: JSON payload including:
    • messageId (integer) – ID of the message being reacted to
    • AppleID (string) – user’s Apple ID who reacted
    • type (string) – reaction type (e.g., β€œlike”, β€œlove”, β€œlaugh”)

Response

  • Status: 201
  • Body: Created reaction object

Update Reaction by ID

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

Delete Reaction by ID

Request

  • Method: DELETE
  • URL: /reactions/:id
  • Parameters:
    • id (integer) – ID of the reaction

Response

  • Status: 200 if deleted, 404 if not found

About

REST API for iMessage

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors