Skip to content
Denis Kalinochkin edited this page Feb 23, 2021 · 16 revisions

Import

from otvetmailru import models

Everything described in this document lies in models.

Enums

class QuestionState(Enum)

State of a question.

open = 'A': the question was asked recently.

vote = 'V': the author hadn't picked the best answer for some time, and now voting for the best answer is open.

resolved = 'R': the best answer has been picked.

class PollType(Enum)

Type of a poll.

none = '': question without a poll. Casts to bool as false.

single = 'S': poll with single choice.

multiple = 'm': poll with multiple choice.

class ThankStatus(Enum)

How the question author marked an answer to it.

none = 0: no reaction. Casts to bool as false.

liked = 1: the answer was thanked.

hidden = -1: the answer was marked as useless.

class CommentType(Enum)

Type of a comment.

question = 'Q': comment to a poll.

answer = 'A': comment to an answer.

class RatingType(Enum)

Type of user rating.

points = 'points': rating by points.

answer_count = 'anscnt': rating by answer count.

best_answer_count = 'bestanscnt': rating by best answer count.

class BrandAnswerStatus(Enum)

If the question has a brand answer or is waiting for one.

none = 0: no brand answer.

waiting = 1: waiting for brand answer.

answered = 2: has a brand answer.

class AbuseReason

Options for reason argument in report_* methods. Custom reasons are also allowed.

spam: report for spam.

insult: report for offensive language.

change_category: question is in a wrong category.

Dataclasses

Questions

class BaseQuestion

Base class for all question representations. Compares with other questions (== and !=) by question id.

id: int: question id.

title: str: question title.

category: Category: question category.

url: str: question url on the website.

class SimpleQuestion(BaseQuestion)

Used only as base class.

state: QuestionState: state of the question.

age_seconds: int: how many seconds ago the question was asked.

is_leader: bool: whether this is a leader question.

poll_type: PollType: type of a poll in the question.

answer_count: int: number of answers.

class QuestionPreview(SimpleQuestion)

Question card on the main page or a category page.

author: UserPreview: question author.

class BestQuestionPreview(QuestionPreview)

Question card on the best question list.

can_like: bool: if the question can be liked by the authenticated user.

like_count: int: current number of likes.

class UserQuestionPreview(SimpleQuestion)

Question card on a user page.

is_hidden: bool: whether the question was hidden. A user can see only their own hidden questions.

class IncompleteQuestion(SimpleQuestion)

Question on the answer page.

author: User: question author.

best_answer: Optional[Answer]: best answer, if selected.

can_choose_best_answer: bool: whether the authenticated user can choose the best answer in the question.

liked_by: List[SmallUserPreview]: users who liked the question (maybe not all of them, use iterate_question_likes to get all).

like_count: int: total like count.

additions: List[QuestionAddition]: additions to the question.

comments: Optional[List[Comment]]: poll comments, if the question is a poll, maybe not all of them. Use get_comments to get all.

comment_count: int: number of comments.

answers: List[Answer]: answers to the question (maybe not all of them, user iterate_answers to get all).

can_comment: bool: whether the authenticated user can comment the question or answers to it.

can_like: bool: whether the authenticated user can like the question.

can_answer: bool: whether the authenticated user can answer the question, vote in the poll or vote for a best answer.

cannot_answer_reason: Optional[str]: the reason why can_answer is false, as returned by the API.

text: str: question text.

is_hidden: bool: whether the question was hidden.

is_watching: bool: whether the authenticated user is receiving notifications about new answers to the question.

poll: Optional[Poll]: poll object.

deleted_by_id: Optional[int]: an id of the user who deleted the question, as returned by the API.

can_recommend_to_golden: bool: whether the authenticated user can recommend this question to the golden category.

edit_token: Optional[str]: token required to edit the question.

brand_answer_status: BrandAnswerStatus: whether the question has a brand answer or is waiting for it.

class Question(IncompleteQuestion)

Question page.

best_answer_vote_count: int: total number of votes for a best answer (when the question is in voting state).

can_edit: bool: whether the authenticated user can edit the question.

can_add: bool: whether the authenticated user can make an addition to the question.

created_at: datetime.datetime: when the question was created.

class MinimalQuestionPreview(SimpleQuestion)

Small question card, used for a list of questions watched by a user.

author: MinimalUserPreview: question author.

class QuestionSearchResult(BaseQuestion)

Question card in search.

text: str: question text.

answer_count: int: number of answers.

state: QuestionState: state of the question.

is_poll: bool: whether the question is a poll.

created_at: datetime.datetime: when the question was created.

age_seconds: int: how many seconds ago the question was asked.

author: MinimalUserPreview: question author.

class SimilarQuestionSearchResult(BaseQuestion)

An item in similar questions list.

Users

class BaseUser

Base class for all user representations. Compares with other users (== and !=) by user id.

id: int: user id.

name: str: name of the user.

avatar: Avatar: avatar of the user.

url: str: user profile url on the website.

class SmallUserPreview(BaseUser)

Small user card, used in likes list, followers list and such.

rate: Rate: user level.

class BrandSmallUserPreview(SmallUserPreview)

SmallUserPreview for brand experts.

brand_id: int: brand id.

brand_description: str: description of the brand.

class CommentUserPreview(SmallUserPreview)

User representation from a comment.

points: int: number of points of the user.

class BrandCommentUserPreview(CommentUserPreview)

CommentUserPreview for brand experts.

brand: Brand: expert's brand.

role: str: role of the expert in the brand.

class PollUserPreview(SmallUserPreview)

User representation for poll votes.

email: str: email of the user.

class UserPreview(BaseUser)

User representation from a question card.

is_vip: bool: whether this is a vip user.

kpd: float: user kpd (percentage of their answers marked as best).

about: str: user description from their profile.

is_expert: bool: whether the user is an expert in some categories.

class User(UserPreview)

User representation from a question page or an answer.

points: int: number of points of the user.

rate: Rate: user level.

class BrandUser(User)

User for brand experts.

brand: Brand: expert's brand.

role: str: role of the expert in the brand.

class UserInRating(User)

User in user rating.

rating_type: RatingType: type of a rating where the user was taken from.

rating_points: int: score (points, answers or best answers) in the corresponding rating.

class UserProfile(User)

User profile.

is_banned: bool: is the user banned.

is_followed_by_me: bool: is the authenticated user following this one.

is_hidden: bool: is this profile hidden by the owner.

place: int: place in rating by points.

answer_count: int: number of answers given by the user.

best_answer_count: int: number of best answers given by the user.

deleted_answer_count: int: number of deleted answers.

question_count: int: number of questions asked by the user.

open_question_count: int: number of open questions.

voting_question_count: int: number of questions in the voting state.

resolved_question_count: int: number of resolved questions.

blacklisted_count: int: size of the user's blacklist.

followers_count: int: number of followers.

following_count: int: number of users followed by the profile owner.

week_points: int: number of points earned this week.

class BrandExpertProfile(UserProfile)

Profile of brand expert.

categories: List[Category]: categories in which this expert is an expert.

brand: BrandBadge: brand of the expert.

role: str: role of the expert in the brand.

class MyUserProfile(UserProfile)

Profile of the authenticated user, has a few extra fields.

watching_question_count: int: number of questions watched.

direct_question_count: int: number of direct questions asked.

removed_question_count: int: number of removed questions.

banned_until: Optional[datetime.datetime]: when the current ban expires.

class MinimalUserPreview(BaseUser)

User representation in some small question previews.

class FollowerPreview(SmallUserPreview)

User card from the follower list.

is_followed_by_me: bool: is the authenticated user following this one.

Answers

class BaseAnswer

Base class for all answer representations. Compares with other answers (== and !=) by answer id.

id: int: answer id.

text: str: answer text.

age_seconds: int: how many seconds ago the answer was added.

url: str: answer url on the website.

class Answer(BaseAnswer)

Answer on a question page.

author: User: answer author.

source: str: answer source (for old answers).

can_like: bool: can the authenticated user like the answer.

can_thank: bool: can the authenticated user thank the answer.

thank_status: ThankStatus: is the answer thanked or hidden.

like_count: int: number of likes.

comment_count: int: number of comments.

vote_count: int: number of votes for this answer as the best answer.

comments: List[Comment]: comments to this answer, maybe not all of them. Use get_comments method to see all comments.

class AnswerPreview(BaseAnswer)

Answer card from a user profile.

is_best: bool: is this answer marked as best.

question: MinimalQuestionPreview: question to which this answer was given.

Other question-related things

class Comment

Comment to an answer or to a poll. Compares with other answers (== and !=) by comment id.

id: int: comment id.

text: str: comment text.

author_id: int: id of the comment author.

author: Union[User, CommentUserPreview, None]: author of the comment. Sometimes full information is not given by the API.

age_seconds: int: how many seconds ago the comment was added.

comment_count: int: number of replies to this comment.

comments: List[Comment]: replies to this comment, maybe not all of them. Use get_comments with the reference to get all.

parent_id: int: parent comment id.

reference_id: int: reference id, answer or poll.

number: int: sequence number of the comment.

type: CommentType: type of the reference.

url: str: comment url on the website.

class QuestionAddition

Addition to a question. Compares with other question additions by id.

id: int: addition id.

age_seconds: int: how many seconds ago the addition was made.

text: str: addition text.

class PollOption

Option in a poll. Compares with other poll options by id.

id: int: option id.

text: str: option text.

vote_count: int: number of votes for this option.

my_vote: bool: whether the authenticated user voted for this option.

class Poll

Poll in a question. Has no id, so compares with other polls by identity.

type: PollType: poll type, single or multiple choice.

vote_count: int: number of votes in the poll.

options: List[PollOption]: poll options.

i_voted: bool: whether the authenticated user has voted in the poll.

class Category

See Categories

Other user-related things

class Avatar

User avatar.

filin: str: avatar id returned from the API.

with_size(width: int, height: int) -> str: get avatar url with the size given.

__str__(): get avatar url with the default size.

class LimitSet

A set of daily limits for the user.

questions: int: number of questions that can be asked.

direct_questions: int: number of direct questions to experts that can be asked.

answers: int: number of answers.

best_answer_votes: int: number of votes for a best answer.

poll_votes: int: number of votes in polls.

likes: int: number of question and answer likes.

photos: int: number of photos in questions and answers.

videos: int: number of videos in questions and answers.

best_question_recommends: int: number of recommendations to the golden category.

class Limits

User limits.

total: LimitSet: total daily limits.

current: LimitSet: remaining daily limits.

class Settings

User settings.

news: bool: receive project news.

sound: bool: enable notification sound.

all_mail: bool: receive all notifications by email.

all_web: bool: receive all notifications on the website.

answer_mail: bool: receive notifications about new answers by email.

answer_web: bool: receive notifications about new answers on the website.

like_mail: bool: receive notifications about question and answer likes by email.

like_web: bool: receive notifications about question and answer likes on the website.

comment_mail: bool: receive notifications about new comments by email.

comment_web: bool: receive notifications about new comments on the website.

vote_mail: bool: receive notifications about new poll votes by email.

vote_web: bool: receive notifications about new poll votes on the website.

class Rate

See Rates

Brands

class BaseBrand

Base class for brands. Compares with other brands (== and !=) by brand urlname.

urlname: str: name of this brand in the url.

brand_url: str: brand website.

url: str: brand profile url on otvet.mail.ru.

class Brand(BaseBrand)

Short brand representation from user cards.

description: str: brand description.

class BrandBadge(BaseBrand)

Brand badge from brand expert profile.

name: str: brand name.

logo_url: str: brand logo.

background_url: str: brand profile background.

class BrandProfile(BrandBadge)

Brand profile page.

id: int: brand id.

answer_count: int: total number of answers given by brand experts.

best_answer_count: int: total number of best answers given by brand experts.

followers_count: int: number of followers of the brand.

open_question_count: total number of open questions asked by brand experts.

voting_question_count: total number of questions in voting state asked by brand experts.

resolved_question_count: total number of resolved questions asked by brand experts.

description: str: brand description.

is_followed_by_me: bool: whether the authenticated user is following this brand.

Clone this wiki locally