-
Notifications
You must be signed in to change notification settings - Fork 93
feat: ApiExecutor docs #1241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SoulPancake
wants to merge
6
commits into
main
Choose a base branch
from
feat/apiexecutor-docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: ApiExecutor docs #1241
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
032f081
feat: apiexecutor docs
SoulPancake 4712d56
fix: address comments
SoulPancake 2fdf385
feat: refactor address comments and add JS example dir
SoulPancake 2a4fed0
fix: apply suggestions from review
SoulPancake c12b366
Merge branch 'main' into feat/apiexecutor-docs
SoulPancake 193ed5c
fix: lint
SoulPancake File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
55 changes: 41 additions & 14 deletions
55
docs/content/getting-started/setup-openfga/configuration.mdx
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| --- | ||
| title: Calling Other Endpoints | ||
| sidebar_position: 9 | ||
| slug: /interacting/raw-api-requests | ||
| description: Making raw HTTP calls to OpenFGA endpoints not yet wrapped by the SDK | ||
| --- | ||
|
|
||
| import { | ||
| DocumentationNotice, | ||
| ExecuteApiRequestViewer, | ||
| ExecuteApiRequestPathParamsViewer, | ||
| ExecuteApiRequestDecodeViewer, | ||
| ExecuteApiRequestStreamingViewer, | ||
| ExecuteApiRequestErrorViewer, | ||
| ProductName, | ||
| ProductNameFormat, | ||
| RelatedSection, | ||
| SdkSetupPrerequisite, | ||
| } from '@components/Docs'; | ||
|
|
||
| # Calling Other Endpoints | ||
|
|
||
| <DocumentationNotice /> | ||
|
|
||
| In certain cases you may want to call API endpoints that are not yet available as dedicated methods in the <ProductName format={ProductNameFormat.ShortForm}/> SDK. Every SDK provides an **API Executor** that lets you make raw HTTP calls to any <ProductName format={ProductNameFormat.ShortForm}/> endpoint while still honoring the client configuration — including authentication, telemetry, retries, and error handling. | ||
|
|
||
| ## When to use | ||
|
|
||
| This is useful when: | ||
|
|
||
| - You want to call a **new endpoint** that is not yet supported by the SDK. | ||
| - You are using an **earlier version** of the SDK that doesn't support a particular endpoint, and can't update. | ||
| - You have a **custom endpoint** deployed that extends the <ProductName format={ProductNameFormat.ShortForm}/> API. | ||
|
|
||
| ## Before you start | ||
|
|
||
| <SdkSetupPrerequisite /> | ||
|
|
||
| ## Making a request | ||
|
|
||
| Initialize the SDK client as usual (see [Setup SDK Client](../getting-started/setup-sdk-client.mdx)), then use the API Executor to build and send a request. | ||
|
|
||
| The examples below call a hypothetical custom endpoint (`/stores/{store_id}/custom-endpoint`), but you can use the same pattern for any <ProductName format={ProductNameFormat.ShortForm}/> API path. | ||
|
|
||
| ### Calling a custom endpoint with POST | ||
|
|
||
| <ExecuteApiRequestViewer skipSetup={true} /> | ||
|
|
||
| :::note | ||
| The examples above use `POST`, but the API Executor supports any HTTP method (`GET`, `POST`, `PUT`, `DELETE`, etc.). For `GET` requests, simply omit the `body` parameter. | ||
| ::: | ||
|
|
||
| ### Using path parameters | ||
|
|
||
| Path parameters are specified in the path using `{param_name}` syntax and must be provided via the path parameters option. They are URL-encoded automatically. | ||
|
|
||
| <ExecuteApiRequestPathParamsViewer skipSetup={true} /> | ||
|
|
||
| ### Decoding the response into a typed object | ||
|
|
||
| Some SDKs let you decode the raw response directly into a typed struct or class, avoiding manual JSON parsing. | ||
|
|
||
| <ExecuteApiRequestDecodeViewer skipSetup={true} /> | ||
|
|
||
| ## Streaming requests | ||
|
|
||
| For endpoints that stream results (such as `StreamedListObjects`), use the streaming variant of the API Executor. Streaming endpoints return results incrementally as they are computed, rather than waiting for all results before responding. | ||
|
|
||
| <ExecuteApiRequestStreamingViewer skipSetup={true} /> | ||
|
|
||
| ## Error handling | ||
|
|
||
| Always check the response status and handle errors appropriately. The API Executor preserves the SDK's built-in error handling, but you may want to inspect status codes for custom endpoints. | ||
|
|
||
| <ExecuteApiRequestErrorViewer skipSetup={true} /> | ||
|
|
||
| ## SDK examples | ||
|
|
||
| For complete working examples, refer to the API Executor examples in each SDK repository: | ||
|
|
||
| - [Node.js](https://github.com/openfga/js-sdk/tree/main/example/api-executor) | ||
| - [Go](https://github.com/openfga/go-sdk/tree/main/example/api_executor) | ||
| - [.NET](https://github.com/openfga/dotnet-sdk/tree/main/example/ApiExecutorExample) | ||
| - [Python](https://github.com/openfga/python-sdk/tree/main/example/execute-api-request) | ||
| - [Java](https://github.com/openfga/java-sdk/tree/main/examples/api-executor) | ||
|
|
||
| <RelatedSection | ||
| description="Check the following sections for more on how to interact with the API." | ||
| relatedLinks={[ | ||
| { | ||
| title: 'Setup SDK Client for Store', | ||
| description: 'Learn how to initialize and configure the SDK client.', | ||
| link: '../getting-started/setup-sdk-client', | ||
| id: '../getting-started/setup-sdk-client.mdx', | ||
| }, | ||
| { | ||
| title: 'Install SDK Client', | ||
| description: 'Learn how to install the OpenFGA SDK for your language.', | ||
| link: '../getting-started/install-sdk', | ||
| id: '../getting-started/install-sdk.mdx', | ||
| }, | ||
| { | ||
| title: 'Relationship Queries', | ||
| description: 'An overview of Check, Read, Expand, and ListObjects APIs.', | ||
| link: '../interacting/relationship-queries', | ||
| id: '../interacting/relationship-queries.mdx', | ||
| }, | ||
| ]} | ||
| /> | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.