{"meta":{"title":"API 见解的 REST API 端点","intro":"使用 REST API 查看组织中 API 使用情况的统计信息。","product":"REST API","breadcrumbs":[{"href":"/zh/rest","title":"REST API"},{"href":"/zh/rest/orgs","title":"组织"},{"href":"/zh/rest/orgs/api-insights","title":"API 洞察"}],"documentType":"article"},"body":"# API 见解的 REST API 端点\n\n使用 REST API 查看组织中 API 使用情况的统计信息。\n\n> [!NOTE]\n> Most endpoints use `Authorization: Bearer <YOUR-TOKEN>` and `Accept: application/vnd.github+json` headers, plus `X-GitHub-Api-Version: 2026-03-10`. Curl examples below omit these standard headers for brevity.\n\n## Get route stats by actor\n\n```\nGET /orgs/{org}/insights/api/route-stats/{actor_type}/{actor_id}\n```\n\nGet API request count statistics for an actor broken down by route within a specified time frame.\nUnder normal conditions, you can expect API data to appear within 4–6 hours after making a request. During incidents or periods of unusually high volume, it may take longer to show up.\n\n### Parameters\n\n#### Headers\n\n- **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n- **`org`** (string) (required)\n  The organization name. The name is not case sensitive.\n\n- **`actor_type`** (string) (required)\n  The type of the actor\n  Can be one of: `installation`, `classic_pat`, `fine_grained_pat`, `oauth_app`, `github_app_user_to_server`\n\n- **`actor_id`** (integer) (required)\n  The ID of the actor\n\n- **`min_timestamp`** (string) (required)\n  The minimum timestamp to query for stats. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.\n\n- **`max_timestamp`** (string)\n  The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.\n\n- **`page`** (integer)\n  The page number of the results to fetch. For more information, see \"Using pagination in the REST API.\"\n  Default: `1`\n\n- **`per_page`** (integer)\n  The number of results per page (max 100). For more information, see \"Using pagination in the REST API.\"\n  Default: `30`\n\n- **`direction`** (string)\n  The direction to sort the results by.\n  Default: `desc`\n  Can be one of: `asc`, `desc`\n\n- **`sort`** (array)\n  The property to sort the results by.\n\n- **`api_route_substring`** (string)\n  Providing a substring will filter results where the API route contains the substring. This is a case-insensitive search.\n\n### HTTP response status codes\n\n- **200** - OK\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  https://api.github.com/orgs/ORG/insights/api/route-stats/ACTOR_TYPE/ACTOR_ID\n```\n\n**Response schema (Status: 200):**\n\nArray of objects:\n  * `http_method`: string\n  * `api_route`: string\n  * `total_request_count`: integer, format: int64\n  * `rate_limited_request_count`: integer, format: int64\n  * `last_rate_limited_timestamp`: string or null\n  * `last_request_timestamp`: string\n\n## Get subject stats\n\n```\nGET /orgs/{org}/insights/api/subject-stats\n```\n\nGet API request statistics for all subjects within an organization within a specified time frame. Subjects can be users or GitHub Apps.\nUnder normal conditions, you can expect API data to appear within 4–6 hours after making a request. During incidents or periods of unusually high volume, it may take longer to show up.\n\n### Parameters\n\n#### Headers\n\n- **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n- **`org`** (string) (required)\n  The organization name. The name is not case sensitive.\n\n- **`min_timestamp`** (string) (required)\n  The minimum timestamp to query for stats. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.\n\n- **`max_timestamp`** (string)\n  The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.\n\n- **`page`** (integer)\n  The page number of the results to fetch. For more information, see \"Using pagination in the REST API.\"\n  Default: `1`\n\n- **`per_page`** (integer)\n  The number of results per page (max 100). For more information, see \"Using pagination in the REST API.\"\n  Default: `30`\n\n- **`direction`** (string)\n  The direction to sort the results by.\n  Default: `desc`\n  Can be one of: `asc`, `desc`\n\n- **`sort`** (array)\n  The property to sort the results by.\n\n- **`subject_name_substring`** (string)\n  Providing a substring will filter results where the subject name contains the substring. This is a case-insensitive search.\n\n### HTTP response status codes\n\n- **200** - OK\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  https://api.github.com/orgs/ORG/insights/api/subject-stats\n```\n\n**Response schema (Status: 200):**\n\nArray of objects:\n  * `subject_type`: string\n  * `subject_name`: string\n  * `subject_id`: integer, format: int64\n  * `total_request_count`: integer\n  * `rate_limited_request_count`: integer\n  * `last_rate_limited_timestamp`: string or null\n  * `last_request_timestamp`: string\n\n## Get summary stats\n\n```\nGET /orgs/{org}/insights/api/summary-stats\n```\n\nGet overall statistics of API requests made within an organization by all users and apps within a specified time frame.\nUnder normal conditions, you can expect API data to appear within 4–6 hours after making a request. During incidents or periods of unusually high volume, it may take longer to show up.\n\n### Parameters\n\n#### Headers\n\n- **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n- **`org`** (string) (required)\n  The organization name. The name is not case sensitive.\n\n- **`min_timestamp`** (string) (required)\n  The minimum timestamp to query for stats. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.\n\n- **`max_timestamp`** (string)\n  The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.\n\n### HTTP response status codes\n\n- **200** - OK\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  https://api.github.com/orgs/ORG/insights/api/summary-stats\n```\n\n**Response schema (Status: 200):**\n\n* `total_request_count`: integer, format: int64\n* `rate_limited_request_count`: integer, format: int64\n\n## Get summary stats by user\n\n```\nGET /orgs/{org}/insights/api/summary-stats/users/{user_id}\n```\n\nGet overall statistics of API requests within the organization for a user.\nUnder normal conditions, you can expect API data to appear within 4–6 hours after making a request. During incidents or periods of unusually high volume, it may take longer to show up.\n\n### Parameters\n\n#### Headers\n\n- **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n- **`org`** (string) (required)\n  The organization name. The name is not case sensitive.\n\n- **`user_id`** (string) (required)\n  The ID of the user to query for stats\n\n- **`min_timestamp`** (string) (required)\n  The minimum timestamp to query for stats. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.\n\n- **`max_timestamp`** (string)\n  The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.\n\n### HTTP response status codes\n\n- **200** - OK\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  https://api.github.com/orgs/ORG/insights/api/summary-stats/users/USER_ID\n```\n\n**Response schema (Status: 200):**\n\nSame response schema as [Get summary stats](#get-summary-stats).\n\n## Get summary stats by actor\n\n```\nGET /orgs/{org}/insights/api/summary-stats/{actor_type}/{actor_id}\n```\n\nGet overall statistics of API requests within the organization made by a specific actor. Actors can be GitHub App installations, OAuth apps or other tokens on behalf of a user.\nUnder normal conditions, you can expect API data to appear within 4–6 hours after making a request. During incidents or periods of unusually high volume, it may take longer to show up.\n\n### Parameters\n\n#### Headers\n\n- **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n- **`org`** (string) (required)\n  The organization name. The name is not case sensitive.\n\n- **`min_timestamp`** (string) (required)\n  The minimum timestamp to query for stats. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.\n\n- **`max_timestamp`** (string)\n  The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.\n\n- **`actor_type`** (string) (required)\n  The type of the actor\n  Can be one of: `installation`, `classic_pat`, `fine_grained_pat`, `oauth_app`, `github_app_user_to_server`\n\n- **`actor_id`** (integer) (required)\n  The ID of the actor\n\n### HTTP response status codes\n\n- **200** - OK\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  https://api.github.com/orgs/ORG/insights/api/summary-stats/ACTOR_TYPE/ACTOR_ID\n```\n\n**Response schema (Status: 200):**\n\nSame response schema as [Get summary stats](#get-summary-stats).\n\n## Get time stats\n\n```\nGET /orgs/{org}/insights/api/time-stats\n```\n\nGet the number of API requests and rate-limited requests made within an organization over a specified time period.\nUnder normal conditions, you can expect API data to appear within 4–6 hours after making a request. During incidents or periods of unusually high volume, it may take longer to show up.\n\n### Parameters\n\n#### Headers\n\n- **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n- **`org`** (string) (required)\n  The organization name. The name is not case sensitive.\n\n- **`min_timestamp`** (string) (required)\n  The minimum timestamp to query for stats. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.\n\n- **`max_timestamp`** (string)\n  The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.\n\n- **`timestamp_increment`** (string) (required)\n  The increment of time used to breakdown the query results (5m, 10m, 1h, etc.)\n\n### HTTP response status codes\n\n- **200** - OK\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  https://api.github.com/orgs/ORG/insights/api/time-stats\n```\n\n**Response schema (Status: 200):**\n\nArray of objects:\n  * `timestamp`: string\n  * `total_request_count`: integer, format: int64\n  * `rate_limited_request_count`: integer, format: int64\n\n## Get time stats by user\n\n```\nGET /orgs/{org}/insights/api/time-stats/users/{user_id}\n```\n\nGet the number of API requests and rate-limited requests made within an organization by a specific user over a specified time period.\nUnder normal conditions, you can expect API data to appear within 4–6 hours after making a request. During incidents or periods of unusually high volume, it may take longer to show up.\n\n### Parameters\n\n#### Headers\n\n- **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n- **`org`** (string) (required)\n  The organization name. The name is not case sensitive.\n\n- **`user_id`** (string) (required)\n  The ID of the user to query for stats\n\n- **`min_timestamp`** (string) (required)\n  The minimum timestamp to query for stats. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.\n\n- **`max_timestamp`** (string)\n  The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.\n\n- **`timestamp_increment`** (string) (required)\n  The increment of time used to breakdown the query results (5m, 10m, 1h, etc.)\n\n### HTTP response status codes\n\n- **200** - OK\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  https://api.github.com/orgs/ORG/insights/api/time-stats/users/USER_ID\n```\n\n**Response schema (Status: 200):**\n\nSame response schema as [Get time stats](#get-time-stats).\n\n## Get time stats by actor\n\n```\nGET /orgs/{org}/insights/api/time-stats/{actor_type}/{actor_id}\n```\n\nGet the number of API requests and rate-limited requests made within an organization by a specific actor within a specified time period.\nUnder normal conditions, you can expect API data to appear within 4–6 hours after making a request. During incidents or periods of unusually high volume, it may take longer to show up.\n\n### Parameters\n\n#### Headers\n\n- **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n- **`org`** (string) (required)\n  The organization name. The name is not case sensitive.\n\n- **`actor_type`** (string) (required)\n  The type of the actor\n  Can be one of: `installation`, `classic_pat`, `fine_grained_pat`, `oauth_app`, `github_app_user_to_server`\n\n- **`actor_id`** (integer) (required)\n  The ID of the actor\n\n- **`min_timestamp`** (string) (required)\n  The minimum timestamp to query for stats. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.\n\n- **`max_timestamp`** (string)\n  The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.\n\n- **`timestamp_increment`** (string) (required)\n  The increment of time used to breakdown the query results (5m, 10m, 1h, etc.)\n\n### HTTP response status codes\n\n- **200** - OK\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  https://api.github.com/orgs/ORG/insights/api/time-stats/ACTOR_TYPE/ACTOR_ID\n```\n\n**Response schema (Status: 200):**\n\nSame response schema as [Get time stats](#get-time-stats).\n\n## Get user stats\n\n```\nGET /orgs/{org}/insights/api/user-stats/{user_id}\n```\n\nGet API usage statistics within an organization for a user broken down by the type of access.\nUnder normal conditions, you can expect API data to appear within 4–6 hours after making a request. During incidents or periods of unusually high volume, it may take longer to show up.\n\n### Parameters\n\n#### Headers\n\n- **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n- **`org`** (string) (required)\n  The organization name. The name is not case sensitive.\n\n- **`user_id`** (string) (required)\n  The ID of the user to query for stats\n\n- **`min_timestamp`** (string) (required)\n  The minimum timestamp to query for stats. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.\n\n- **`max_timestamp`** (string)\n  The maximum timestamp to query for stats. Defaults to the time 30 days ago. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.\n\n- **`page`** (integer)\n  The page number of the results to fetch. For more information, see \"Using pagination in the REST API.\"\n  Default: `1`\n\n- **`per_page`** (integer)\n  The number of results per page (max 100). For more information, see \"Using pagination in the REST API.\"\n  Default: `30`\n\n- **`direction`** (string)\n  The direction to sort the results by.\n  Default: `desc`\n  Can be one of: `asc`, `desc`\n\n- **`sort`** (array)\n  The property to sort the results by.\n\n- **`actor_name_substring`** (string)\n  Providing a substring will filter results where the actor name contains the substring. This is a case-insensitive search.\n\n### HTTP response status codes\n\n- **200** - OK\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  https://api.github.com/orgs/ORG/insights/api/user-stats/USER_ID\n```\n\n**Response schema (Status: 200):**\n\nArray of objects:\n  * `actor_type`: string\n  * `actor_name`: string\n  * `actor_id`: integer, format: int64\n  * `integration_id`: integer or null, format: int64\n  * `oauth_application_id`: integer or null, format: int64\n  * `total_request_count`: integer\n  * `rate_limited_request_count`: integer\n  * `last_rate_limited_timestamp`: string or null\n  * `last_request_timestamp`: string"}