Skip to content

Latest commit

 

History

History
161 lines (125 loc) · 4.6 KB

v1.apibp.md

File metadata and controls

161 lines (125 loc) · 4.6 KB

FORMAT: 1A

User API

User API Creates, Deletes, Updates, Searches HashtagSell users

Group Version

The version resource is useful for retrieving status and uptime as well as current version for the postings API

Version [/v1/version]

User API version information.

Get API version [GET]

  • Response 200 (application/json)

    • Body

        {
          "name": "hashtagsell-user-api",
          "version": "0.1.0",
          "memory": {
            "free": "63 MB",
            "total": "8.59 GB"
          },
          "os": {
            "arch": "x64",
            "hostname": "NewBradBookPro.local"
          },
          "uptime": "10 seconds"
        }
      

Group Authentication

The auth resources will create new users and login existing users.

Register a new user [/v1/auth/register]

Register a new user with system. Does not create new user if email already in system.

Register [POST]

To create a user, send JSON with the appropriate values

  • Request (application/json)

          {
              "email": "brad@domain.com",
              "isAdmin" : "true", //defaults to false
              "password" : "password",
              "phone" : "123-456-7891" //optional
              "firstName" : "Brad",
              "lastName" : "Davis"
          }
    
  • Response 201

          {
              "__v": 0,
              "email": "brad@domain.com",
              "isAdmin": true,
              "firstName": "Brad",
              "lastName": "Davis",
              "phone": "123-456-7891",
              "userId": "9d62c28604644275b905b6980c0732da",  //handled by api
              "modifiedAt": "2015-07-27T18:58:39.249Z",  //handled by api
              "createdAt": "2015-07-27T18:58:39.249Z",  //handled by api
              "iat": 1438023549,  //Issue At Time
              "exp": 1438109949,  //Token expiration, default is 24 hours
              "token": "eyJ0eXAiOiJKV1QiL....3m6r_9DkA6lozE" //token should be stored by client
          }
    

Login a new user [/v1/auth/login]

Logs in user with their username and password. Returns a token that must be used in all subsequent queries thereafter.

Login [POST]

To login a user, send JSON with the appropriate values. The token returned must be included in all subsequent requests thereafter to make full use of APIs (see exampled DELETE user).

  • Request (application/json)

          {
              "email": "brad@domain.com",
              "password" : "password"
          }
    
  • Response 200

          {
              "__v": 0,
              "email": "brad@domain.com",
              "isAdmin": true,
              "firstName": "Brad",
              "lastName": "Davis",
              "phone": "123-456-7891",
              "userId": "9d62c28604644275b905b6980c0732da",  //handled by api
              "modifiedAt": "2015-07-27T18:58:39.249Z",  //handled by api
              "createdAt": "2015-07-27T18:58:39.249Z",  //handled by api
              "iat": 1438023549,  //Issue At Time
              "exp": 1438109949,  //Token expiration, default is 24 hours
              "token": "eyJ0eXAiOiJKV1QiL....3m6r_9DkA6lozE" //token should be stored by client
          }
    

Group Users

The user resources will update a user, delete a user, and search for a user/users. All resources here are protected and require a valid user token.

User Collection [/v1/users/]

Create, login, and delete a user

  • Model (application/json)

    • Body

          {
            userId : {
              index: true,
              required: true,
              type: String
            },
            firstName : {
              required : false,
              type : String
            },
            lastName : {
              required : false,
              type : String
            },
            email : {
              index : true,
              required : true,
              type : String
            },
            password : {
              required : true,
              type: String
            },
            phone: {
              required: false,
              type: String
            },
            isAdmin : {
              required : true,
              type : Boolean
            }
          }
      

Delete a user [DELETE]

  • Request (application/json)

    • Headers

          x-access-token: token here
      
    • Body

          {
              "email":"brad@domain.com",
              "token" : "token here"
          }
      
  • Response 204