Category

Authentication

  • HTTP Authentication, scheme: bearer

Category

Create category

Code samples

const data = JSON.stringify({
  name: 'Shoes',
  parentId: '17a54659-a06a-464f-a914-190cee7d4b1a',
});

const xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener('readystatechange', function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open('POST', 'https://fakestoreapi.ru/category');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('Authorization', 'Bearer {access-token}');

xhr.send(data);

POST /category

Body parameter

Parameters

Name
In
Type
Required
Description

body

body

true

none

Responses

Status
Meaning
Description
Schema

201

Category created

None

5XX

Unknown

Server error

None

4XX

Unknown

Check response message

None

To perform this operation, you must be authenticated by means of one of the following methods: bearer

Get root categories

Code samples

GET /category

Parameters

Name
In
Type
Required
Description

l

query

number

false

Items limit on page ( from 1 to 50 )

p

query

number

false

Items page ( min 1 )

Example responses

200 Response

Responses

Status
Meaning
Description
Schema

200

Root categories received

5XX

Unknown

Server error

None

4XX

Unknown

Check response message

None

This operation does not require authentication

Get subcategories

Code samples

GET /category/{id}/children

Parameters

Name
In
Type
Required
Description

id

path

string

true

Parent category id

all

query

boolean

false

Retrieve all subcategories at all levels, or just the current one.

Example responses

200 Response

Responses

Status
Meaning
Description
Schema

200

Subcategories received

Inline

5XX

Unknown

Server error

None

4XX

Unknown

Check response message

None

Response Schema

Status Code 200

Name
Type
Required
Restrictions
Description

anonymous

false

none

none

» _uuid

string

true

none

Category id

» name

string

true

none

Category name

» Childrens

false

none

Field for retrieve subcategories at all level

» hasChildren

boolean

false

none

Is category has children

» hasProduct

boolean

false

none

Is category has product

This operation does not require authentication

Update category

Code samples

PATCH /category/{id}

Body parameter

Parameters

Name
In
Type
Required
Description

id

path

string

true

Category id

body

body

true

none

Responses

Status
Meaning
Description
Schema

200

Category updated

None

5XX

Unknown

Server error

None

4XX

Unknown

Check response message

None

To perform this operation, you must be authenticated by means of one of the following methods: bearer

Remove category by id

Code samples

DELETE /category/{id}

Parameters

Name
In
Type
Required
Description

id

path

string

true

Category id

all

query

boolean

true

none

Responses

Status
Meaning
Description
Schema

200

Category deleted

None

5XX

Unknown

Server error

None

4XX

Unknown

Check response message

None

To perform this operation, you must be authenticated by means of one of the following methods: bearer

Last updated