Знакомство с API Toxu

программирование
api
toxu
faq

(Официальный аккаунт) #1

Знакомство с API Toxu

В этом руководстве Вы найдете базовую информацию о принципах работы API Toxu и о подготовке к его использованию. Если Вы уже работали с нашим API или с аналогичными сервисами других платформ, и знаете, какое приложение хотите создать, мы рекомендуем Вам перейти в соответствующий раздел документации.

Использование API-ключа, метод GET

curl -X GET "http://***/admin/users/list/active.json?api_key=714552c6148e1617aeab526d0606184b94a80ec048fc&api_username=Toxu1"

POST

curl -X POST "http://***/categories" \
-H "Content-Type: multipart/form-data;" \
-F "api_key=714552c6148e1617aeab526d0606184b94a80ec048fc" \
-F "api_username=Toxu1" \
-F "name=89853c20-4409-e91a-a8ea-f6cdff96aaaa" \
-F "color=49d9e9" \
-F "text_color=f0fcfd"

Дополнение:

Последние изменения 21 августа 2017, 16:54


RSS-каналы сайта Toxu
(Официальный аккаунт) #2

Получить список разделов

Возвращает список всех разделов для вашего сайта, к которому у вас есть доступ.

GET /categories.json

ОБРАЗЦЫ ОТВЕТОВ
{
  "category_list": {
    "can_create_category": true,
    "can_create_topic": true,
    "draft": true,
    "draft_key": "string",
    "draft_sequence": 0,
    "categories": [
      {
        "id": 0,
        "name": "string",
        "color": "string",
        "text_color": "string",
        "slug": "string",
        "topic_count": 0,
        "post_count": 0,
        "position": 0,
        "description": "string",
        "description_text": "string",
        "topic_url": "string",
        "logo_url": "string",
        "background_url": "string",
        "read_restricted": true,
        "permission": 0,
        "notification_level": "string",
        "can_edit": true,
        "topic_template": "string",
        "has_children": true,
        "topics_day": 0,
        "topics_week": 0,
        "topics_month": 0,
        "topics_year": 0,
        "topics_all_time": 0,
        "description_excerpt": "string"
      }
    ]
  }
}

POST /categories.json

ОБРАЗЦЫ ЗАПРОСОВ

{
“name”: “string”,
“color”: “string”,
“text_color”: “string”
}

ОБРАЗЦЫ ОТВЕТОВ
{
  "category": {
    "id": 0,
    "name": "string",
    "color": "string",
    "text_color": "string",
    "slug": "string",
    "topic_count": 0,
    "post_count": 0,
    "position": 0,
    "description": "string",
    "description_text": "string",
    "topic_url": "string",
    "logo_url": "string",
    "background_url": "string",
    "read_restricted": true,
    "permission": "string",
    "notification_level": "string",
    "can_edit": true,
    "topic_template": "string",
    "has_children": true,
    "available_groups": [],
    "auto_close_hours": 0,
    "auto_close_based_on_last_post": true,
    "group_permissions": [],
    "email_in": true,
    "email_in_allow_strangers": true,
    "suppress_from_homepage": true,
    "can_delete": true,
    "cannot_delete_reason": "string",
    "allow_badges": true,
    "custom_fields": {}
  }
}

GET /c/{id}.json

ОБРАЗЦЫ ОТВЕТОВ
{
  "users": [
    {
      "id": 0,
      "username": "string",
      "avatar_template": "string"
    }
  ],
  "topic_list": {
    "can_create_topic": true,
    "draft": true,
    "draft_key": "string",
    "draft_sequence": 0,
    "per_page": 0,
    "topics": [
      {
        "id": 0,
        "title": "string",
        "fancy_title": "string",
        "slug": "string",
        "posts_count": 0,
        "reply_count": 0,
        "highest_post_number": 0,
        "image_url": "string",
        "created_at": "string",
        "last_posted_at": "string",
        "bumped": true,
        "bumped_at": "string",
        "unseen": true,
        "pinned": true,
        "unpinned": true,
        "excerpt": "string",
        "visible": true,
        "closed": true,
        "archived": true,
        "bookmarked": {},
        "liked": {},
        "views": 0,
        "like_count": 0,
        "has_summary": true,
        "archetype": "string",
        "last_poster_username": "string",
        "category_id": 0,
        "pinned_globally": true,
        "posters": [
          {
            "extras": "string",
            "description": "string",
            "user_id": 0
          }
        ]
      }
    ]
  }
}

PUT /categories/{id}

ОБРАЗЦЫ ЗАПРОСОВ

{
  "name": "string",
  "color": "string",
  "text_color": "string"
}
ОБРАЗЦЫ ОТВЕТОВ
{
  "success": "string",
  "category": {
    "id": 0,
    "name": "string",
    "color": "string",
    "text_color": "string",
    "slug": "string",
    "topic_count": 0,
    "post_count": 0,
    "position": 0,
    "description": {},
    "description_text": {},
    "topic_url": "string",
    "logo_url": "string",
    "background_url": "string",
    "read_restricted": true,
    "permission": {},
    "notification_level": {},
    "can_edit": true,
    "topic_template": "string",
    "has_children": {},
    "available_groups": [
      {}
    ],
    "auto_close_hours": {},
    "auto_close_based_on_last_post": true,
    "group_permissions": [
      null
    ],
    "email_in": {},
    "email_in_allow_strangers": true,
    "suppress_from_homepage": true,
    "can_delete": true,
    "cannot_delete_reason": {},
    "allow_badges": true,
    "custom_fields": {}
  }
}

(Официальный аккаунт) #3

Получить список вопросов

POST /posts

ОБРАЗЦЫ ЗАПРОСОВ

{
  "title": "string",
  "topic_id": 0,
  "raw": "string",
  "category": 0,
  "target_usernames": "discourse1,discourse2",
  "archetype": "private_message",
  "created_at": "2017-01-31"
}
ОБРАЗЦЫ ОТВЕТОВ
{
  "id": 0,
  "name": "string",
  "username": "string",
  "avatar_template": "string",
  "created_at": "string",
  "cooked": "string",
  "post_number": 0,
  "post_type": 0,
  "updated_at": "string",
  "reply_count": 0,
  "reply_to_post_number": null,
  "quote_count": 0,
  "avg_time": null,
  "incoming_link_count": 0,
  "reads": 0,
  "score": 0,
  "yours": true,
  "topic_id": 0,
  "topic_slug": "string",
  "display_username": "string",
  "primary_group_name": null,
  "primary_group_flair_url": null,
  "primary_group_flair_bg_color": null,
  "primary_group_flair_color": null,
  "version": 0,
  "can_edit": true,
  "can_delete": true,
  "can_recover": true,
  "can_wiki": true,
  "user_title": null,
  "actions_summary": [
    null
  ],
  "moderator": true,
  "admin": true,
  "staff": true,
  "user_id": 0,
  "draft_sequence": 0,
  "hidden": true,
  "hidden_reason_id": null,
  "trust_level": 0,
  "deleted_at": null,
  "user_deleted": true,
  "edit_reason": null,
  "can_view_edit_history": true,
  "wiki": true
}

Получение определенного вопроса

GET /t/{id}.json

ОБРАЗЦЫ ОТВЕТОВ
{
  "post_stream": {
    "posts": [
      {
        "id": 0,
        "name": "string",
        "username": "string",
        "avatar_template": "string",
        "created_at": "string",
        "cooked": "string",
        "post_number": 0,
        "post_type": 0,
        "updated_at": "string",
        "reply_count": 0,
        "reply_to_post_number": {},
        "quote_count": 0,
        "avg_time": {},
        "incoming_link_count": 0,
        "reads": 0,
        "score": 0,
        "yours": true,
        "topic_id": 0,
        "topic_slug": "string",
        "display_username": "string",
        "primary_group_name": {},
        "primary_group_flair_url": {},
        "primary_group_flair_bg_color": {},
        "primary_group_flair_color": {},
        "version": 0,
        "can_edit": true,
        "can_delete": true,
        "can_recover": true,
        "can_wiki": true,
        "read": true,
        "user_title": {},
        "actions_summary": [
          {}
        ],
        "moderator": true,
        "admin": true,
        "staff": true,
        "user_id": 0,
        "hidden": true,
        "hidden_reason_id": {},
        "trust_level": 0,
        "deleted_at": {},
        "user_deleted": true,
        "edit_reason": {},
        "can_view_edit_history": true,
        "wiki": true,
        "polls": {
          "poll": {
            "options": [
              {
                "id": "string",
                "html": "string",
                "votes": 0
              }
            ],
            "voters": 0,
            "status": "string",
            "name": "string",
            "type": "string"
          }
        },
        "polls_votes": {
          "poll": [
            "string"
          ]
        }
      }
    ],
    "stream": [
      {}
    ]
  },
  "timeline_lookup": [
    null
  ],
  "id": 0,
  "title": "string",
  "fancy_title": "string",
  "posts_count": 0,
  "created_at": "string",
  "views": 0,
  "reply_count": 0,
  "participant_count": 0,
  "like_count": 0,
  "last_posted_at": {},
  "visible": true,
  "closed": true,
  "archived": true,
  "has_summary": true,
  "archetype": "string",
  "slug": "string",
  "category_id": 0,
  "word_count": {},
  "deleted_at": {},
  "user_id": 0,
  "draft": {},
  "draft_key": "string",
  "draft_sequence": {},
  "unpinned": {},
  "pinned_globally": true,
  "pinned": true,
  "pinned_at": "string",
  "pinned_until": {},
  "details": {
    "auto_close_at": {},
    "auto_close_hours": {},
    "auto_close_based_on_last_post": true,
    "created_by": {
      "id": 0,
      "username": "string",
      "avatar_template": "string"
    },
    "last_poster": {
      "id": 0,
      "username": "string",
      "avatar_template": "string"
    },
    "participants": [
      null
    ],
    "suggested_topics": [
      null
    ],
    "notification_level": 0,
    "can_flag_topic": true
  },
  "highest_post_number": 0,
  "deleted_by": {},
  "actions_summary": [
    null
  ],
  "chunk_size": 0,
  "bookmarked": {}
}

Пропущены следующие пункты:

  • Remove a single topic
  • Update a single topic
  • Invite user to topic
  • bookmark a topic
  • close a topic
  • Get the latest topics
  • Get the top topics
  • Get the top topics filtered by specified flag
  • Create a timed topic
  • Update a topics timestamp
  • set notification level