User | Create a new User
In this case "apiErrorStructure" is defined and used. Define blocks with params that will be used in several functions, so you dont have to rewrite them.
post
//api.example.com/user
Permission:
none
Request Body
Field
Type
Description
age
required
Number
Age of the User
name
required
String
Name of the User
Default value: Caroline
extraInfo.hireDate
required
Date
Date when user was hired
extraInfo.hireDateWithDefault
required
Date
Date when user was hired with default
Default value: 2021-09-01
extraInfo.nickname
required
String
Nickname of the user
extraInfo.isVegan
required
Boolean
Is the user vegan? (boolean with default)
Default value: true
extraInfo.isAlive
required
Boolean
Is the user alive? (boolean with no default)
extraInfo.secrets.crush
required
String
The user secret crush
extraInfo.secrets.hair
required
Number
Number of hair of user
Default value: 1000
Success 200
Field
Type
Description
id
required
Number
The new Users-ID.
Error 4xx
Name
Description
NoAccessRight
required
Only authenticated Admins can access the data.
UserNameTooShort
required
Minimum of 5 characters required.
HTTP/1.1 400 Bad Request
{
"error" : "UserNameTooShort"
}
User | Create a User
In this case "apiErrorStructure" is defined and used. Define blocks with params that will be used in several functions, so you dont have to rewrite them.
post
//api.example.com/user
Permission:
none
Parameter
Field
Type
Description
name
required
String
Name of the User.
Success 200
Field
Type
Description
id
required
String
The Users-ID.
Error 4xx
Name
Description
NoAccessRight
required
Only authenticated Admins can access the data.
UserNameTooShort
required
Minimum of 5 characters required.
HTTP/1.1 400 Bad Request
{
"error" : "UserNameTooShort"
}
Send a Sample Request
Parameters
User | Read data of a User
Compare version 0.3.0 with 0.2.0 and you will see the green markers with new items in version 0.3.0 and red markers with removed items since 0.2.0.
get
//api.example.com/user/:region/:id/:opt
Permission:
admin:computer
curl -H "Authorization: token 5f048fe" -i https://api.example.com/user/fr-par/4711
curl -H "Authorization: token 5f048fe" -H "X-Apidoc-Cool-Factor: superbig" -i https://api.example.com/user/de-ber/1337/yep
const client = AcmeCorpApi ( '5f048fe' ) ;
const user = client. getUser ( 42 ) ;
client = AcmeCorpApi. Client( token= "5f048fe" )
user = client. get_user( 42 )
Header
Field
Type
Description
Authorization
required
String
The token can be generated from your user profile.
X-Apidoc-Cool-Factor
required
String
Some other header with a default value.
Default value: big
Parameter
Field
Type
Description
id
required
Number
User unique ID
region
required
String
User region
Default value: fr-par
opt
optional
String
An optional param
Success 200
Field
Type
Description
id
required
Number
The Users-ID.
registered
required
Date
Registration Date.
name
required
String
Fullname of the User.
nicknames
required
String[]
List of Users nicknames (Array of Strings).
profile
required
Object
Profile data (example for an Object)
age
required
Number
Users age.
image
required
String
Avatar-Image.
options
required
Object[]
List of Users options (Array of Objects).
name
required
String
Option Name.
value
required
String
Option Value.
Error 4xx
Name
Description
NoAccessRight
required
Only authenticated Admins can access the data.
UserNotFound
required
The id
of the User was not found.
500 Internal Server Error
Name
Description
InternalServerError
required
The server encountered an internal error
HTTP/1.1 401 Not Authenticated
{
"error" : "NoAccessRight"
}
Send a Sample Request
Headers
Parameters
User | Read data of a User
Here you can describe the function. Multilines are possible.
get
//api.example.com/user/:id
Permission:
admin
Parameter
Field
Type
Description
id
required
String
The Users-ID.
Success 200
Field
Type
Description
id
required
String
The Users-ID.
name
required
Date
Fullname of the User.
Error 4xx
Name
Description
UserNotFound
required
The id
of the User was not found.
Send a Sample Request
Parameters
User | Read data of a User
Here you can describe the function. Multilines are possible.
get
//api.example.com/user/:id
Permission:
admin
Parameter
Field
Type
Description
id
required
String
The Users-ID.
Success 200
Field
Type
Description
id
required
String
The Users-ID.
name
required
Date
Fullname of the User.
Error 4xx
Name
Description
UserNotFound
required
The error description text in version 0.1.0.
Send a Sample Request
Parameters
User | Change a User
This function has same errors like POST /user, but errors not defined again, they were included with "apiErrorStructure"
put
//api.example.com/user/:id
Permission:
none
Parameter
Field
Type
Description
id
required
Number
id
of the user.
Request Body
Field
Type
Description
name
required
String
Name of the User.
avatar
required
File
Upload avatar.
Error 4xx
Name
Description
NoAccessRight
required
Only authenticated Admins can access the data.
UserNameTooShort
required
Minimum of 5 characters required.
HTTP/1.1 400 Bad Request
{
"error" : "UserNameTooShort"
}
Send a Sample Request
Parameters
Body
Content-Type
json
form-data
User | Delete user
Be careful! This will remove all the data associated with that user!
delete
//api.example.com/user/:id
Permission:
admin
curl -X DELETE -H "Authorization: token 5f048fe" -i https://api.example.com/user/4711
const client = AcmeCorpApi ( '5f048fe' ) ;
const user = client. deleteUser ( 42 ) ;
client = AcmeCorpApi. Client( token= "5f048fe" )
user = client. delete_user( 42 )
Header
Field
Type
Description
Authorization
required
String
The token can be generated from your user profile.
Parameter
Field
Type
Description
id
required
Number
id
of the user.
Success 200
Field
Type
Description
result
required
String
ok
if everything went fine.
nullableField
optional
String
This response field is not always there (can be null).
HTTP/1.1 200 OK
{
"result" : "ok"
}
Error 4xx
Name
Description
NoAccessRight
required
Only authenticated Admins can access the data.
UserNotFound
required
The id
of the User was not found.
500 Internal Server Error
Name
Description
InternalServerError
required
The server encountered an internal error.
HTTP/1.1 401 Not Authenticated
{
"error" : "NoAccessRight"
}
Send a Sample Request
Headers
Parameters
User | Thank a user: this is quite a long name indeed
This is here to have a long name in the left menu.
post
//api.example.com/user/:id