OSS Insight Public API

Public read-only REST API behind OSS Insight, the PingCAP-built open-source analytics service that queries billions of GitHub events stored in TiDB. Exposes repository, developer, organization, collection and trending analytics endpoints used by the ossinsight.io site and by third parties.

OpenAPI Specification

pingcap-ossinsight-public-api-openapi-original.yaml Raw ↑
openapi: 3.0.3
info:
  title: OSSInsight Public API
  description: >
    
    OSSInsight Public APIs (beta) provide a convenient way to access insight data for open source projects on GitHub, supplementing the existing GitHub API.


    It provides data query in different dimensions, including:


    ```mdx-code-block

    import DocCardList from '@theme/DocCardList';

    import {useCurrentSidebarCategory} from '@docusaurus/theme-common';


    <DocCardList items={useCurrentSidebarCategory().items.filter((item) => {
        // Exclude Introduction and Showcase pages
        return item.docId !== 'api/showcase' && item.docId !== 'api/ossinsight-public-api';
    })}/>

    ```


    ## Usage


    The OSSInsight Public API is designed to follow the OpenAPI specification and can be accessed by initiating HTTP requests using the command line `curl` or web request libraries in different programming languages.


    ### Base URL


    All API requests are based on the following URL:


    ```shell

    https://api.ossinsight.io/v1

    ```


    ### Authentication


    No authentication is required for beta version of public APIs, but there are [rate limits](#rate-limit) for API requests.


    > Note:

    > We will add authentication way for larger API requests in future releases.


    ### Rate Limit


    For each IP address, the rate limit allows for up to **600 requests per hour**, which can be checked by the following fields in the Response Header to see the current usage:


    ```

    x-ratelimit-limit: 600

    x-ratelimit-remaining: 599

    ```


    In addition, we have also set up a global rate limit of up to **1000 requests per minute**, which can be checked by the following fields in the Response Header to see the current usage:


    ```

    x-ratelimit-limit-minute: 1000

    x-ratelimit-remaining-minute: 97

    ```


    ### Example


    For example, if you want to know what countries the stargazers in the `pingcap/tidb` repository are located in, you can make a request using the curl command as follows:


    ```shell

    curl https://api.ossinsight.io/v1/repos/pingcap/tidb/stargazers/countries

    ```


    <details>


    <summary>Example Response</summary>


    ```json

    {
      "type": "sql_endpoint",
      "data": {
        "columns": [
          {
            "col": "country_or_area",
            "data_type": "CHAR",
            "nullable": true
          },
          {
            "col": "count",
            "data_type": "BIGINT",
            "nullable": true
          },
          {
            "col": "percentage",
            "data_type": "DECIMAL",
            "nullable": true
          }
        ],
        "rows": [
          {
            "count": "9183",
            "country_or_area": "CN",
            "percentage": "0.5936"
          },
          {
            "count": "1542",
            "country_or_area": "US",
            "percentage": "0.0997"
          },
          {
            "count": "471",
            "country_or_area": "JP",
            "percentage": "0.0304"
          }
        ],
        "result": {
          "code": 200,
          "message": "Query OK!",
          "start_ms": 1690351487809,
          "end_ms": 1690351487930,
          "latency": "121ms",
          "row_count": 132,
          "row_affect": 0,
          "limit": 300,
          "databases": [
            "gharchive_dev"
          ]
        }
      }
    }

    ```


    </details>


    ## Request New API 


    If the API in the documentation does not meet your query requirements, please contact us as follows:


    - Email us at ossinsight@pingcap.com

    - Open an issue in the [OSSInsight GitHub repository](https://github.com/pingcap/ossinsight/issues/new?assignees=&labels=type%2Ffeature&projects=&template=feature_request.md&title=New%20API)
  version: v1beta
components:
  schemas: {}
paths:
  /collections/:
    get:
      operationId: list-collections
      summary: List collections
      tags:
        - Collections
      description: List collections.
      responses:
        "200":
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                required:
                  - type
                  - data
                properties:
                  type:
                    type: string
                    description: The type of the endpoint.
                    enum:
                      - sql_endpoint
                    example: sql_endpoint
                  data:
                    type: object
                    required:
                      - columns
                      - rows
                      - result
                    properties:
                      columns:
                        type: array
                        items:
                          type: object
                          required:
                            - col
                            - data_type
                            - nullable
                          properties:
                            col:
                              type: string
                              description: The name of the column in the query result.
                            data_type:
                              type: string
                              enum:
                                - CHAR
                                - BIGINT
                                - DECIMAL
                                - INT
                                - UNSIGNED BIGINT
                                - TINYINT
                                - TIMESTAMP
                                - TEXT
                                - VARCHAR
                                - DATETIME
                                - DOUBLE
                                - FLOAT
                                - DATE
                                - TIME
                                - YEAR
                                - MEDIUMINT
                                - SMALLINT
                                - BIT
                                - BINARY
                                - VARBINARY
                                - JSON
                                - ENUM
                                - SET
                                - TINYTEXT
                                - MEDIUMTEXT
                                - LONGTEXT
                                - TINYBLOB
                                - MEDIUMBLOB
                                - BLOB
                                - LONGBLOB
                              description: The data type of the column.
                            nullable:
                              type: boolean
                              description: Whether the column is nullable.
                          additionalProperties: true
                        example:
                          - col: id
                            data_type: BIGINT
                            nullable: false
                          - col: name
                            data_type: VARCHAR
                            nullable: false
                      rows:
                        type: array
                        items:
                          type: object
                          properties:
                            repo_id:
                              type: string
                              description: Repository ID
                            repo_name:
                              type: string
                              description: Repository name
                          additionalProperties: true
                        example:
                          - id: "1"
                            name: Static Site Generator
                          - id: "2"
                            name: Open Source Database
                          - id: "10001"
                            name: CSS Framework
                          - id: "10002"
                            name: Google Analytics Alternative
                          - id: "10003"
                            name: Low Code Development Tool
                      result:
                        type: object
                        properties:
                          code:
                            type: number
                            description: The code of the response.
                          message:
                            type: string
                            description: The message of the response.
                          start_ms:
                            type: number
                            description: The start time of the query in milliseconds.
                          end_ms:
                            type: number
                            description: The end time of the query in milliseconds.
                          latency:
                            type: string
                            description: The latency of the query.
                          row_count:
                            type: number
                            description: The number of rows in the query result.
                          row_affect:
                            type: number
                            description: The number of rows affected by the query.
                          limit:
                            type: number
                            description: The maximum number of rows in the query result.
                          databases:
                            type: array
                            description: The databases used in the query.
                            items:
                              type: string
                        additionalProperties: true
                        example:
                          code: 200
                          message: Query OK!
                          start_ms: 1690957407469
                          end_ms: 1690957407499
                          latency: 30ms
                          row_count: 5
                          row_affect: 0
                          limit: 50
                          databases:
                            - gharchive_dev
  /collections/hot/:
    get:
      operationId: list-hot-collections
      summary: List hot collections
      tags:
        - Collections
      description: List hot collections with top repositories of the collection.
      responses:
        "200":
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                required:
                  - type
                  - data
                properties:
                  type:
                    type: string
                    description: The type of the endpoint.
                    enum:
                      - sql_endpoint
                    example: sql_endpoint
                  data:
                    type: object
                    required:
                      - columns
                      - rows
                      - result
                    properties:
                      columns:
                        type: array
                        items:
                          type: object
                          required:
                            - col
                            - data_type
                            - nullable
                          properties:
                            col:
                              type: string
                              description: The name of the column in the query result.
                            data_type:
                              type: string
                              enum:
                                - CHAR
                                - BIGINT
                                - DECIMAL
                                - INT
                                - UNSIGNED BIGINT
                                - TINYINT
                                - TIMESTAMP
                                - TEXT
                                - VARCHAR
                                - DATETIME
                                - DOUBLE
                                - FLOAT
                                - DATE
                                - TIME
                                - YEAR
                                - MEDIUMINT
                                - SMALLINT
                                - BIT
                                - BINARY
                                - VARBINARY
                                - JSON
                                - ENUM
                                - SET
                                - TINYTEXT
                                - MEDIUMTEXT
                                - LONGTEXT
                                - TINYBLOB
                                - MEDIUMBLOB
                                - BLOB
                                - LONGBLOB
                              description: The data type of the column.
                            nullable:
                              type: boolean
                              description: Whether the column is nullable.
                          additionalProperties: true
                        example:
                          - col: id
                            data_type: BIGINT
                            nullable: false
                          - col: name
                            data_type: VARCHAR
                            nullable: false
                          - col: repos
                            data_type: BIGINT
                            nullable: false
                          - col: repo_id
                            data_type: BIGINT
                            nullable: false
                          - col: repo_name
                            data_type: VARCHAR
                            nullable: false
                          - col: repo_current_period_rank
                            data_type: INT
                            nullable: true
                          - col: repo_past_period_rank
                            data_type: INT
                            nullable: true
                          - col: repo_rank_changes
                            data_type: BIGINT
                            nullable: true
                      rows:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: string
                              description: Collection ID
                            name:
                              type: string
                              description: Collection name
                            repos:
                              type: string
                              description: The number of repositories in the collection
                            repo_id:
                              type: string
                              description: Repository ID
                            repo_name:
                              type: string
                              description: Repository name
                            repo_current_period_rank:
                              type: string
                              description: The rank of the repository in the collection in the current period
                            repo_past_period_rank:
                              type: string
                              description: The rank of the repository in the collection in the past period
                            repo_rank_changes:
                              type: string
                              description: The rank changes of the repository in the collection
                          additionalProperties: true
                        example:
                          - id: "10010"
                            name: Artificial Intelligence
                            repos: "36"
                            repo_id: "155220641"
                            repo_name: huggingface/transformers
                            repo_current_period_rank: "1"
                            repo_past_period_rank: "1"
                            repo_rank_changes: "0"
                          - id: "10010"
                            name: Artificial Intelligence
                            repos: "36"
                            repo_id: "65600975"
                            repo_name: pytorch/pytorch
                            repo_current_period_rank: "3"
                            repo_past_period_rank: "4"
                            repo_rank_changes: "1"
                          - id: "10010"
                            name: Artificial Intelligence
                            repos: "36"
                            repo_id: "458588993"
                            repo_name: nebuly-ai/nebullvm
                            repo_current_period_rank: "2"
                            repo_past_period_rank: "2"
                            repo_rank_changes: "0"
                          - id: "10078"
                            name: ChatGPT Apps
                            repos: "36"
                            repo_id: "599394820"
                            repo_name: Chanzhaoyu/chatgpt-web
                            repo_current_period_rank: "3"
                            repo_past_period_rank: "6"
                            repo_rank_changes: "3"
                          - id: "10078"
                            name: ChatGPT Apps
                            repos: "36"
                            repo_id: "609416865"
                            repo_name: yetone/openai-translator
                            repo_current_period_rank: "2"
                            repo_past_period_rank: ""
                            repo_rank_changes: ""
                          - id: "10078"
                            name: ChatGPT Apps
                            repos: "36"
                            repo_id: "608555244"
                            repo_name: microsoft/visual-chatgpt
                            repo_current_period_rank: "1"
                            repo_past_period_rank: ""
                            repo_rank_changes: ""
                      result:
                        type: object
                        properties:
                          code:
                            type: number
                            description: The code of the response.
                          message:
                            type: string
                            description: The message of the response.
                          start_ms:
                            type: number
                            description: The start time of the query in milliseconds.
                          end_ms:
                            type: number
                            description: The end time of the query in milliseconds.
                          latency:
                            type: string
                            description: The latency of the query.
                          row_count:
                            type: number
                            description: The number of rows in the query result.
                          row_affect:
                            type: number
                            description: The number of rows affected by the query.
                          limit:
                            type: number
                            description: The maximum number of rows in the query result.
                          databases:
                            type: array
                            description: The databases used in the query.
                            items:
                              type: string
                        additionalProperties: true
                        example:
                          code: 200
                          message: Query OK!
                          start_ms: 1690957407469
                          end_ms: 1690957407499
                          latency: 30ms
                          row_count: 6
                          row_affect: 0
                          limit: 50
                          databases:
                            - gharchive_dev
  /trends/repos/:
    get:
      operationId: list-trending-repos
      summary: List trending repos
      tags:
        - Trends
      description: >-
        Trending repos is an open source alternative to GitHub trends, which
        showcases recently popular open source projects in the GitHub community.


        > **Note**

        >

        > Please URI encode the requested parameters, e.g. `C++` needs to be encoded as `C%2B%2B`.
         
        ☁️ Daily run on [TiDB Cloud](https://tidbcloud.com/?utm_source=ossinsight&utm_medium=ossinsight_api), analyze upon dataset that has over 6 billion GitHub events.
      parameters:
        - schema:
            type: string
            enum:
              - past_24_hours
              - past_week
              - past_month
              - past_3_months
            default: past_24_hours
          in: query
          name: period
          required: false
          description: Specify the period of time to calculate trending repos.
        - schema:
            type: string
            enum:
              - All
              - JavaScript
              - Java
              - Python
              - PHP
              - C++
              - C#
              - TypeScript
              - Shell
              - C
              - Ruby
              - Rust
              - Go
              - Kotlin
              - HCL
              - PowerShell
              - CMake
              - Groovy
              - PLpgSQL
              - TSQL
              - Dart
              - Swift
              - HTML
              - CSS
              - Elixir
              - Haskell
              - Solidity
              - Assembly
              - R
              - Scala
              - Julia
              - Lua
              - Clojure
              - Erlang
              - Common Lisp
              - Emacs Lisp
              - OCaml
              - MATLAB
              - Objective-C
              - Perl
              - Fortran
            default: All
          in: query
          name: language
          required: false
          description: Specify using which programming language to filter trending repos.
            If not specified, all languages will be included.
      responses:
        "200":
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                required:
                  - type
                  - data
                properties:
                  type:
                    type: string
                    description: The type of the endpoint.
                    enum:
                      - sql_endpoint
                    example: sql_endpoint
                  data:
                    type: object
                    required:
                      - columns
                      - rows
                      - result
                    properties:
                      columns:
                        type: array
                        items:
                          type: object
                          required:
                            - col
                            - data_type
                            - nullable
                          properties:
                            col:
                              type: string
                              description: The name of the column in the query result.
                            data_type:
                              type: string
                              enum:
                                - CHAR
                                - BIGINT
                                - DECIMAL
                                - INT
                                - UNSIGNED BIGINT
                                - TINYINT
                                - TIMESTAMP
                                - TEXT
                                - VARCHAR
                                - DATETIME
                                - DOUBLE
                                - FLOAT
                                - DATE
                                - TIME
                                - YEAR
                                - MEDIUMINT
                                - SMALLINT
                                - BIT
                                - BINARY
                                - VARBINARY
                                - JSON
                                - ENUM
                                - SET
                                - TINYTEXT
                                - MEDIUMTEXT
                                - LONGTEXT
                                - TINYBLOB
                                - MEDIUMBLOB
                                - BLOB
                                - LONGBLOB
                              description: The data type of the column.
                            nullable:
                              type: boolean
                              description: Whether the column is nullable.
                          additionalProperties: true
                        example:
                          - col: repo_id
                            data_type: INT
                            nullable: true
                          - col: repo_name
                            data_type: VARCHAR
                            nullable: true
                          - col: primary_language
                            data_type: VARCHAR
                            nullable: true
                          - col: description
                            data_type: VARCHAR
                            nullable: true
                          - col: stars
                            data_type: INT
                            nullable: true
                          - col: forks
                            data_type: INT
                            nullable: true
                          - col: pull_requests
                            data_type: INT
                            nullable: true
                          - col: pushes
                            data_type: INT
                            nullable: true
                          - col: total_score
                            data_type: DOUBLE
                            nullable: true
                          - col: contributor_logins
                            data_type: VARCHAR
                            nullable: true
                          - col: collection_names
                            data_type: VARCHAR
                            nullable: true
                      rows:
                        type: array
                        items:
                          type: object
                          properties:
                            repo_id:
                              type: string
                              description: ID of the repo
                            repo_name:
                              type: string
                              description: Name of the repo
                            primary_language:
                              type: string
                              description: Primary programing language used by the repo
                            description:
                              type: string
                              description: Description of the repo
                            stars:
                              type: string
                              description: Number of stars in the period
                            forks:
                              type: string
                              description: Number of forks in the period
                            pull_requests:
                              type: string
                              description: Number of pull requests in the period
                            pushes:
                              type: string
                              description: Number of pushes in the period
                            total_score:
                              type: string
                              description: Total score of the repo
                            contributor_logins:
                              type: string
                              description: Comma separated list of active contributor logins
                            collection_names:
                              type: string
                              description: Comma separated list of collection names
                        example:
                          - collection_names: CICD
                            contributor_logins: cplee,nektos-ci,usagirei,ae-ou,MrNossiom
                            description: Run your GitHub Actions locally 🚀
                            forks: "5"
                            primary_language: Go
                            pull_requests: "6"
                            pushes: "17"
                            repo_id: "163883279"
                            repo_name: nektos/act
                            stars: "395"
                            total_score: "1565.7526"
                          - collection_names: ChatGPT Alternatives
                            contributor_logins: antonkesy,ruanslv,starplatinum3,AlexandroLuis,realhaik
                            description: Inference code for LLaMA models
                            forks: "48"
                            primary_language: Python
                            pull_requests: "41"
                            pushes: "7"
                            repo_id: "601538369"
                            repo_name: facebookresearch/llama
                            stars: "209"
                            total_score: "1079.0274"
                          - collection_names: Stable Diffusion Ecosystem
                            contributor_logins: atiorh,SaladDays831,ZachNagengast,TimYao18,vzsg
                            description: Stable Diffusion with Core ML on Apple Silicon
                            forks: "5"
                            primary_language: Python
                            pull_requests: "7"
                            pushes: "5"
                            repo_id: "566576114"
                            repo_name: apple/ml-stable-diffusion
                            stars: "99"
                            total_score: "575.2498"
                          - collection_names: Stable Diffusion Ecosystem
                            contributor_logins: danonymous856,EvilPhi666,FurkanGozukara,Prathyusha-98,ca-kishida
                            description: High-Resolution Image Synthesis with Latent Diffusion Models
                            forks: "6"
                            primary_language: Python
                            pull_requests: "2"
                            pushes: ""
                            repo_id: "569927055"
                            repo_name: Stability-AI/stablediffusion
                            stars: "75"
                            total_score: "483.0236"
                      result:
                        type: object
                        properties:
                          code:
                            type: number
                            description: The code of the response.
                          message:
                            type: string
                            description: The message of the response.
                          start_ms:
                            type: number
                            description: The start time of the query in milliseconds.
                          end_ms:
                            type: number
                            description: The end time of the query in milliseconds.
                          latency:
                            type: string
                            description: The latency of the query.
                          row_count:
                            type: number
                            description: The number of rows in the query result.
                          row_affect:
                            type: number
                            description: The number of rows affected by the query.
                          limit:
                            type: 

# --- truncated at 32 KB (163 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/pingcap/refs/heads/main/openapi/pingcap-ossinsight-public-api-openapi-original.yaml