SamuraiJS Social Network API documentation version 1.0.0
https://social-network.samuraijs.com/api/1.0
Here you can get beta API documentation https://docs.google.com/document/d/1ZSXmTzkgq_Kj1VbWuq8fTv_DPD95GFDvPZgqFeIYGoM/edit#
SamuraiJS Social Network
This is a Social-Network Server API. You can find out more about this API at https://social-network.samuraijs.com/docs
/security
Security workflow
/auth
Is current user authorized
get /auth/me
Is current user authorized
HTTP status code 200
successful operation
Headers
- Content-Type: required(application/json)
Body
Media type: application/json
Type: object
Properties- data: required(object)
if user is authenticated then data contains all this properties
- id: required(number)
logged user id
- email: required(string)
logged user email
- login: required(string)
user login
- id: required(number)
- resultCode: required(number)
(0 if opearation completed successfullt, other numbers - some error occured)
- messages: required(array of string)
is empty if resultCode is 0, contains error messages if resultCode is different from 0
Example:
{
resultCode: 0
messages: [],
data: {
id: 2,
email: 'blabla@bla.bla',
login: 'samurai'
}
}
Authorize on the service
Unfollow requested user
post /auth/login
Authorize on the service
Body
Media type: application/json
Type: object
Properties- email: required(string)
valid confirmed user email address, which used during registration
- password: required(string)
valid user password
- rememberMe: (boolean)
if true, then session will not be expired after session finishing
- captcha: (boolean)
text from captcha-image that should be added if there is resultCode is 10 in response data.
HTTP status code 200
successful operation
Headers
- Content-Type: required(application/json)
Body
Media type: application/json
Type: object
Properties- resultCode: required(number)
(0 if opearation completed successfullt, other numbers - some error occured)
- messages: required(array of string)
is empty if resultCode is 0, contains error messages if resultCode is different from 0
- data: required(object)
some additional data
Example:
{
resultCode: 0
messages: [],
data: {
userId: 2
}
}
delete /auth/login
Unfollow requested user
HTTP status code 200
Body
Media type: application/json
Type: object
Properties- resultCode: required(number)
(0 if opearation completed successfullt, other numbers - some error occured)
- messages: required(array of string)
is empty if resultCode is 0, contains error messages if resultCode is different from 0
- data: required(object)
some additional data
Example:
{
resultCode: 1
messages: ['Something wrong'],
data: {}
}
/users
Returns all (or only filtered by name with term parameter) users splitted by page
get /users
Returns all (or only filtered by name with term parameter) users splitted by page
Query Parameters
- count: (integer - default: 10 - maximum: 100)
page size (how many items will be returned in response)
- page: (integer - default: 1)
number of portion of items
- term: (string)
user name string for searching
- friend: (boolean)
if true, then find only followed users, false - only not followed users, if omit parameter - all users
HTTP status code 200
successful operation
Headers
- Content-Type: required(application/json)
Body
Media type: application/json
Type: object
Properties- items: required(array of User)
Items: User
- id: required(integer)
- name: required(string)
- status: (string)
Ccurrent small text user status
Example:
Hi! i am React JS Junior developer and I am looking for a job
- photos: required(object)
- small: (string)
URL address of user photo (small size) (null if photo is not uploaded to the server)
- large: (string)
URL address of user photo (large size) (null if photo is not uploaded to the server)
- small: (string)
- followed: required(boolean)
Is current authorized user following returned user. If current user is anonymous then value always will be false
- totalCount: (integer)
total amount of registered users matching criteria
- error: (string)
if result can't be returned this field will contain error message
Example:
{
"items": [
{
"name": "Shubert",
"id": 1,
"photos": {
"small": null,
"large": null
},
"status": null,
"followed": false
},
{
"name": "Hacker",
"id": 2,
"photos": {
"small": null,
"large": null
},
"status": null,
"followed": false
}
],
"totalCount": 30,
"error": null
}
/profile
put /profile
Body
Media type: application/json
Type: object
Properties- userId: required(integer)
- lookingForAJob: required(boolean)
- lookingForAJobDescription: required(string)
- fullName: required(string)
- contacts: required(object)
- github: required(string)
- vk: required(string)
- facebook: required(string)
- instagram: required(string)
- twitter: required(string)
- website: required(string)
- youtube: required(string)
- mainLink: required(string)
HTTP status code 200
Body
Media type: application/json
Type: object
Properties- resultCode: required(number)
(0 if opearation completed successfullt, other numbers - some error occured)
- messages: required(array of string)
is empty if resultCode is 0, contains error messages if resultCode is different from 0
- data: required(object)
some additional data
Example:
{
resultCode: 1
messages: ['Something wrong'],
data: {}
}
put /profile
Body
Media type: application/json
Type: object
Properties- userId: required(integer)
- lookingForAJob: required(boolean)
- lookingForAJobDescription: required(string)
- fullName: required(string)
- contacts: required(object)
- github: required(string)
- vk: required(string)
- facebook: required(string)
- instagram: required(string)
- twitter: required(string)
- website: required(string)
- youtube: required(string)
- mainLink: required(string)
HTTP status code 200
Body
Media type: application/json
Type: object
Properties- resultCode: required(number)
(0 if opearation completed successfullt, other numbers - some error occured)
- messages: required(array of string)
is empty if resultCode is 0, contains error messages if resultCode is different from 0
- data: required(object)
some additional data
Example:
{
resultCode: 1
messages: ['Something wrong'],
data: {}
}
put /profile/photo
Body
Media type: multipart/form-data
Type: object
Properties- image: required(file)
HTTP status code 200
Body
Media type: application/json
Type: object
Properties- data: required(object)
some additional data
- small: (string)
URL address of user photo (small size) (null if photo is not uploaded to the server)
- large: (string)
URL address of user photo (large size) (null if photo is not uploaded to the server)
- small: (string)
- resultCode: required(number)
(0 if opearation completed successfullt, other numbers - some error occured)
- messages: required(array of string)
is empty if resultCode is 0, contains error messages if resultCode is different from 0
Example:
{
resultCode: 1
messages: ['Something wrong'],
data: {}
}
put /profile/photo
Body
Media type: multipart/form-data
Type: object
Properties- image: required(file)
HTTP status code 200
Body
Media type: application/json
Type: object
Properties- data: required(object)
if photo updated then photos urls will be returned
- photos: required(object)
- small: (string)
URL address of user photo (small size) (null if photo is not uploaded to the server)
- large: (string)
URL address of user photo (large size) (null if photo is not uploaded to the server)
- small: (string)
- photos: required(object)
- resultCode: required(number)
(0 if opearation completed successfullt, other numbers - some error occured)
- messages: required(array of string)
is empty if resultCode is 0, contains error messages if resultCode is different from 0
Example:
{
resultCode: 1
messages: ['Something wrong'],
data: {}
}
Update status for current authorized user
put /profile/status
Body
Media type: application/json
Type: object
Properties- status: required(string - maxLength: 300)
HTTP status code 200
Body
Media type: application/json
Type: object
Properties- resultCode: required(number)
(0 if opearation completed successfullt, other numbers - some error occured)
- messages: required(array of string)
is empty if resultCode is 0, contains error messages if resultCode is different from 0
- data: required(object)
some additional data
Example:
{
resultCode: 1
messages: ['Something wrong'],
data: {}
}
Returns text status of requested user
Returns user profile information
get /profile/{userId}
URI Parameters
- userId: required(integer)
HTTP status code 200
successful operation
Headers
- Content-Type: required(application/json)
Body
Media type: application/json
Type: object
Properties- userId: required(integer)
- lookingForAJob: required(boolean)
- lookingForAJobDescription: required(string)
- fullName: required(string)
- contacts: required(object)
- github: required(string)
- vk: required(string)
- facebook: required(string)
- instagram: required(string)
- twitter: required(string)
- website: required(string)
- youtube: required(string)
- mainLink: required(string)
- photos: required(object)
- small: (string)
URL address of user photo (small size) (null if photo is not uploaded to the server)
- large: (string)
URL address of user photo (large size) (null if photo is not uploaded to the server)
- small: (string)
/follow
Is current user follower for requested user
Follow requested user
Unfollow requested user
post /follow/{userId}
Follow requested user
URI Parameters
- userId: required(integer)
HTTP status code 200
Body
Media type: application/json
Type: object
Properties- resultCode: required(number)
(0 if opearation completed successfullt, other numbers - some error occured)
- messages: required(array of string)
is empty if resultCode is 0, contains error messages if resultCode is different from 0
- data: required(object)
some additional data
Example:
{
resultCode: 1
messages: ['Something wrong'],
data: {}
}
delete /follow/{userId}
Unfollow requested user
URI Parameters
- userId: required(integer)
HTTP status code 200
Body
Media type: application/json
Type: object
Properties- resultCode: required(number)
(0 if opearation completed successfullt, other numbers - some error occured)
- messages: required(array of string)
is empty if resultCode is 0, contains error messages if resultCode is different from 0
- data: required(object)
some additional data
Example:
{
resultCode: 1
messages: ['Something wrong'],
data: {}
}