Skip to content

Commit 121f2b5

Browse files
muetyjaebradley
andauthored
feat: support custom api urls (#102)
Co-authored-by: Jae Bradley <[email protected]>
1 parent f50c0f8 commit 121f2b5

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ npm install wakatime-client --save
2323
## API
2424

2525
* [Create Instance Using API Key](#create-instance-using-api-key)
26+
* [Custom Base URLs](#custom-base-urls)
2627
* [`getUser`](#getuser)
2728
* [`getMe`](#getme)
2829
* [`getTeams`](#getteams)
@@ -68,6 +69,13 @@ import { WakaTimeClient } from 'wakatime-client';
6869
const client = new WakaTimeClient('some api key');
6970
```
7071

72+
#### Custom Base URLs
73+
```javascript
74+
import { WakaTimeClient } from 'wakatime-client';
75+
76+
const client = new WakaTimeClient('some api key', 'https://wakapi.dev/api/v1');
77+
```
78+
7179
### `getUser`
7280

7381
Get details for user

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ const rangeQueryParameters = Object.freeze({
1515
});
1616

1717
class WakaTimeClient {
18-
constructor(apiKey) {
18+
constructor(apiKey, baseURL = 'https://wakatime.com/api/v1/') {
1919
this.apiKey = apiKey;
2020
this.axiosConfiguration = axios.create({
21-
baseURL: 'https://wakatime.com/api/v1/',
21+
baseURL,
2222
// Base-64 encode the API Key
2323
// https://wakatime.com/developers#introduction
2424
headers: { Authorization: `Basic ${Buffer.from(this.apiKey).toString('base64')}` },

0 commit comments

Comments
 (0)