summaryrefslogtreecommitdiff
blob: 6227a7fc2695b756484ae39b59f90bb36ae110cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# Jetpack HTTP API

Jetpack's HTTP API is built as an [extension to the WP-API](http://v2.wp-api.org/extending/adding/). Thus, you may find additional information on approaching the API in the [WP API Docs](http://v2.wp-api.org/).

## API Authentication and authorization

The API requests rely on [cookie-based authentication and a specific nonce](http://v2.wp-api.org/guide/authentication/#cookie-authentication)
for requests to be authorized.

### API Request Authorization via nonces

The WP REST API infrastructure requires a nonce for authorizing of the request itself.

Ensure to use the `X-WP-Nonce` header on your request.

```
X-WP-Nonce: e1cff122e1
```

The nonce is being served on the Jetpack admin page by usage of the [wp_localize_script](https://codex.wordpress.org/Function_Reference/wp_localize_script) mechanism for passing values from PHP code to the JS scope. It's created for the action `wp_rest` and made available in the Jetpack Admin Page as:

```
window.Initial_State.WP_API_nonce;
```

The root URL for the the API is found on the same page as:

```
window.Initial_State.WP_API_root;
```

## Discovery

WP-API-compatible [capabilities document](http://v2.wp-api.org/guide/discovery/) for the endpoints registered by Jetpack.

`GET /wp-json/jetpack/v4`

## API Reference

All endpoints return and accept JSON. Make sure you add the proper `content-type` header to your PUT/POST requests sending JSON objects.

```
'Content-type': 'application/json'
```

### Jetpack connection

Operations related to Jetpack's connection to WordPress.com

#### GET /wp-json/jetpack/v4/connection-status

Fetch Jetpack's current connection status.

#### GET /wp-json/jetpack/v4/connect-url

Fetch a fresh WordPress.com URL for connecting the Jetpack installation.

#### GET /wp-json/jetpack/v4/user-connection-data

Fetch the data of the current's user WordPress.com account.

#### POST /wp-json/jetpack/v4/disconnect/site

Disconnect the Jetpack installation from WordPress.com servers.

**This endpoint does not take Body parameters**

#### POST /wp-json/jetpack/v4/recheck-ssl

Check if the site has SSL enabled.

**This endpoint does not take Body parameters**

### Jetpack modules

#### GET /wp-json/jetpack/v4/module/all

Get a list of all Jetpacks modules, its description, other properties and the module's options

#### GET /wp-json/jetpack/v4/module/:module-slug

Get a single module description and properties by its slug.

**URL parameters**

* `module-slug`: {String} The identifier of the module to get info about.

#### POST /wp-json/jetpack/v4/module/:module-slug/active

Activate or deactivate a module by its slug

Accepts a JSON object in the body like:
```
{
	"active": true
}
```

**URL parameters**

* `module-slug`: {String} The identifier of the module on which to act.

**Body parameters**

* `active`: {Boolean} Send false to deactivate the module.


#### POST /wp-json/jetpack/v4/module/activate

Activate several modules at a time by their slug

**Body parameters**

* `modules`: {Array} An array of strings of identifiers of the modules to activate

```
{
	"modules": [ "protect", "monitor", "likes" ]
}
```

#### POST /wp-json/jetpack/v4/module/:module-slug

Update an option's value for a module

**URL parameters**

* `module-slug`: {String} The identifier of the module on which to act.

**Body parameters**

* Accepts a simple object with the key of the option to update and the new value.

Accepts a JSON object in the body like:
```
{
	"option-key": "new-option-value"
}
```

### Jetpack miscellaneous settings

### GET /wp-json/jetpack/v4/settings

Fetch a list of Jetpack settings not related to a particular module.

### POST /wp-json/jetpack/v4/settings/update

Update a setting value

**Body parameters**

* Accepts a simple object with the key of the setting to update and the new value.

Accepts a JSON object in the body like:
```
{
	"setting-key": "new-setting-value"
}
```

#### POST /wp-json/jetpack/v4/jumpstart/activate

Activate Jumpstart turning on some options and settings to a recommended state.

**This endpoint does not take Body parameters**

#### POST /wp-json/jetpack/v4/jumpstart/deactivate

Deactivate Jumpstart reverting options to their default state.

**This endpoint does not take Body parameters**

#### POST /wp-json/jetpack/v4/reset/:options_or_modules

Reset  Jetpack module options or Jetpack modules activation state to default values.

**URL parameters**

* `options_or_modules`: {String} Available values:
	* `"options"`: all the modules' options will be re-set to their default values.
	* `"modules"`: the modules activation state will be reset to their defaults.

	**This endpoint does not take Body parameters**


### Users

Operations related to the site's users linked to WordPress.com accounts.

#### POST /wp-json/jetpack/v4/unlink

Unlink current user from the related WordPress.com account.

**This endpoint does not take Body parameters**

### Site information

Operations related to information about the site.

### Jetpack notices

#### POST /wp-json/jetpack/v4/notice/:notice/dismiss

Dismiss a Jetpack notice by Id.

**URL parameters**

* `notice`: {String} The identifier of the notice to dismiss. Possible values:
	* `"feedback_dash_request"`
	* `"welcome"`.

** HTTP Status codes**

* `404` - When `:notice` is not valid or absent

#### GET /wp-json/jetpack/v4/site

Get current site data

### Protect module related operations

##### GET /wp-json/jetpack/v4/module/protect/count/get

Get count of blocked attacks by Protect.

### Monitor module related operations

#### GET /wp-json/jetpack/v4/module/monitor/downtime/last

Get from the Monitor module, the last time the site was down.

### Verification Tools module related operations

#### GET /wp-json/jetpack/v4/module/verification-tools/services

Get services that this site is verified with.

### Site's plugins related operations

#### GET /wp-json/jetpack/v4/updates/plugins

Get number of updated available for currently installed WordPress plugins.

### Akismet related operations

#### GET /wp-json/jetpack/v4/akismet/stats/get

Get stats from Akismet filtered spam.

### VaultPress options

#### GET /wp-json/jetpack/v4/module/vaultpress/data

get date of last backup or status and information about actions for user to take.