forked from justincasher/lean-explore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenapi.yaml
More file actions
370 lines (356 loc) · 12.3 KB
/
openapi.yaml
File metadata and controls
370 lines (356 loc) · 12.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
openapi: 3.0.3
info:
title: LeanExplore API
version: v1.0.0
description: >-
The LeanExplore API provides programmatic access to search and retrieve
information about Lean 4 statement groups, their definitions, docstrings,
and dependencies from various Lean projects, including Mathlib.
Authentication is required via an API key. The key can be provided either
as a Bearer token in the 'Authorization' header or via an 'X-API-Key' header.
Rate limits are applied to API endpoints. Exceeding these limits
will result in a 429 Too Many Requests error.
contact:
name: Justin Asher
email: justinchadwickasher@gmail.com
url: https://www.leanexplore.com
license:
name: Apache 2.0
url: https://www.apache.org/licenses/LICENSE-2.0.html
# Defines tags used for grouping operations in API documentation tools.
tags:
- name: Search
description: Endpoints for searching Lean statement groups.
- name: Statement Groups
description: Endpoints for retrieving specific statement groups and their properties (like dependencies).
servers:
- url: https://www.leanexplore.com/api/v1
description: Production LeanExplore API Server
# - url: http://localhost:5000/api/v1 # Example placeholder for a local development server.
# description: Local Development Server
# Reusable building blocks for the API specification.
components:
securitySchemes:
# Defines Bearer Token authentication method.
BearerAuth:
type: http
scheme: bearer
description: >-
API key provided as a Bearer token.
Example: `Authorization: Bearer YOUR_API_KEY`
# Defines API Key in header authentication method.
ApiKeyHeaderAuth:
type: apiKey
in: header
name: X-API-Key
description: >-
API key provided in the X-API-Key header.
Example: `X-API-Key: YOUR_API_KEY`
# Data models used in request and response bodies.
schemas:
APIPrimaryDeclarationInfo:
type: object
description: Minimal information about a primary declaration.
properties:
lean_name:
type: string
nullable: true
description: The full Lean name of the primary declaration (e.g., "Nat.add").
example: "Nat.add"
APISearchResultItem:
type: object
description: Represents a single statement group item.
required:
- id
- primary_declaration
- source_file
- range_start_line
- statement_text
properties:
id:
type: integer
format: int64 # Specifies the integer as a 64-bit number.
description: Unique identifier for the statement group.
example: 10243
primary_declaration:
$ref: '#/components/schemas/APIPrimaryDeclarationInfo'
source_file:
type: string
description: The source file path for the statement group.
example: "Mathlib/Data/Nat/Basic.lean"
range_start_line:
type: integer
description: Start line of the statement group in its source file.
example: 78
display_statement_text:
type: string
nullable: true
description: A display-optimized version of the statement text.
example: "theorem Nat.add_comm (n m : Nat) : n + m = m + n"
statement_text:
type: string
description: The full canonical Lean code text of the statement group.
example: "theorem Nat.add_comm (n m : Nat) : n + m = m + n := by simp [Nat.add_assoc]"
docstring:
type: string
nullable: true
description: The docstring associated with the statement group.
example: "Addition of natural numbers is commutative."
informal_description:
type: string
nullable: true
description: An informal, human-readable description of the statement group.
example: "This theorem states that for any two natural numbers n and m, n + m is equal to m + n."
APISearchResponse:
type: object
description: Response structure for a search API call.
required:
- query
- results
- count
- total_candidates_considered
- processing_time_ms
properties:
query:
type: string
description: The original search query string.
example: "commutative monoid"
packages_applied:
type: array
items:
type: string
nullable: true
description: List of package names applied to the search. Can be empty or null.
example: ["Mathlib", "Std"]
results:
type: array
items:
$ref: '#/components/schemas/APISearchResultItem'
description: A list of search result items.
count:
type: integer
description: The number of results returned in this response.
example: 10
total_candidates_considered:
type: integer
description: Total candidate results before truncation by any server-side limit.
example: 152
processing_time_ms:
type: integer
description: Server-side processing time for the search in milliseconds.
example: 120
APICitationsResponse:
type: object
description: Response for a dependencies (citations) API call.
required:
- source_group_id
- citations
- count
properties:
source_group_id:
type: integer
format: int64
description: The ID of the statement group whose citations are listed.
example: 10243
citations:
type: array
items:
$ref: '#/components/schemas/APISearchResultItem'
description: A list of statement groups cited by the source group.
count:
type: integer
description: The number of citations provided.
example: 5
ApiError:
type: object
description: Standard error response structure for client and server errors.
required:
- msg
properties:
msg:
type: string
description: A human-readable error message.
example: "Invalid or inactive API key"
# Global security definition:
# Specifies that EITHER BearerAuth OR ApiKeyHeaderAuth can be used for authentication
# for operations that require security. A client must satisfy one of these schemes.
security:
- BearerAuth: []
- ApiKeyHeaderAuth: []
# Defines the available API paths and their operations.
paths:
/search:
get:
summary: Search Statement Groups
description: >-
Performs a search for Lean statement groups based on a query string
and optional package filters. Requires API key authentication.
operationId: searchStatementGroups # Unique ID for this operation.
tags:
- Search
parameters:
- name: q
in: query
required: true
description: The natural language search query string.
schema:
type: string
example: "isomorphism"
- name: pkg
in: query
required: false
description: >-
Package names to filter by. Specify multiple times for multiple packages
(e.g., "pkg=Mathlib&pkg=Std").
schema:
type: array
items:
type: string
style: form # Default style for query parameters.
explode: true # For array type, results in pkg=val1&pkg=val2... matching Flask's getlist().
example: ["Mathlib", "Std"]
responses:
'200':
description: Successful search operation.
content:
application/json:
schema:
$ref: '#/components/schemas/APISearchResponse'
'400':
description: Bad Request - Invalid or missing search query.
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
'401':
description: Unauthorized - API key is missing, invalid, or inactive.
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
'429':
description: Too Many Requests - Rate limit exceeded.
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
'500':
description: Internal Server Error.
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
'503':
description: Service Unavailable.
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
/statement_groups/{group_id}:
get:
summary: Get Statement Group by ID
description: Retrieves detailed information for a specific statement group using its unique ID. Requires API key authentication.
operationId: getStatementGroupById
tags:
- Statement Groups
parameters:
- name: group_id
in: path
required: true
description: The unique integer ID of the statement group.
schema:
type: integer
format: int64
example: 10243
responses:
'200':
description: Successfully retrieved the statement group.
content:
application/json:
schema:
$ref: '#/components/schemas/APISearchResultItem'
'401':
description: Unauthorized - API key is missing, invalid, or inactive.
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
'404':
description: Not Found - The statement group with the specified ID does not exist.
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
'429':
description: Too Many Requests - Rate limit exceeded.
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
'500':
description: Internal Server Error.
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
'503':
description: Service Unavailable.
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
/statement_groups/{group_id}/dependencies:
get:
summary: Get Statement Group Dependencies
description: >-
Retrieves the direct dependencies for a given statement group ID.
Requires API key authentication.
operationId: getStatementGroupDependencies
tags:
- Statement Groups
parameters:
- name: group_id
in: path
required: true
description: The unique integer ID of the source statement group.
schema:
type: integer
format: int64
example: 10243
responses:
'200':
description: Successfully retrieved the list of dependencies.
content:
application/json:
schema:
$ref: '#/components/schemas/APICitationsResponse'
'401':
description: Unauthorized - API key is missing, invalid, or inactive.
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
'404':
description: Not Found - The source statement group with the specified ID does not exist.
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
'429':
description: Too Many Requests - Rate limit exceeded.
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
'500':
description: Internal Server Error.
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
'503':
description: Service Unavailable.
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'