Skip to content

API Reference

Siddhesh edited this page Apr 21, 2022 · 8 revisions

API Reference

The Referral board API is organized around [REST] (http://en.wikipedia.org/wiki/Representational_State_Transfer). Our API has predictable resource-oriented URLs, accepts form-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs.

The basic URL

http://localhost:5555/api

ERRORS

Referral Board uses conventional HTTP response codes to indicate the success or failure of an API request. In general: Codes in the 2xx range indicate success. Codes in the 4xx range indicate an error that failed given the information provided (e.g., a required parameter was omitted, a charge failed, etc.). Codes in the 5xx range indicate an error with Stripe's servers (these are rare).

Retrieve All Users

Retrieves the list of all users from the database.

Parameters

none

GET /api/users

curl http://localhost:5555/api/users

Response

Returns a JSON array of JSON objects for all the users in the database.

[
	{
		"userId": 1,
		"firstName": "dummy_firstName",
		"lastName": "dummy_lastName",
		"currentLocation": "Florida",
		"currentCompanyId": 1,
		"currentCompanyName": "Dummy Company",
		"currentPosition": "dummyPosition",
		"school": "dummySchool",
		"yearsOfExperienceId": 1,
		"email": "[email protected]",
		"password": "dummyPassword"
	}
]

Retrieve a User based on Id

Retrieves a user details based on the filter user Id

Parameters

none

GET /api/users/id/:id

curl http://localhost:5555/api/users/id/:id

Response

Returns a JSON object of the user based on the user id.

	{
		"userId": 1,
		"firstName": "dummy_firstName",
		"lastName": "dummy_lastName",
		"currentLocation": "Florida",
		"currentCompanyId": 1,
		"currentCompanyName": "Company A",
		"currentPosition": "Intern",
		"school": "UF",
		"yearsOfExperienceId": 1,
		"email": "[email protected]",
		"password": "root"
	}

Retrieve a User based on Email Id

Retrieves a user details based on the filter user email id

Parameters

none

GET /api/users/email/:email

curl http://localhost:5555/api/users/email/:email

Response

Returns a JSON object of the user based on the email id.

	{
		"userId": 1,
		"firstName": "dummy_firstName",
		"lastName": "dummy_lastName",
		"currentLocation": "Florida",
		"currentCompanyId": 1,
		"currentCompanyName": "Company A",
		"currentPosition": "Intern",
		"school": "UF",
		"yearsOfExperienceId": 1,
		"email": "[email protected]",
		"password": "root"
	}

Add new User

Adds new user to database.

Parameters

  • firstName: string
  • lastName: string
  • currentLocation: string
  • currentCompanyId: integer
  • currentCompanyName: string
  • currentPosition: string
  • school: string
  • yearsOfExperienceId: integer
  • email: string
  • password: string

POST /api/users/newuser

curl -d "{\"firstName\": \"dummy_firstName\",\"lastName\":\"dummy_lastName\",\"currentLocation\":\"dummy_location\", \"currentComapnyId\":1, \"currentCompanyName\":\"dummy_company\",\"school\":\"dummy_school\", \"yearsOfExperience\":1, \"email\":\"[email protected]\", \"password\":\"dummypassword\"}" 
-H "Content-Type: application/json" 
http://localhost:8080/api/users/newuser

Response

Returns the JSON object of the newly added User.

	{
		"userId": 1,
		"firstName": "dummy_firstName",
		"lastName": "dummy_lastName",
		"currentLocation": "Florida",
		"currentCompanyId": 1,
		"currentCompanyName": "Company A",
		"currentPosition": "Intern",
		"school": "UF",
		"yearsOfExperienceId": 1,
		"email": "[email protected]",
		"password": "root"
	}

Update a User

Updates a user details based on the user id filter.

Parameters

  • userId: integer
  • firstName: string
  • lastName: string
  • currentLocation: string
  • currentCompanyId: integer
  • currentCompanyName: string
  • currentPosition: string
  • school: string
  • yearsOfExperienceId: integer
  • email: string
  • password: string

PUT /api/users/:id

curl -d "{\"userId\":1\"firstName\": \"dummy_firstName\",\"lastName\":\"dummy_lastName\",\"currentLocation\":\"dummy_location\", \"currentComapnyId\":1, \"currentCompanyName\":\"dummy_company\",\"school\":\"dummy_school\", \"yearsOfExperience\":1, \"email\":\"[email protected]\", \"password\":\"dummypassword\"}" 
-H "Content-Type: application/json" 
http://localhost:8080/api/users/:id

Response

Returns the JSON object of the updated User.

	{
		"userId": 1,
		"firstName": "dummy_firstName",
		"lastName": "dummy_lastName",
		"currentLocation": "Florida",
		"currentCompanyId": 1,
		"currentCompanyName": "Company A",
		"currentPosition": "Intern",
		"school": "UF",
		"yearsOfExperienceId": 1,
		"email": "[email protected]",
		"password": "root"
	}

Retrieve all Posts

Retrieves all the posts from the database

Parameter

none

GET /api/posts

curl http://localhost:5555/api/posts

Response

Returns a JSON array containing all the JSON objects for posts available in the database.

[
    {
        "postId": 1,
        "userId": 1,
        "targetCompanyId": 2,
        "targetPosition": "dummy_position",
        "message": "dummy message",
        "resume": "dummy_resume_link",
        "jobLink": "https://www.companyb.com/jobid/123",
        "createdAt": "2022-02-02T22:13:47.894901-05:00"
    }
]

Retrieve Post by Post Id

Retrieves a post based on the post id filter

Parameters

none

GET /api/posts/id/:id

curl http://localhost:5555/api/posts/id/:id

Response

Returns the JSON object for the post based on the post id

{
	"postId": 1,
	"userId": 1,
	"targetCompanyId": 2,
	"targetPosition": "Software Engineer",
	"message": "Message 1",
	"resume": "Resume 1",
	"jobLink": "https://www.companyb.com/jobid/123",
	"createdAt": "2022-02-02T22:13:47.894901-05:00"
}

Delete a Post

Deletes a post from database based on the post id filter

Parameters

none

DELETE /api/posts/:id

curl -X DELETE http://localhost:5555/api/posts/:id

Response

Returns the JSON object for the deleted post based on post id.

{
	"postId": 1,
	"userId": 1,
	"targetCompanyId": 2,
	"targetPosition": "Software Engineer",
	"message": "Message 1",
	"resume": "Resume 1",
	"jobLink": "https://www.companyb.com/jobid/123",
	"createdAt": "2022-02-02T22:13:47.894901-05:00"
}