You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* docs: update API style guide
Bringing in REST API guidance
* docs: feedback implemented
Clarified responsibilities around snippets (dev vs. writer)
Added link to Open Payments style guide
Fixed broken link in ChunkedSnippet page
This guide is designed for writers and contributors involved in documenting our APIs, which use both GraphQL and REST API technologies.
11
11
12
-
At Interledger, we maintain multiple repositories that encompass a variety of projects, each serving different purposes in our ecosystem. This style guide aims to provide a cohesive framework for documenting these APIs so that our docs are clear, consistent, and aligned with our standards.
12
+
At Interledger, we maintain multiple repositories that encompass a variety of projects, each serving different purposes across our ecosystem. This style guide aims to provide a cohesive framework for documenting these APIs so that our docs are clear, consistent, and aligned with our standards.
13
13
14
14
## GraphQL
15
15
@@ -123,7 +123,7 @@ Before this style guide was created, there were older GraphQL examples that, in
123
123
}
124
124
```
125
125
</TabItem>
126
-
<TabItem label="Arguments">
126
+
<TabItem label="Variables">
127
127
```json
128
128
{
129
129
"input": {
@@ -163,7 +163,7 @@ Before this style guide was created, there were older GraphQL examples that, in
163
163
}
164
164
```
165
165
</TabItem>
166
-
<TabItemlabel="Arguments">
166
+
<TabItemlabel="Variables">
167
167
```json
168
168
{
169
169
"input": {
@@ -191,4 +191,87 @@ Before this style guide was created, there were older GraphQL examples that, in
191
191
192
192
## REST API
193
193
194
-
Coming soon
194
+
From [restfulapi.net](https://restfulapi.net/), a REST API (Representational State Transfer) provides a standardized way to interact with resources using predictable HTTP requests (GET, POST, PUT, DELETE). REST APIs are designed for interoperability and human readability, enabling developers to work with predictable resource paths and standardized data formats such as JSON. Each endpoint represents a resource, and responses use standard HTTP status codes to indicate success or failure.
195
+
196
+
For more in-depth information about REST APIs, take a look at the following resources:
In [Open Payments](https://openpayments.dev/), REST APIs expose operations such as creating incoming and outgoing payments, requesting quotes, and handling authentication. Each follows conventional HTTP request/response semantics defined in our [OpenAPI specifications](https://github.com/interledger/open-payments-specifications).
203
+
204
+
### Documenting REST API examples
205
+
206
+
Our REST API examples appear in two primary contexts within the Open Payments docs:
207
+
208
+
1.[SDK pages](https://openpayments.dev/sdk/before-you-begin/): Focused, single-operation walkthroughs showing how to call individual endpoints (for example, creating an incoming payment)
209
+
2.[Guide pages](https://openpayments.dev/guides/accept-otp-online-purchase/): Broader workflows that combine multiple operations into real world end-to-end use cases (for example, accept a one-time payment for an online purchase)
210
+
211
+
Although both types of content reference the same underlying API endpoints, the way examples are embedded and presented differs slightly. This section explains how to structure and format these examples consistently.
212
+
213
+
:::note
214
+
When writing or updating Open Payments SDK and guide pages, refer also to the [Open Payments style guide](/content/openpayments). It defines higher‑level conventions such as naming, formatting, and guide structure that complement the REST‑specific example guidance below.
215
+
:::
216
+
217
+
#### SDK pages
218
+
219
+
Each SDK page demonstrates how a single API operation is implemented across multiple SDKs. These examples are presented in a multi-language tabbed interface, where each programming language has its own `<TabItem>` component.
220
+
221
+
Like the GraphQL examples above, we're using the built-in Starlight [`<Tabs>` and `<TabItem>`](https://starlight.astro.build/components/tabs/) components.
222
+
223
+
:::tip
224
+
Make sure you import the `<Tabs>` and `<TabItem>` components to your MDX file like so:
225
+
226
+
`import { Tabs, TabItem } from '@astrojs/starlight/components'`
227
+
:::
228
+
229
+
##### Using the tabbed interface
230
+
231
+
As stated earlier, the `<Tabs>` component is wrapped around all language examples, and each language is inside its own `<TabItem>` component. Writers do not edit the code examples themselves. Developers maintain those code snippets in their respective SDK repositories, and writers embed them into SDK pages with [`<ChunkedSnippet>`](/oppm/chunkedsnippet/) components. It's our role to make sure that the structure, order, and labeling of the tabs are consistent across all SDK pages.
232
+
233
+
- Maintain a consistent tab order (TypeScript/JavaScript, Rust, PHP)
234
+
- Each `<TabItem>` label should include both the language name and its [corresponding icon](https://starlight.astro.build/reference/icons/#all-icons) when available (for example, `icon="seti:javascript"`)
235
+
- Use [`<ChunkedSnippet>`](/oppm/chunkedsnippet/) to import maintained code blocks directly from SDK repositories
These conventions ensure a consistent presentation across all SDK examples, even as we add new languages.
254
+
255
+
#### Guide pages
256
+
257
+
Open Payments developer guides demonstrate complete workflows that combine multiple REST API operations. Each step typically shows one request/response sequence.
258
+
259
+
Writers should follow the broader framework in the [Open Payments style guide](/content/openpayments/#developer-guides) for page elements like the page summary, scenario, endpoints list, and the steps in the guide. That guide also defines the formatting details for [API requests](/content/openpayments/#code-for-requests) and [API responses](/content/openpayments/#code-for-responses).
260
+
261
+
Keep both request and response examples visually lightweight and predictable. Each should fit comfortably within a single screen view so readers can understand an operation at a glance. Refer to the following tips for both example requests and responses.
262
+
263
+
##### API request considerations
264
+
265
+
Example API requests should illustrate the endpoint, HTTP method, and relevant data.
266
+
267
+
- Keep payloads brief and realistic
268
+
- Include the parameters that can influence the specific response being demonstrated
269
+
- When different endpoints share common data (like wallet addresses or grants), display those values consistently throughout the guide so readers can easily recognize them
270
+
271
+
##### API response considerations
272
+
273
+
Example API responses should represent what relevant data comes back from the API, and it doesn't always have to include a full payload.
274
+
275
+
- Emphasize what changed or what was created as a result of the request (for example, a new ID that was generated or a status that changed)
276
+
- Trim unrelated fields to keep the focus on the result shown
277
+
- Follow the same component pattern as SDK pages: a `<details>` block labeled "Example response" containing a short explanatory line and a `json wrap` block that matches the OpenAPI spec
Copy file name to clipboardExpand all lines: src/content/docs/content/openpayments.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -127,7 +127,7 @@ If the guide mentions optional APIs, exclude them from this list. This list is w
127
127
Request snippets should come from a developer. If the developer is nice enough to add the snippets to the doc, review the markdown to make sure it's formatted correctly.
128
128
129
129
* Each step should use a synced Tabs component (`<Tabs syncKey="lang">`).
130
-
* Each language should have its own tab and include the lang's icon, if available.
130
+
* Each language should have its own tab and include the [lang's icon](https://starlight.astro.build/reference/icons/#all-icons), if available.
131
131
* Each code block should specify the lang and use the `wrap` property (` ```ts wrap `).
132
132
133
133
Update each snippet, when possible, to be specific to your scenario. Look at other guides for examples. You might need a developer to help with parts of it.
Copy file name to clipboardExpand all lines: src/content/docs/oppm/chunkedsnippet.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,4 +33,4 @@ Use the `<ChunkedSnippet>` component within your content like so:
33
33
34
34
## Working example
35
35
36
-
Refer to the TypeScript code snippets within the Open Payments documentation for [Get wallet address information](https://openpayments.guide/snippets/wallet-get-info/#prerequisites). The raw source file is located [here](https://raw.githubusercontent.com/interledger/open-payments-snippets/main/wallet-address/wallet-address-get.ts).
36
+
Refer to the TypeScript code snippets within the Open Payments documentation for [Get wallet address information](https://openpayments.dev/sdk/wallet-get-info/). The raw source file is located [here](https://raw.githubusercontent.com/interledger/open-payments-snippets/main/wallet-address/wallet-address-get.ts).
0 commit comments