Back to top

Esportsinsight - API Documentation

DB Schemas

This section inherently shows what kind of scheme in we store each entity. Data validation between frontend & backend may vary and described in API section.

Based on Joi’s validation. API reference

User

{
  "_id": Joi.objectId().required(),
  "username": Joi.string().min(5).required(),
  "email": Joi.string().email().optional(),
  "password": Joi.string().min(5).required(),
  "accessToken": Joi.objectId(),
  "recoveryHash": Joi.string().length(25),
  "socialProviders": Joi.array().optional()
}
{
  "socialProviders": [{
    "provider": "Steam",
    "data": {
      "steamId": ""
    },
  }]
}

Accesstoken

{
  "_id": Joi.objectId().required(),
  "userId": Joi.objectId.required(),
  "issuedAt": Joi.date().required(),
  "expiresAt": Joi.date().required(),
  "rawToken": Joi.string().required()
}

Authentication

Basic

Basic
POST/v1/auth/basic

  • username (required)

  • password (required)

Example URI

POST /v1/auth/basic
Request
HideShow
Headers
Content-Type: application/json
Body
{
  "username": "bali",
  "password": "1234",
}
Response  200
HideShow
Body
{
  "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ",
}
Response  400
HideShow

Request’s in bad format. (missing key or value - ex: username)

Body
{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "child \"username\" fails because [\"username\" must be a valid email]",
  "validation": {
    "source": "payload",
    "keys": [
      "username"
    ]
  }
}
Response  401
HideShow

Request’s in good format yet they’re bad credentials.

Body
{
  "payload": {
    "statusCode": 401,
    "error": "Unauthorized",
    "message": "invalid credentials"
  },
  "headers" {}
}

Steam

Steam
POST/v1/auth/steam

Example URI

POST /v1/auth/steam
Request
HideShow
  • steamId (required)

  • username (optional) - backend generates if empty

  • email (optional)

  • password (optional)

Body
{
  "steamId": "",
}
Response  200
HideShow
Body
{
  "accessToken": "",
}
Response  400
HideShow

Submitted data’s invalid.

Body
{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "child \"steamId\" fails because [\"steamId\" must be a valid steamId]",
  "validation": {
    "source": "payload",
    "keys": [
      "steamId"
    ]
  }
}
Response  409
HideShow

username, email or steamId is/are already taken.

Body
{
  "statusCode": 409,
  "error": "Conflict",
  "message": "there was a conflict",
  "data": {
    "keys": ['username', 'email']
  }
}
Response  401
HideShow

steamId is invalid.

Body
{
  "payload": {
    "statusCode": 401,
    "error": "Unauthorized",
    "message": "invalid steamid"
},
"headers" {}
}

API

User

Get info
GET/user

Example URI

GET /user
Request
HideShow
Headers
Content-Type: application/json
Authorization: Bearer 'token'
Body
{}
Response  200
HideShow
Body
{}

Change username
PUT/user/name

Example URI

PUT /user/name

Change email
PUT/user/email

Example URI

PUT /user/email

Change password
PUT/user/password

Example URI

PUT /user/password

Recover account
POST/user/recover_account

Example URI

POST /user/recover_account

Users

Find
GET/users?name={name}

Example URI

GET /users?name=bali
URI Parameters
HideShow
name
string (optional) Default: * Example: bali

Username.

Response  200
HideShow

If not found comes with empty array without user object

Body
[
  {
    "name": ""
  }
]

Create new
POST/users

Example URI

POST /users
Request
HideShow
  • username (required)

  • password (required)

  • email (optional)

Headers
Content-Type: application/json
Body
{
  "username": "",
  "password": "",
  "email": "",
}
Response  200
HideShow
Body
{}

Reviews

Generated by aglio on 01 May 2017