|
| 1 | +# API Reference template |
| 2 | + |
| 3 | +> The following template is taken from [The Good Docs Project](https://www.thegooddocsproject.dev/template/api-reference) |
| 4 | +> Some adjustments/clarifications have been made in the context of the **SuperTokens** docs. |
| 5 | +
|
| 6 | +## Overview |
| 7 | + |
| 8 | +Use the {product} APIs to {access | customize | program} the {features | functionality}. |
| 9 | + |
| 10 | +### Base URL |
| 11 | + |
| 12 | +```text |
| 13 | +{Provide the base URL of the API. For example: https://api.example.com} |
| 14 | +``` |
| 15 | + |
| 16 | +### Authorization |
| 17 | + |
| 18 | +Authentication and authorization {is | is not} required for requests to these APIs. Supported authentication methods are: |
| 19 | +{ Basic | Digest | OAuth | others} |
| 20 | + |
| 21 | +```text |
| 22 | +{Provide an example request with {Basic | Digest | OAuth | others} authentication.} |
| 23 | +``` |
| 24 | + |
| 25 | +### Version |
| 26 | + |
| 27 | +{This section is optional.} |
| 28 | + |
| 29 | +{Provide the version number using semantic versioning or your product's API versioning scheme. For example: `0.0.1`} |
| 30 | + |
| 31 | +### Pagination |
| 32 | + |
| 33 | +{This section is optional.} |
| 34 | + |
| 35 | +Due to the potentially very large result sets from API calls, responses {are | can be} returned as shorter pages. |
| 36 | + |
| 37 | +Pagination can be customized using {pagination settings}. If not specified, the default values are {values}. |
| 38 | + |
| 39 | +### Rate limiting and throttling |
| 40 | + |
| 41 | +{This section is optional.} |
| 42 | + |
| 43 | +The {product} APIs use a {strategy-name} rate limiting strategy. The maximum number of requests allowed to access a {resource | endpoint |..} is {number} requests per {time period}. |
| 44 | + |
| 45 | +### HTTP status codes |
| 46 | + |
| 47 | +The {product} APIs use the following standard HTTP response codes: |
| 48 | + |
| 49 | +| Status code | Message | Description | |
| 50 | +| ----------- | ----------------- | ------------- | |
| 51 | +| `200 OK` | Request succeeds. | {description} | |
| 52 | +| | | | |
| 53 | +| | | | |
| 54 | + |
| 55 | +### Errors |
| 56 | + |
| 57 | +{This section is optional.} |
| 58 | + |
| 59 | +The {product} APIs use the following error types: |
| 60 | + |
| 61 | +| Error | Description | |
| 62 | +| --------------------------------------- | ---------------- | |
| 63 | +| [{ExampleErrorType}](#exampleerrortype) | {Failure in ...} | |
| 64 | +| | | |
| 65 | +| | | |
| 66 | + |
| 67 | +#### ExampleErrorType |
| 68 | + |
| 69 | +| Field | Type | Description | |
| 70 | +| -------------- | -------- | -------------------------------------------------------------------- | |
| 71 | +| {errorType} | {enum} | {Predefined error codes. Possible enum values are x, y, ..., and z.} | |
| 72 | +| {errorMessage} | {string} | {Additional information about why the error occurs.} | |
| 73 | + |
| 74 | +## {Resource name} |
| 75 | + |
| 76 | +The {resource name} is used to {functionality}. |
| 77 | + |
| 78 | +### Data model |
| 79 | + |
| 80 | +| Attribute | Type | Required? | Description | |
| 81 | +| --------- | ------ | --------- | --------------------------- | |
| 82 | +| {id} | string | Required | {Unique identifier of user} | |
| 83 | +| {name} | string | Optional | {Name of user} | |
| 84 | +| | | | | |
| 85 | + |
| 86 | +### Example |
| 87 | + |
| 88 | +```text |
| 89 | +{Provide an example of the data representation in the format that your project use.} |
| 90 | +``` |
| 91 | + |
| 92 | +### Endpoints |
| 93 | + |
| 94 | +Use the following endpoints to interact with the {resource name} entities. |
| 95 | + |
| 96 | +| Method | Endpoint name | Description | |
| 97 | +| ------ | ---------------------------------------- | ----------------------- | |
| 98 | +| POST | {[Endpoint name A](#link_to_endpoint_a)} | Creates a {resource}. | |
| 99 | +| GET | {[Endpoint name B](#link_to_endpoint_b)} | Retrieves a {resource}. | |
| 100 | +| | | | |
| 101 | + |
| 102 | +## {Endpoint name} |
| 103 | + |
| 104 | +{Provide a one-line description of what the API does. Starts with a verb in the indicative mood. For example, "Retrieves a user by `userID`".} |
| 105 | + |
| 106 | +### Endpoint |
| 107 | + |
| 108 | +```text |
| 109 | +{METHOD} /{request-url}/{{path-parameter}} |
| 110 | +``` |
| 111 | + |
| 112 | +### Description |
| 113 | + |
| 114 | +{Explain what the endpoint does.} |
| 115 | + |
| 116 | +{This paragraph is optional.} This endpoint has been deprecated. Use {the recommended endpoint} instead. For more information about how to migrate to {the recommended endpoint}, see [{the migration guide}](#link). |
| 117 | + |
| 118 | +{This paragraph is optional.} The maximum number of calls to this API endpoint is {number} per minute. For more information about API rate limiting/throttling, see [{the topic}](#example). |
| 119 | + |
| 120 | +### Authorization |
| 121 | + |
| 122 | +The [{authorization method}](#authorization) is required for each API request. |
| 123 | + |
| 124 | +{This paragraph is optional.} Calling this endpoint also requires the {permission-name} permission. |
| 125 | + |
| 126 | +### Request schema |
| 127 | + |
| 128 | +#### Path parameters |
| 129 | + |
| 130 | +{This section is optional.} |
| 131 | + |
| 132 | +| Path parameter | Type | Required? | Description | |
| 133 | +| -------------- | ------ | --------- | --------------------------- | |
| 134 | +| {id} | string | Required | {Unique identifier of user} | |
| 135 | +| | | | | |
| 136 | + |
| 137 | +#### Query parameters |
| 138 | + |
| 139 | +{This section is optional.} |
| 140 | + |
| 141 | +| Query parameter | Type | Required? | Description | |
| 142 | +| --------------- | ---- | --------- | --------------------------------------------------------------------------------- | |
| 143 | +| {pageSize} | int | Optional | {The number of items to be returned in a single request. The default value is N.} | |
| 144 | +| | | | | |
| 145 | + |
| 146 | +#### Header parameters |
| 147 | + |
| 148 | +{This section is optional.} |
| 149 | + |
| 150 | +| Header parameter | Type | Required? | Description | |
| 151 | +| ---------------- | ------ | --------- | ------------------------------------------------ | |
| 152 | +| {Content-Type} | string | Required | {Media type of the resource. Must be an object.} | |
| 153 | +| | | | | |
| 154 | + |
| 155 | +#### Request body |
| 156 | + |
| 157 | +{This section is optional.} |
| 158 | + |
| 159 | +| Field | Type | Required? | Description | |
| 160 | +| ------ | ------ | --------- | ------------------------------- | |
| 161 | +| {id} | string | Required | {Unique identifier of the user} | |
| 162 | +| {name} | string | Optional | {Name of the user} | |
| 163 | + |
| 164 | +### Request example |
| 165 | + |
| 166 | +```text |
| 167 | +{Provide an example of the API request, filled with sample values.} |
| 168 | +``` |
| 169 | + |
| 170 | +### Response schema |
| 171 | + |
| 172 | +| Status code | Schema | Description | |
| 173 | +| ----------- | --------------------------------------- | ---------------------------------------------------------------------------- | |
| 174 | +| `2xx` | [{ExampleDataType}](#data-model) | {Describe the result where the request succeeds.} | |
| 175 | +| `4xx` | [{ExampleErrorType}](#exampleerrortype) | {Describe the result where the request fails with the specified error code.} | |
| 176 | + |
| 177 | +### Response example |
| 178 | + |
| 179 | +```text |
| 180 | +{Provide an example of the API response, filled with sample values.} |
| 181 | +``` |
| 182 | + |
| 183 | +--- |
| 184 | + |
| 185 | +> Explore other templates from [The Good Docs Project](https://thegooddocsproject.dev/). Use our [feedback form](https://thegooddocsproject.dev/feedback/?template=API%20reference) to give feedback on this template. |
0 commit comments