Skip to content

Commit 31972aa

Browse files
committed
docs: updated README.md
1 parent c96e9a3 commit 31972aa

File tree

2 files changed

+45
-5
lines changed

2 files changed

+45
-5
lines changed

README.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,48 @@ Alternatively, we ship the OpenAPI v2 and v3 spec in the repository:
186186
- OpenAPI v2 spec: [v2.swagger.json](https://github.com/nekomeowww/factorio-rcon-api/blob/main/apis/factorioapi/v2/v2.swagger.json)
187187
- OpenAPI v3 spec: [v2.swagger.v3.yaml](https://github.com/nekomeowww/factorio-rcon-api/blob/main/apis/factorioapi/v2/v2.swagger.v3.yaml)
188188

189+
### SDKs
190+
191+
#### TypeScript / JavaScript
192+
193+
We are now shipping the SDKs for TypeScript for easier integration with the APIs.
194+
195+
##### Installation
196+
197+
```shell
198+
ni factorio-rcon-api-client # from @antfu/ni, can be installed via `npm i -g @antfu/ni`
199+
pnpm i factorio-rcon-api-client
200+
yarn i factorio-rcon-api-client
201+
npm i factorio-rcon-api-client
202+
```
203+
204+
##### Usage
205+
206+
```typescript
207+
// Import the client and the API functions
208+
import { client, v2FactorioConsoleCommandRawPost } from 'factorio-rcon-api-client'
209+
210+
async function main() {
211+
// Set the base URL of the API
212+
client.setConfig({
213+
baseUrl: 'http://localhost:3000',
214+
})
215+
216+
// Call POST /api/v2/factorio/console/command/raw
217+
const res = await v2FactorioConsoleCommandRawPost({
218+
body: {
219+
input: '/help', // The command to run
220+
},
221+
})
222+
223+
console.log(res) // The response from the API
224+
}
225+
226+
main().catch(console.error)
227+
```
228+
189229
> [!TIP]
190-
> Additionally, we can ship the SDKs for Lua, TypeScript and Python (widely used for mods, admin panels, bots) in the future, you are welcome to contribute to the project.
230+
> Additionally, we can ship the SDKs for Lua, and Python (widely used for mods, admin panels, bots) in the future, you are welcome to contribute to the project.
191231
192232
For developers working with the APIs from Factorio RCON API, you can either use the above OpenAPI specs or use Protobuf files to generate types for TypeScript, Python, Go, and many more languages' SDKs with code generators. We are not going to cover all of these in this README, but you can find more information on the internet:
193233

apis/sdk/typescript/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ Generated TypeScript SDK client for [https://github.com/nekomeowww/factorio-rcon
55
## Getting started
66

77
```shell
8-
ni factorio-rcon-api-client -D # from @antfu/ni, can be installed via `npm i -g @antfu/ni`
9-
pnpm i factorio-rcon-api-client -D
10-
yarn i factorio-rcon-api-client -D
11-
npm i factorio-rcon-api-client -D
8+
ni factorio-rcon-api-client # from @antfu/ni, can be installed via `npm i -g @antfu/ni`
9+
pnpm i factorio-rcon-api-client
10+
yarn i factorio-rcon-api-client
11+
npm i factorio-rcon-api-client
1212
```
1313

1414
## Usage

0 commit comments

Comments
 (0)