VK API JSON Schema

repository·master·Indexed 42 days ago

https://github.com/vkcom/vk-api-schema

Official JSON Schema definitions for the VK.COM API version 5.199. Provides schemas for API methods, objects, responses, and errors, compatible with JSON Schema draft-07. Includes tools to merge split schema files into a single unified schema.

Tokens
1.7K
Snippets
4
Records
5
Agent score
3%

What's inside VK API Schema

  1. Understand the VK API JSON Schema structure

    master

    The repository provides JSON Schema documents that define the structure of all VK.COM API objects and methods. These schemas are compatible with JSON Schema draft-07 and VK API version 5.199. The schema is divided into several key files:

    • methods.json: Describes all available VK API methods.
    • objects.json: Describes the objects returned in method responses.
    • responses.json: Describes the structure of method responses.
    • errors.json: Describes possible method errors.
    • schema.json: Defines custom keywords used to extend the canonical JSON Schema specification for VK-specific needs, such as method, error, and parameter.
  2. Combine split API schemas using combine.sh

    master

    The combine.sh script can be used to merge split API schemas into a single unified schema.

    Prerequisites

    You must have jq installed on your system for the script to function correctly.

    Usage

    You can run the script with two optional positional parameters:

    bash ./combine.sh [INPUT] [OUTPUT]

    • INPUT: The directory containing the split schemas. Defaults to the current directory (.).
    • OUTPUT: The directory where the combined result will be saved. Defaults to ./_build.

    Example

    To combine schemas from the current directory and save the output to a directory named ../build:

    bash ./combine.sh . ../build
  3. Example: users.get method schema

    master

    The following is a sample of how a method is described in methods.json. It includes the method name, description, parameters (with types and constraints), and the reference to its response structure.

    {
          "name": "users.get",
          "description": "Returns detailed information on users.",
          "open": true,
          "parameters": [
            {
              "name": "user_ids",
              "description": "User IDs or screen names ('screen_name'). By default, current user ID.",
              "type": "array",
              "items": {
                "type": "string"
              },
              "maxItems": 1000
            },
            {
              "name": "domains",
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            {
              "name": "fields",
              "description": "Profile fields to return. Sample values: 'nickname', 'screen_name', 'sex', 'bdate' (birthdate), 'city', 'country', 'timezone', 'photo', 'photo_medium', 'photo_big', 'has_mobile', 'contacts', 'education', 'online', 'counters', 'relation', 'last_seen', 'activity', 'can_write_private_message', 'can_see_all_posts', 'can_post', 'universities';",
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            {
              "name": "name_case",
              "description": "Case for declension of user name and surname:; 'nom' — nominative (default); 'gen' — genitive ; 'dat' — dative; 'acc' — accusative ; 'ins' — instrumental ; 'abl' — prepositional",
              "type": "string"
            }
          ],
          "responses": {
            "response": {
              "$ref": "responses.json#/definitions/users_get_response"
            }
          }
        }
  4. Example: market_market_album object schema

    master

    The following is a sample of how an object is defined in objects.json. It specifies the properties, their types, descriptions, and required fields.

    "market_market_album": {
          "type": "object",
          "properties": {
            "id": {
              "type": "integer",
              "description": "Market album ID",
              "minimum": 1
            },
            "owner_id": {
              "type": "integer",
              "description": "Market album owner's ID"
            },
            "title": {
              "type": "string",
              "description": "Market album title"
            },
            "count": {
              "type": "integer",
              "description": "Items number",
              "minimum": 0
            },
            "updated_time": {
              "type": "integer",
              "description": "Date when album has been updated last time in Unixtime",
              "minimum": 0
            },
            "photo": {
              "$ref": "#/definitions/photos_photo"
            }
          },
          "required": [
            "id",
            "owner_id",
            "title",
            "count",
            "updated_time"
          ]
        }