Skip to content
This repository was archived by the owner on Feb 28, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ const client = Figma.Client({
});
```

Or if you need to use a https proxy agent:

```typescript
import * as Figma from 'figma-js';
import { HttpsProxyAgent } from 'https-proxy-agent';

const token = '12345';
const proxyAgent = new HttpsProxyAgent(process.env.https_proxy);

const client = Figma.Client({
accessToken: token,
httpsAgent: proxyAgent,
proxy: false
});
```

### Doing cool things

Once you have instantiated a client, have fun!
Expand Down
10 changes: 8 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// export * from './lib/number';
import * as Figma from './figmaTypes';
export * from './figmaTypes';
import axios, { AxiosInstance, AxiosPromise } from 'axios';
import axios, { AxiosInstance, AxiosPromise, AxiosRequestConfig } from 'axios';

export interface FileParams {
/**
Expand Down Expand Up @@ -107,7 +107,10 @@ export interface PaginationParams {
readonly cursor?: { readonly before?: number; readonly after?: number };
}

export interface ClientOptions {
export interface ClientOptions
extends Readonly<
Pick<AxiosRequestConfig, 'proxy' | 'httpAgent' | 'httpsAgent'>
> {
/** access token returned from OAuth authentication */
readonly accessToken?: string;
/** personal access token obtained from account settings */
Expand Down Expand Up @@ -340,6 +343,9 @@ export const Client = (opts: ClientOptions): ClientInterface => {
};

const client = axios.create({
proxy: opts.proxy,
httpAgent: opts.httpAgent,
httpsAgent: opts.httpsAgent,
baseURL: `https://${opts.apiRoot || 'api.figma.com'}/v1/`,
headers,
});
Expand Down