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

Latest commit

 

History

History
379 lines (248 loc) · 8.97 KB

user_story.mdx

File metadata and controls

379 lines (248 loc) · 8.97 KB
sidebar_position
6

UserStory

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_story/:id' }, { method: 'GET', uri: '/v1/user_story' }, { method: 'PUT', uri: '/v1/user_story' }, { method: 'POST', uri: '/v1/user_story' }, { method: 'DELETE', uri: '/v1/user_story' } ];

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

UserStory is used to synchronize data between AniAPI and external Anime tracking systems.

The UserStory object

Attributes


id

Unique identifier for an UserStory.


user_id

User external unique identifier.


anime_id

Anime external unique identifier.


status

The UserStory's watching status.

"CURRENT": 0,
"PLANNING": 1,
"COMPLETED": 2,
"DROPPED": 3,
"PAUSED": 4,
"REPEATING": 5

current_episode

The UserStory's watching progress.


current_episode_ticks

The UserStory's current_episode watching time in milliseconds.


Example

{
  "user_id": 1,
  "anime_id": 10,
  "status": 2,
  "current_episode": 220,
  "current_episode_ticks": 0,
  "id": 27
}

Retrieve a specific UserStory

Retrieves an UserStory, based on its unique identifier.

Parameters

No parameters.

Returns

Returns an UserStory object if a valid identifier was provided and the authenticated User owns the rights to get it.

Try it

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

Get a list of UserStory

Returns a list of UserStory objects. The UserStories are returned sorted by creation_date, following descending order.

:::info

As default, it will return all the UserStories owned by the request's authenticated User using the user_id filter's field.

:::

Parameters


anime_id

A filter on the list based on the anime_id field value.


user_id

A filter on the list based on the user_id field value.


status

A filter on the list based on the status field value.


synced

A filter on the list based on the synced field value. synced field indicates if an UserStory has been synchronized with User's linked trackers.


Returns

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

Try it

export const getListUserStoryParams = [ { name: 'anime_id', type: 'number', placeholder: 'anime_id', value: '' }, { name: 'user_id', type: 'number', placeholder: 'user_id', value: '' }, { name: 'status', type: 'number', placeholder: 'status', value: '' }, { name: 'synced', type: 'checkbox', placeholder: 'synced', value: true }, ];

Create an UserStory

Creates an UserStory based on the provided values.

Parameters


user_id

The User's id that own the UserStory.


anime_id

The UserStory's Anime.


status

The UserStory's watching status.


current_episode

The UserStory's watching progress. Must be equal or less than the Anime's episodes_count value. When you provide a status equal to 1 or 2 this field is auto-calculated.


current_episode_ticks

The UserStory's current_episode watching time in milliseconds.


Returns

Returns the created UserStory object.

Example

fetch('https://api.aniapi.com/v1/user_story', {
  method: 'PUT',
  headers: {
    'Authorization': 'Bearer <YOUR_JWT>',
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  },
  body: {
    user_id: 1,
    anime_id: 10,
    status: 2
  }
});
{
  "status_code": 200,
  "message": "Story created",
  "data": {
    "user_id": 1,
    "anime_id": 10,
    "status": 2,
    "current_episode": 220,
    "current_episode_ticks": 0,
    "id": 1
  },
  "version": "1"
}

Update an UserStory

Updates an UserStory based on the provided values.

Parameters


id

The UserStory's unique identifier.


user_id

The User's id that owns the UserStory.


anime_id

The UserStory's Anime.


status

The UserStory's watching status.


current_episode

The UserStory's watching progress. Must be equal or less than the Anime's episodes_count value.


current_episode_ticks

The UserStory's current_episode watching time in milliseconds.


Returns

Returns the updated UserStory object.

Example

fetch('https://api.aniapi.com/v1/user_story', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer <YOUR_JWT>',
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  },
  body: {
    id: 27,
    user_id: 1,
    anime_id: 10,
    status: 0,
    current_episode: 140,
    current_episode_ticks: 1200000
  }
});
{
  "status_code": 200,
  "message": "Story updated",
  "data": {
    "user_id": 1,
    "anime_id": 10,
    "status": 0,
    "current_episode": 140,
    "current_episode_ticks": 1200000,
    "id": 27
  },
  "version": "1"
}

Delete an UserStory

Deletes an UserStory based on the provided unique identifier.

:::caution

You should use this endpoint only when the User has zero linked trackers. Otherwise the UserStory will get re-imported!

:::

Parameters

No parameters.

Returns

No particular return.

Example

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