Skip to content
This repository has been archived by the owner on Dec 2, 2022. It is now read-only.

Latest commit

 

History

History
321 lines (201 loc) · 7.22 KB

user.mdx

File metadata and controls

321 lines (201 loc) · 7.22 KB
sidebar_position
5

User

import ApiCodeBlock from '../../src/components/ApiCodeBlock'; import Highlight from '../../src/components/Highlight'; import ApiTryIt from '../../src/components/ApiTryIt';

export const endpoints = [ { method: 'GET', uri: '/v1/user/:id' }, { method: 'GET', uri: '/v1/user' }, { method: 'POST', uri: '/v1/user' }, { method: 'DELETE', uri: '/v1/user' } ];

This is an object representing an User. The API allows you to retrieve individual User as well as a list of them using various filters. Furthermore it lets you update and delete an User.

The User object

Attributes


id

Unique identifier for an User.


username

The User's username.


email

The User's email.

:::note

This field is obscured1 to not-authorized in order to avoid email adresses' collecting behaviours.

:::


email_verified

Indicates if the User has already confirmed their email.

:::note

This field is obscured1 to not-authorized.

:::


role

The User's role inside AniAPI.

"BASIC": 0,
"MODERATOR": 1,
"ADMINISTRATOR": 2

avatar

The User's avatar. This value is imported from external User's trackers.


gender

The User's gender.

"UNKNOWN": 0,
"MALE": 1,
"FEMALE": 2

localization

The User's preferred locale reference.

:::info

Check on Resource for further details on locales.

:::


has_anilist

Indicates if the User has linked their AniList account with AniAPI.


has_mal

Indicates if the User has linked their MyAnimeList account with AniAPI.


Example

{
  "username": "Dazorn",
  "role": 0,
  "gender": 1,
  "avatar": "https://s4.anilist.co/file/anilistcdn/user/avatar/large/b192651-setw7IgPvmZS.jpg",
  "id": 1
}

Retrieve a specific User

Retrieves an User, based on its unique identifier.

Parameters

No parameters.

Returns

Returns an obscured1 User object if a valid identifier was provided.

Try it

export const retrieveUserParams = [ { name: ':id', type: 'number', placeholder: ':id', value: '1' } ];

Get a list of User

Returns a list of obscured1 User objects. The Users are returned sorted by username, following alphabetical ascending order.

Parameters


username

A case-insensitive pattern filter on the list based on the username field value.


email

A case-sensitive filter on the list based on the email field value.


Returns

Returns an array of obscured1 User objects with a size based on the filter provided.

Try it

export const getListUserParams = [ { name: 'username', type: 'text', placeholder: 'username', value: 'Daz' }, { name: 'email', type: 'text', placeholder: 'email', value: '' } ];

Update an User

:::warning

We recommend you to not implement an User's update data form.

Instead, we strongly suggest you to redirect the User to the profile web page and to let us do the rest ♥.

:::

Updates an User based on the provided values.

Parameters


id

The User's id to update


password

The User's new password value.


gender

The User's gender value.


localization

The User's new localization value.


anilist_id

The User's AniList account external id.


anilist_token

The User's AniList account external token. This value becomes required when you provide the anilist_id field.


Returns

Returns the updated User object.

Example

fetch('https://api.aniapi.com/v1/user', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer <YOUR_JWT>',
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  },
  body: {
    id: 1,
    gender: 1,
    localization: 'it'
  }
});
{
  "status_code": 200,
  "message": "User updated",
  "data": {
    "username": "Dazorn",
    "role": 0,
    "gender": 1,
    "localization": "it",
    "has_anilist": true,
    "has_mal": false,
    "id": 1
  },
  "version": "1"
}

Delete an User

Deletes an User based on the provided unique identifier.

Parameters

No parameters.

Returns

No particular return.

Example

fetch('https://api.aniapi.com/v1/user/1', {
  method: 'DELETE',
  headers: {
    'Authorization': 'Bearer <YOUR_JWT>',
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  }
});
{
  "status_code": 200,
  "message": "User deleted",
  "data": "",
  "version": "1"
}

Footnotes

  1. An obscured object has certain fields hidden 2 3 4 5