Skip to content

Commit db8fe5b

Browse files
Enhance README.md with updated API documentation
- Improved parameter table formatting for clarity and added new optional fields: `enabled`, `url`, and `source_url`. - Updated example POST and cURL commands to reflect the new parameters. - Added details for PATCH/PUT requests, including optional fields for document updates. - Enhanced GET request examples with additional query parameters for filtering and searching documents.
1 parent f496d73 commit db8fe5b

File tree

1 file changed

+52
-11
lines changed

1 file changed

+52
-11
lines changed

README.md

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -425,12 +425,15 @@ Each object in the `questions` array includes:
425425
426426
##### Parameters
427427
428-
> | name | type | data type | description |
429-
> |-----------|-----------|-------------------------|-----------------------------------------------------------------------|
430-
> | document | required | text | The content of the document. 10,000 token limit. |
431-
> | title | required | text | The title of the document |
432-
> | library_id | required | text | The ID of the library to which this document will be added |
433-
> | external_id | optional | text | A unique ID provided by the client. If a POST request includes the same external_id as an existing record, the record will be updated instead of created. |
428+
> | name | type | data type | description |
429+
> |-------------|----------|-----------|---------------------------------------------------------------------------------------------------------------------------------------------|
430+
> | document | required | text | The content of the document. 10,000 token limit. |
431+
> | title | required | text | The title of the document. |
432+
> | library_id | required | text | The ID of the library to which this document will be added. |
433+
> | external_id | optional | text | A unique ID provided by the client. If a POST includes the same external_id as an existing record, the record will be updated instead of created. |
434+
> | enabled | optional | boolean | Whether the document is enabled. |
435+
> | url | optional | text | URL for the document. |
436+
> | source_url | optional | text | Source URL for the document. |
434437
435438
##### Example POST Data
436439
Make sure you have the top level "document" attribute.
@@ -439,6 +442,10 @@ Make sure you have the top level "document" attribute.
439442
> "document": "Restart your computer to fix it.",
440443
> "title": "How to fix a computer",
441444
> "library_id": 23,
445+
> "external_id": "optional_unique_id",
446+
> "enabled": true,
447+
> "url": "https://example.com/doc",
448+
> "source_url": "https://example.com/source"
442449
> }
443450
> ```
444451
@@ -452,7 +459,31 @@ Make sure you have the top level "document" attribute.
452459
##### Example cURL
453460
454461
> ```javascript
455-
> curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <token>" -d '{"document": {"document":"Document Content", "library_id":"your_library_id", "external_id":"optional_unique_id"}}' http://localhost:3000/api/v1/documents
462+
> curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <token>" -d '{"document": {"document":"Document Content", "title":"My Doc", "library_id":"your_library_id", "external_id":"optional_unique_id", "enabled":true, "url":"https://example.com", "source_url":"https://example.com/source"}}' http://localhost:3000/api/v1/documents
463+
> ```
464+
</details>
465+
466+
<details>
467+
<summary><code>PATCH</code> / <code>PUT</code> <code><b>/api/v1/documents/_id_</b></code> <code>Update Document</code></summary>
468+
469+
##### Parameters
470+
471+
Same body as Create; wrap attributes in a top-level `document` object. All fields are optional for update.
472+
473+
> | name | type | data type | description |
474+
> |-------------|----------|-----------|--------------------------------|
475+
> | document | optional | text | The content of the document. |
476+
> | title | optional | text | The title of the document. |
477+
> | library_id | optional | text | The ID of the library. |
478+
> | external_id | optional | text | Client-provided unique ID. |
479+
> | enabled | optional | boolean | Whether the document is enabled. |
480+
> | url | optional | text | URL for the document. |
481+
> | source_url | optional | text | Source URL for the document. |
482+
483+
##### Example cURL
484+
485+
> ```
486+
> curl -X PATCH -H "Content-Type: application/json" -H "Authorization: Bearer <token>" -d '{"document": {"title":"Updated Title", "enabled":false}}' http://localhost:3000/api/v1/documents/<id>
456487
> ```
457488
</details>
458489
@@ -512,9 +543,17 @@ The `document` object includes:
512543
513544
##### Parameters
514545
515-
| name | type | data type | description |
516-
|-------|----------|-----------|---------------------------------|
517-
| page | optional | integer | The page number to retrieve. Defaults to 1. |
546+
| name | type | data type | description |
547+
|--------------|----------|-----------|---------------------------------------------------------------------------------------------------------------------------------------------|
548+
| page | optional | integer | The page number to retrieve. Defaults to 1. |
549+
| per_page | optional | integer | Number of documents per page. Defaults to 10. |
550+
| library_id | optional | integer | Filter documents by library ID. |
551+
| show_deleted | optional | string | `true` = include deleted; `only` = only deleted documents; omit = exclude deleted (default). |
552+
| since | optional | string | Return documents with `updated_at` after this time. ISO 8601, RFC 3339, or formats like `YYYY-MM-DD`, `YYYY-MM-DDTHH:MM:SSZ`. |
553+
| until | optional | string | Return documents with `updated_at` before this time. Same date formats as `since`. |
554+
| contains | optional | string | Full-text search: return documents that contain this text (takes priority over `similar_to`). |
555+
| similar_to | optional | string | Semantic search: return documents similar to this text (ignored if `contains` is present). Results ordered by similarity. |
556+
| sort | optional | string | Sort order: `questions` (by questions count desc), `tokens` (by token count desc); default = `updated_at` desc. Ignored when using `contains` or `similar_to`. |
518557
519558
##### Responses
520559
@@ -541,7 +580,9 @@ Each object in the `documents` array includes:
541580
##### Example cURL
542581
543582
>```
544-
>curl -X GET -H "Authorization: Bearer <token>" "http://localhost:3000/api/v1/documents?page=1"
583+
>curl -X GET -H "Authorization: Bearer <token>" "http://localhost:3000/api/v1/documents?page=1&per_page=10&library_id=1&sort=questions"
584+
>curl -X GET -H "Authorization: Bearer <token>" "http://localhost:3000/api/v1/documents?contains=setup&since=2024-01-01T00:00:00Z"
585+
>curl -X GET -H "Authorization: Bearer <token>" "http://localhost:3000/api/v1/documents?similar_to=how+to+configure+falcon"
545586
>```
546587
547588
>```javascript

0 commit comments

Comments
 (0)