API Documentation for Hillel demo project

Categories

GET
GET list of categories

Get list of categories

GET categories

cURL

curl -X GET "http://localhost:8081/api/categories?" \
     -H "Content-Type: application/json"

Response

[
  {
    "_id": "58a446fcc26aaf13460533bd",
    "name": "Work"
  }
]

POST
POST Add new category

Add new category to all users

POST categories

Optional parameters

Name /type

Description /example

Constraints

name
string

  • max length: 256

cURL

curl -X POST "http://localhost:8081/api/categories" \
     -H "Content-Type: application/json" \
     --data '{}'

Response

{
  "message": "Category created successful"
}

DELETE
DELETE category by id

Delete category for all users by id

DELETE categories/:identifier

cURL

curl -X DELETE "http://localhost:8081/api/categories/58a446fcc26aaf13460533bd" \
     -H "Content-Type: application/json" \
     --data '{}'

Response

{
  "message": "Category removed successful"
}

PhoneBook

GET
GET list of contacts

Get list of contacts with pagination and search

GET phonebook

Optional parameters

Name /type

Description /example

Constraints

page
number

Page number

1
  • default value: 1
  • min length: 1
  • max length: 256

limit
number

Limit per page

25
  • default value: 25
  • valid values: 25, 50, 100

sort
string

Sort field name

"name"
  • default value: name
  • valid values: "name", "surname", "phone", "addedAt"

sortValue
number

Sort value (asc|desc)

1
  • default value: 1
  • valid values: -1, 1

search
string

Full text search filter (name|surname|phone|email)

""
  • default value:
  • min length: 0
  • max length: 100

category
string

"58a446fcc26aaf13460533bd"
  • pattern: ^[0-9a-fA-F]{24}$

cURL

curl -X GET "http://localhost:8081/api/phonebook?page=1&limit=25&sort=name&sortValue=1&search=&category=58a446fcc26aaf13460533bd" \
     -H "Content-Type: application/json"

Response

[
  {
    "_id": "58a446fcc26aaf13460533bd",
    "name": "Yurii",
    "surname": "Chikhrai",
    "image": "/img/58a446fcc26aaf13460533bd/awerasef.jpg"
  }
]

POST
POST Add new contact

Add new contact to phonebook

POST phonebook

Optional parameters

Name /type

Description /example

Constraints

position
string

  • max length: 256

name
string

  • max length: 256

information
string

  • max length: 1024

phone
array

Array of phones with type

[ { "_id": "58a446fcc26aaf13460533bd", "category": "mobile", "value": "+38096*******" } ]
  • unique items
  • max length: 25

bornDate
string (date)

Contact birth date

"1992-10-19"

    surname
    string

    • max length: 256

    image
    string

    Image path

    • pattern: ^/img/[0-9a-fA-F]{24}/.{4,100}$

    email
    array

    Array of contact emails

    [ "y.chikhrai@shipnext.com" ]
    • unique items
    • max length: 25

    category
    string

    "58a446fcc26aaf13460533bd"
    • pattern: ^[0-9a-fA-F]{24}$

    cURL

    curl -X POST "http://localhost:8081/api/phonebook" \
         -H "Content-Type: application/json" \
         --data '{"email":["y.chikhrai@shipnext.com"],"phone":[{"_id":"58a446fcc26aaf13460533bd","category":"mobile","value":"+38096*******"}],"bornDate":"1992-10-19","category":"58a446fcc26aaf13460533bd"}'

    Response

    {
      "message": "Contact added successful",
      "id": "58a446fcc26aaf13460533bd"
    }

    GET
    GET full contact information by id

    Get full information about contact by id

    GET phonebook/:identifier

    cURL

    curl -X GET "http://localhost:8081/api/phonebook/58a446fcc26aaf13460533bd?" \
         -H "Content-Type: application/json"

    Response

    {
      "_id": "58a446fcc26aaf13460533bd",
      "name": "Yurii",
      "surname": "Chikhrai",
      "position": "NodeJS developer as ShipNEXT.com",
      "email": [
        "y.chikhrai@shipnext.com"
      ],
      "phone": [
        {
          "_id": "58a446fcc26aaf13460533bd",
          "category": "mobile",
          "value": "+38096*******"
        }
      ],
      "bornDate": "1992-10-19",
      "category": "58a446fcc26aaf13460533bd",
      "information": "Cool dude.",
      "image": "/img/58a446fcc26aaf13460533bd/awerasef.jpg",
      "addedAt": "2018-04-06T18:18:44.602Z",
      "addedBy": "58a446fcc26aaf13460533bd"
    }

    PUT
    PUT modification inside contact

    Update contact information

    PUT phonebook/:identifier

    Optional parameters

    Name /type

    Description /example

    Constraints

    position
    string

    • max length: 256

    name
    string

    • max length: 256

    information
    string

    • max length: 1024

    phone
    array

    Array of phones with type

    [ { "_id": "58a446fcc26aaf13460533bd", "category": "mobile", "value": "+38096*******" } ]
    • unique items
    • max length: 25

    bornDate
    string (date)

    Contact birth date

    "1992-10-19"

      surname
      string

      • max length: 256

      image
      string

      Image path

      • pattern: ^/img/[0-9a-fA-F]{24}/.{4,100}$

      email
      array

      Array of contact emails

      [ "y.chikhrai@shipnext.com" ]
      • unique items
      • max length: 25

      category
      string

      "58a446fcc26aaf13460533bd"
      • pattern: ^[0-9a-fA-F]{24}$

      cURL

      curl -X PUT "http://localhost:8081/api/phonebook/58a446fcc26aaf13460533bd" \
           -H "Content-Type: application/json" \
           --data '{"email":["y.chikhrai@shipnext.com"],"phone":[{"_id":"58a446fcc26aaf13460533bd","category":"mobile","value":"+38096*******"}],"bornDate":"1992-10-19","category":"58a446fcc26aaf13460533bd"}'

      Response

      {
        "_id": "58a446fcc26aaf13460533bd",
        "name": "Yurii",
        "surname": "Chikhrai",
        "position": "NodeJS developer as ShipNEXT.com",
        "email": [
          "y.chikhrai@shipnext.com"
        ],
        "phone": [
          {
            "_id": "58a446fcc26aaf13460533bd",
            "category": "mobile",
            "value": "+38096*******"
          }
        ],
        "bornDate": "1992-10-19",
        "category": "58a446fcc26aaf13460533bd",
        "information": "Cool dude.",
        "image": "/img/58a446fcc26aaf13460533bd/awerasef.jpg",
        "addedAt": "2018-04-06T18:18:44.602Z",
        "addedBy": "58a446fcc26aaf13460533bd"
      }

      DELETE
      DELETE contact by id

      Delete full information about contact by id

      DELETE phonebook/:identifier

      cURL

      curl -X DELETE "http://localhost:8081/api/phonebook/58a446fcc26aaf13460533bd" \
           -H "Content-Type: application/json" \
           --data '{}'

      Response

      {
        "message": "Contact deleted successful"
      }

      Users

      POST
      POST Log in into system

      Log in into system. Response with header 'set-cookie'. Authorization work on cookie-sessions.

      POST users/login

      Optional parameters

      Name /type

      Description /example

      Constraints

      email
      string (email)

      User email

      "y.chikhrai@shipnext.com"
      • min length: 4
      • max length: 70

      password
      string

      User password

      "*******"
      • min length: 4
      • max length: 256

      cURL

      curl -X POST "http://localhost:8081/api/users/login" \
           -H "Content-Type: application/json" \
           --data '{"email":"y.chikhrai@shipnext.com","password":"*******"}'

      Response

      {
        "message": "Log in successful"
      }

      POST
      POST Register into system

      Register into system. Response with header 'set-cookie'. Authorization work on cookie-sessions.

      POST users/register

      Optional parameters

      Name /type

      Description /example

      Constraints

      email
      string (email)

      User email

      "y.chikhrai@shipnext.com"
      • min length: 4
      • max length: 70

      password
      string

      User password

      "*******"
      • min length: 4
      • max length: 256

      name
      string

      User name

      "Yurii"
      • min length: 2
      • max length: 256

      surname
      string

      User surname

      "Chikhrai"
      • min length: 2
      • max length: 256

      cURL

      curl -X POST "http://localhost:8081/api/users/register" \
           -H "Content-Type: application/json" \
           --data '{"email":"y.chikhrai@shipnext.com","password":"*******","name":"Yurii","surname":"Chikhrai"}'

      Response

      {
        "message": "Register successful"
      }