Skip to content
This repository was archived by the owner on Oct 10, 2022. It is now read-only.

Commit faf831b

Browse files
authored
Merge pull request #82 from netlify/docs/update-readme
Improve `README`
2 parents 9e52e7b + fd77ea2 commit faf831b

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

README.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![npm version][npm-img]][npm] [![build status][build-img]][build]
44
[![coverage][coverage-img]][coverage] [![dependencies][david-img]][david] [![downloads][dl-img]][dl]
55

6-
A Netlify [open-api](https://github.com/netlify/open-api) client that works in the browser and Node.js.
6+
A Netlify [OpenAPI](https://github.com/netlify/open-api) client that works in the browser and Node.js.
77

88
## Usage
99

@@ -13,7 +13,7 @@ const client = new NetlifyAPI('1234myAccessToken')
1313
const sites = await client.listSites()
1414
```
1515

16-
## Using Open API operations
16+
## Using OpenAPI operations
1717

1818
```js
1919
const NetlifyAPI = require('netlify')
@@ -52,8 +52,9 @@ Create a new instance of the Netlify API client with the provided `accessToken`.
5252
scheme: 'https',
5353
host: 'api.netlify.com',
5454
pathPrefix: '/api/v1',
55+
accessToken: '1234myAccessToken',
5556
globalParams: {} // parameters you want available for every request.
56-
// Global params are only sent of the open-api spec specifies the provided params.
57+
// Global params are only sent of the OpenAPI spec specifies the provided params.
5758
}
5859
```
5960

@@ -65,19 +66,19 @@ A setter/getter that returns the `accessToken` that the client is configured to
6566

6667
A getter that returns the formatted base URL of the endpoint the client is configured to use.
6768

68-
### Open API Client methods
69+
### OpenAPI Client methods
6970

70-
The client is dynamically generated from the [open-api](https://github.com/netlify/open-api) definition file. Each method is is named after the `operationId` name of each operation. **To see list of available operations see the [open-api website](https://open-api.netlify.com/)**.
71+
The client is dynamically generated from the [OpenAPI](https://github.com/netlify/open-api) definition file. Each method is is named after the `operationId` name of each operation. **To see a list of available operations, please see the [OpenAPI website](https://open-api.netlify.com/)**.
7172

72-
Every open-api operation has the following signature:
73+
Every OpenAPI operation has the following signature:
7374

74-
#### `promise(response) = client.operationId([params], [opts])`
75+
#### `response = await client.operationId([params], [opts])`
7576

76-
Perform a call to the given endpoint corresponding with the `operationId`. Returns promise that will resolve with the body of the response, or reject with an error with details about the request attached. Rejects if the `status` > 400.
77+
Performs a call to the given endpoint corresponding with the `operationId`. Returns a promise resolved with the body of the response, or rejected with an error with the details about the request attached. Rejects if the `status` > 400.
7778

7879
- `params` is an object that includes any of the required or optional endpoint parameters.
79-
- `params.body` should be an object which gets serialized to JSON automatically. Any object can live here but refer to the open-api specification for allowed fields in a particular request body.
80-
- If the endpoint accepts `binary`, `params.body` can be a Node.js readable stream or stream ctor (e.g. `() => fs.createReadStream('./foo')`). A Stream ctor function is required to support rate limit retry.
80+
- `params.body` should be an object which gets serialized to JSON automatically. Any object can live here but refer to the OpenAPI specification for allowed fields in a particular request body. It can also be a function returning an object.
81+
- If the endpoint accepts `binary`, `params.body` can be a Node.js readable stream or a function returning one (e.g. `() => fs.createReadStream('./foo')`). Using a function is recommended.
8182

8283
```js
8384
// example params
@@ -90,7 +91,7 @@ Perform a call to the given endpoint corresponding with the `operationId`. Retur
9091
}
9192
```
9293

93-
Optional `opts` can include any property you want passed to `node-fetch`. The `headers` property is merged with some `defaultHeaders`.
94+
Optional `opts` can include any property you want passed to [`node-fetch`](https://github.com/bitinn/node-fetch). The `headers` property is merged with some `defaultHeaders`.
9495

9596
```js
9697
// example opts
@@ -119,13 +120,13 @@ async function getSomeData() {
119120
}
120121
```
121122

122-
If the request response includes `json` in the `contentType` header, fetch will deserialize the JSON body. Otherwise the `text` of the response is returned.
123+
If the response includes `json` in the `contentType` header, fetch will deserialize the JSON body. Otherwise the `text` of the response is returned.
123124

124125
### API Flow Methods
125126

126127
Some methods have been added in addition to the open API operations that make certain actions simpler to perform.
127128

128-
#### `promise(accessToken) = client.getAccessToken(ticket, [opts])`
129+
#### `accessToken = await client.getAccessToken(ticket, [opts])`
129130

130131
Pass in a [`ticket`](https://open-api.netlify.com/#model-ticket) and get back an `accessToken`. Call this with the response from a `client.createTicket({ client_id })` call. Automatically sets the `accessToken` to `this.accessToken` and returns `accessToken` for the consumer to save for later.
131132

@@ -154,9 +155,9 @@ async function login() {
154155
}
155156
```
156157

157-
#### `promise(deploy) = client.deploy(siteId, buildDir, [opts])`
158+
#### `deploy = await client.deploy(siteId, buildDir, [opts])`
158159

159-
**Node.js Only**: Pass in a `siteId`, a `buildDir` (the folder you want to deploy) and an options object to deploy the contents of that folder.
160+
**Node.js only**: Pass in a `siteId`, a `buildDir` (the folder you want to deploy) and an options object to deploy the contents of that folder.
160161
Sometimes this method needs to write to a `tmpDir`. By default `tmpDir` is a folder in the system temporary directory.
161162

162163
The following paths can be passed in the options:

0 commit comments

Comments
 (0)