├── .github └── workflows │ ├── ci.yml │ └── npm-publish.yml ├── .gitignore ├── .npmignore ├── .travis.yml ├── LICENSE ├── README.md ├── demo ├── giant.json ├── index.js └── webpack.config.js ├── index.html ├── mocks └── less.ts ├── package.json ├── rollup.config.js ├── rollup.dev.config.js ├── server.js ├── src ├── helpers.ts ├── index.ts ├── style.less └── style.less.d.ts ├── test └── spec.ts ├── tsconfig.json ├── webpack.config.js └── yarn.lock /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | branches: 9 | - master 10 | 11 | jobs: 12 | build: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Checkout code 16 | uses: actions/checkout@v2 17 | 18 | - name: Setup Node.js 19 | uses: actions/setup-node@v2 20 | with: 21 | node-version: 18 22 | 23 | - name: Install dependencies 24 | run: yarn install 25 | 26 | - name: Run Unit Tests 27 | run: yarn prettier --check . 28 | 29 | - name: Run TypeScript check 30 | run: yarn tsc --noEmit 31 | 32 | - name: Run Unit Tests 33 | run: yarn test 34 | -------------------------------------------------------------------------------- /.github/workflows/npm-publish.yml: -------------------------------------------------------------------------------- 1 | name: npm-publish 2 | on: 3 | push: 4 | branches: 5 | - master 6 | jobs: 7 | gh-pages: 8 | name: Update Github Pages 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Checkout repository 12 | uses: actions/checkout@master 13 | - name: Set up Node.js 14 | uses: actions/setup-node@master 15 | with: 16 | node-version: 18 17 | - name: Install dependencies 18 | run: yarn 19 | - name: Build 20 | run: yarn build 21 | - name: Deploy 22 | uses: peaceiris/actions-gh-pages@v3 23 | with: 24 | github_token: ${{ secrets.GITHUB_TOKEN }} 25 | publish_dir: . 26 | publish_branch: gh-pages 27 | npm-publish: 28 | name: npm-publish 29 | runs-on: ubuntu-latest 30 | steps: 31 | - name: Checkout repository 32 | uses: actions/checkout@master 33 | - name: Set up Node.js 34 | uses: actions/setup-node@master 35 | with: 36 | node-version: 18 37 | - name: Install dependencies 38 | run: yarn 39 | - name: Build 40 | run: yarn build 41 | - name: Publish 42 | uses: Github-Actions-Community/merge-release@main 43 | env: 44 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 45 | NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} 46 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | node_modules 3 | *.log 4 | 5 | dist 6 | package-lock.json 7 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .git 2 | .github 3 | mocks 4 | test 5 | src 6 | !dist/src 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: stable 3 | cache: yarn 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Mohsen Azimi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JSON Formatter 2 | 3 | > Render JSON objects in HTML with a **collapsible** navigation. 4 | 5 | **Check out [`` Custom Element](https://github.com/mohsen1/pretty-json) for a more portable and light solution** 6 | 7 | ## Usage 8 | 9 | **[Live Demo](http://azimi.me/json-formatter-js/)** 10 | 11 | Install via npm 12 | 13 | ```shell 14 | npm install --save json-formatter-js 15 | ``` 16 | 17 | Include `json-formatter.js` from the `dist` folder in your page. 18 | 19 | ```js 20 | import JSONFormatter from "json-formatter-js"; 21 | 22 | const myJSON = { ans: 42 }; 23 | 24 | const formatter = new JSONFormatter(myJSON); 25 | 26 | document.body.appendChild(formatter.render()); 27 | ``` 28 | 29 | ## API 30 | 31 | ### `JSONFormatter(json [, open [, config] ])` 32 | 33 | #### `json` (`Object`) - **required** 34 | 35 | The JSON object you want to render. It has to be an object or array. Do NOT pass a raw JSON string. 36 | 37 | #### `open` (`Number`) 38 | 39 | Default: `1` 40 | This number indicates up to how many levels the rendered tree should expand. Set it to `0` to make the whole tree collapsed or set it to `Infinity` to expand the tree deeply. 41 | 42 | #### `config` (`Object`) 43 | 44 | Default: 45 | 46 | ```js 47 | { 48 | hoverPreviewEnabled: false, 49 | hoverPreviewArrayCount: 100, 50 | hoverPreviewFieldCount: 5, 51 | animateOpen: true, 52 | animateClose: true, 53 | theme: null, 54 | useToJSON: true, 55 | sortPropertiesBy: null, 56 | maxArrayItems: 100, 57 | exposePath: false 58 | } 59 | ``` 60 | 61 | Available configurations: 62 | 63 | ##### Hover Preview 64 | 65 | - `hoverPreviewEnabled`: enable preview on hover. 66 | - `hoverPreviewArrayCount`: number of array items to show in preview. Any array larger than this number will be shown as `Array[XXX]` where `XXX` is the length of the array. 67 | - `hoverPreviewFieldCount`: number of object properties to show for object preview. Any object with more properties than this number will be truncated. 68 | 69 | ##### Theme 70 | 71 | - `theme`: a string that can be any of these options: `['dark']`. Look at [`src/style.less`](src/style.less) for making new themes. 72 | 73 | ##### Animation 74 | 75 | - `animateOpen`: enable animation when expanding a JSON object. True by default. 76 | - `animateClose`: enable animation when closing a JSON object. True by default. 77 | 78 | ##### Rendering Options 79 | 80 | - `useToJSON`: use the `toJSON` method to render an object as a string, if available. Useful for objects like `Date` or Mongo's `ObjectID` that might make more sense as a string than as empty objects. True by default. 81 | - `sortPropertiesBy`: use the given sorting function to deeply sort the object properties. 82 | - `maxArrayItems`: use to split arrays into multiple smaller groups. This value defines the size of each group. If the length of the array is less than this number, no groups are created. It's the same behavior as the Webkit developer tool's console. 83 | - `exposePath`: add an array of keys to each node dataset so it is possible to correlate nodes to the original JSON. 84 | 85 | ### `openAtDepth([depth])` 86 | 87 | ```js 88 | const formatter = new JSONFormatter({ ... }); 89 | document.body.appendChild(formatter.render()); 90 | formatter.openAtDepth(3); 91 | ``` 92 | 93 | #### `depth` (`Number`) 94 | 95 | Default: `1` 96 | This number indicates up to how many levels the rendered tree should open. It allows use cases such as collapsing all levels (with value `0`) or expanding all levels (with value `Infinity`). 97 | 98 | ## Development 99 | 100 | Install the dependencies: 101 | 102 | ```shell 103 | npm install 104 | ``` 105 | 106 | Run the dev server: 107 | 108 | ```shell 109 | npm run dev 110 | ``` 111 | 112 | ### Running Tests 113 | 114 | **Once:** 115 | 116 | ```shell 117 | npm test 118 | ``` 119 | 120 | ## License 121 | 122 | [MIT](./LICENSE) 123 | -------------------------------------------------------------------------------- /demo/giant.json: -------------------------------------------------------------------------------- 1 | { 2 | "swagger": "2.0", 3 | "info": { 4 | "version": "1.1", 5 | "title": "Twitter REST API This is interesting in so many cases" 6 | }, 7 | "host": "api.twitter.com", 8 | "basePath": "/1.1", 9 | "schemes": ["http", "https"], 10 | "consumes": ["application/json"], 11 | "produces": ["application/json"], 12 | "securityDefinitions": { 13 | "oauth": { 14 | "type": "oauth2", 15 | "flow": "implicit", 16 | "authorizationUrl": "https://twitter.com/oauth/authorize/?client_id=CLIENT-ID&redirect_uri=REDIRECT-URI&response_type=token", 17 | "scopes": { 18 | "basic": "to read any and all data related to twitter this is interesting op\n" 19 | } 20 | } 21 | }, 22 | "security": [ 23 | { 24 | "oauth": ["basic"] 25 | } 26 | ], 27 | "paths": { 28 | "/statuses/mentions_timeline": { 29 | "get": { 30 | "description": "Returns the 20 most recent mentions for the authenticating kkkkkkk user", 31 | "security": [ 32 | { 33 | "oauth": ["basic"] 34 | } 35 | ], 36 | "parameters": [ 37 | { 38 | "name": "count", 39 | "in": "query", 40 | "description": "Specifies the number of tweets to try and retrieve", 41 | "required": false, 42 | "type": "string" 43 | }, 44 | { 45 | "name": "since_id", 46 | "in": "query", 47 | "description": "Returns result with an ID greater than the specified ID", 48 | "required": false, 49 | "type": "string" 50 | }, 51 | { 52 | "name": "max_id", 53 | "in": "query", 54 | "description": "Returns results with an ID less than or equal to the specified ID", 55 | "required": false, 56 | "type": "string" 57 | }, 58 | { 59 | "name": "trim_user", 60 | "in": "query", 61 | "description": "When set to either true, t or 1, each tweet returned in a timeline will include a user object", 62 | "required": false, 63 | "type": "string" 64 | }, 65 | { 66 | "name": "contributor_details", 67 | "in": "query", 68 | "description": "This parameter enhances the contributors element of the status response", 69 | "required": false, 70 | "type": "string" 71 | }, 72 | { 73 | "name": "include_entities", 74 | "in": "query", 75 | "description": "The entities node will be disincluded when set to false", 76 | "required": false, 77 | "type": "string" 78 | } 79 | ], 80 | "responses": { 81 | "200": { 82 | "description": "Success", 83 | "schema": { 84 | "type": "array", 85 | "items": { 86 | "$ref": "#/definitions/Tweets" 87 | } 88 | } 89 | } 90 | } 91 | } 92 | }, 93 | "/statuses/user_timeline": { 94 | "get": { 95 | "description": "Returns a collection of the most recent Tweets posted by the User", 96 | "security": [ 97 | { 98 | "oauth": ["basic"] 99 | } 100 | ], 101 | "parameters": [ 102 | { 103 | "name": "count", 104 | "in": "query", 105 | "description": "Specifies the number of tweets to try and rppetrieve", 106 | "required": false, 107 | "type": "string" 108 | }, 109 | { 110 | "name": "since_id", 111 | "in": "query", 112 | "description": "Returns result with an ID greater than the specified ID", 113 | "required": false, 114 | "type": "string" 115 | }, 116 | { 117 | "name": "max_id", 118 | "in": "query", 119 | "description": "Returns results with an ID less than or equal to the specified ID", 120 | "required": false, 121 | "type": "string" 122 | }, 123 | { 124 | "name": "trim_user", 125 | "in": "query", 126 | "description": "When set to either true, t or 1, each tweet returned in a timeline will include a user object", 127 | "required": false, 128 | "type": "string" 129 | }, 130 | { 131 | "name": "exclude_replies", 132 | "in": "query", 133 | "description": "This paramters will prevent from appearing in the returned timeline", 134 | "required": false, 135 | "type": "boolean" 136 | }, 137 | { 138 | "name": "contributor_details", 139 | "in": "query", 140 | "description": "This paramters enhances the contributors element of the status response to include the screen_name of the contributor", 141 | "required": false, 142 | "type": "boolean" 143 | }, 144 | { 145 | "name": "include_rts", 146 | "in": "query", 147 | "description": "When set to false, the timeline will strip any native retweet", 148 | "required": false, 149 | "type": "boolean" 150 | } 151 | ], 152 | "responses": { 153 | "200": { 154 | "description": "Success", 155 | "schema": { 156 | "type": "array", 157 | "items": { 158 | "$ref": "#/definitions/Tweets" 159 | } 160 | } 161 | } 162 | } 163 | } 164 | }, 165 | "/statuses/home_timeline": { 166 | "get": { 167 | "description": "Returns a collection of the most recent Tweets", 168 | "security": [ 169 | { 170 | "oauth": ["basic"] 171 | } 172 | ], 173 | "parameters": [ 174 | { 175 | "name": "since_id", 176 | "in": "query", 177 | "description": "Returns result with an ID greater than the specified ID", 178 | "required": false, 179 | "type": "string" 180 | }, 181 | { 182 | "name": "max_id", 183 | "in": "query", 184 | "description": "Returns results with an ID less than or equal to the specified ID", 185 | "required": false, 186 | "type": "string" 187 | }, 188 | { 189 | "name": "trim_user", 190 | "in": "query", 191 | "description": "When set to either true, t or 1, each tweet returned in a timeline will include a user object", 192 | "required": false, 193 | "type": "string" 194 | }, 195 | { 196 | "name": "exclude_replies", 197 | "in": "query", 198 | "description": "This paramters will prevent from appearing in the returned timeline", 199 | "required": false, 200 | "type": "boolean" 201 | }, 202 | { 203 | "name": "contributor_details", 204 | "in": "query", 205 | "description": "This paramters enhances the contributors element of the status response to include the screen_name of the contributor", 206 | "required": false, 207 | "type": "boolean" 208 | } 209 | ], 210 | "responses": { 211 | "200": { 212 | "description": "Success", 213 | "schema": { 214 | "type": "array", 215 | "items": { 216 | "$ref": "#/definitions/Tweets" 217 | } 218 | } 219 | } 220 | } 221 | } 222 | }, 223 | "/statuses/retweets/{id}": { 224 | "post": { 225 | "description": "Retweens a tweet", 226 | "security": [ 227 | { 228 | "oauth": ["basic"] 229 | } 230 | ], 231 | "parameters": [ 232 | { 233 | "name": "id", 234 | "in": "path", 235 | "description": "The numerical ID of the desired status", 236 | "required": true, 237 | "type": "string" 238 | }, 239 | { 240 | "name": "trim_user", 241 | "in": "query", 242 | "description": "When set to either true, t or 1, each tweet returned in a timeline will include a user object", 243 | "required": false, 244 | "type": "string" 245 | } 246 | ], 247 | "responses": { 248 | "200": { 249 | "description": "Success", 250 | "schema": { 251 | "$ref": "#/definitions/Tweets" 252 | } 253 | } 254 | } 255 | } 256 | }, 257 | "/statuses/show/{id}": { 258 | "get": { 259 | "description": "Retruns a single Tweet", 260 | "security": [ 261 | { 262 | "oauth": ["basic"] 263 | } 264 | ], 265 | "parameters": [ 266 | { 267 | "name": "id", 268 | "in": "path", 269 | "description": "The numerical ID of the desired status", 270 | "required": true, 271 | "type": "string" 272 | }, 273 | { 274 | "name": "trim_user", 275 | "in": "query", 276 | "description": "When set to either true, t or 1, each tweet returned in a timeline will include a user object", 277 | "required": false, 278 | "type": "string" 279 | }, 280 | { 281 | "name": "include_my_retweet", 282 | "in": "query", 283 | "description": "When set to either true, t or 1, any Tweets returned that have been retweeted by the authenticating", 284 | "required": true, 285 | "type": "string" 286 | }, 287 | { 288 | "name": "include_entities", 289 | "type": "string", 290 | "in": "query", 291 | "description": "The entities node will be disincluded when set to false", 292 | "required": false 293 | } 294 | ], 295 | "responses": { 296 | "200": { 297 | "description": "Success if that matters wd sw", 298 | "schema": { 299 | "$ref": "#/definitions/Tweets" 300 | } 301 | } 302 | } 303 | } 304 | }, 305 | "/statuses/destroy/{id}": { 306 | "post": { 307 | "description": "Destroys the status specified by the required ID parameter", 308 | "security": [ 309 | { 310 | "oauth": ["basic"] 311 | } 312 | ], 313 | "parameters": [ 314 | { 315 | "name": "id", 316 | "in": "path", 317 | "description": "The numerical ID of the desired status", 318 | "required": true, 319 | "type": "string" 320 | }, 321 | { 322 | "name": "trim_user", 323 | "in": "query", 324 | "description": "When set to either true, t or 1, each tweet returned in a timeline will include a user object", 325 | "required": false, 326 | "type": "string" 327 | } 328 | ], 329 | "responses": { 330 | "200": { 331 | "description": "Success", 332 | "schema": { 333 | "$ref": "#/definitions/Tweets" 334 | } 335 | } 336 | } 337 | } 338 | }, 339 | "/statuses/update": { 340 | "post": { 341 | "description": "Updates the authenticating user's status", 342 | "security": [ 343 | { 344 | "oauth": ["basic"] 345 | } 346 | ], 347 | "parameters": [ 348 | { 349 | "name": "status", 350 | "in": "query", 351 | "description": "The text of your status update", 352 | "required": true, 353 | "type": "string" 354 | }, 355 | { 356 | "name": "in_reply_to_status_id", 357 | "in": "query", 358 | "description": "The ID of an existing status", 359 | "required": false, 360 | "type": "string" 361 | }, 362 | { 363 | "name": "lat", 364 | "in": "query", 365 | "description": "The latitude of the location", 366 | "required": false, 367 | "type": "string" 368 | }, 369 | { 370 | "name": "long", 371 | "in": "query", 372 | "description": "The longitude of the location", 373 | "required": false, 374 | "type": "string" 375 | }, 376 | { 377 | "name": "place_id", 378 | "in": "query", 379 | "description": "A place in the world", 380 | "required": false, 381 | "type": "string" 382 | }, 383 | { 384 | "name": "display_coordinates", 385 | "in": "query", 386 | "description": "Whether or not to put a pin on the exact coordinates a tweet", 387 | "required": false, 388 | "type": "string" 389 | }, 390 | { 391 | "name": "trim_user", 392 | "in": "query", 393 | "description": "When set to either true, t or 1, each tweet returned in a timeline will include a user object", 394 | "required": false, 395 | "type": "string" 396 | } 397 | ], 398 | "responses": { 399 | "200": { 400 | "description": "Success", 401 | "schema": { 402 | "$ref": "#/definitions/Tweets" 403 | } 404 | }, 405 | "403": { 406 | "description": "Error" 407 | } 408 | } 409 | } 410 | }, 411 | "/statuses/oembed": { 412 | "get": { 413 | "description": "Returns information allowing the creation of an embedded representation", 414 | "security": [ 415 | { 416 | "oauth": ["basic"] 417 | } 418 | ], 419 | "parameters": [ 420 | { 421 | "name": "id", 422 | "in": "query", 423 | "description": "The tweet/status id to return embed code for", 424 | "required": true, 425 | "type": "string" 426 | }, 427 | { 428 | "name": "url", 429 | "in": "query", 430 | "description": "The encoded URL of the Tweet status to be embedded", 431 | "required": true, 432 | "type": "string" 433 | }, 434 | { 435 | "name": "maxwidth", 436 | "in": "query", 437 | "description": "The maximum width in pixels that the embed should be rendered at", 438 | "required": false, 439 | "type": "string" 440 | }, 441 | { 442 | "name": "hide_media", 443 | "in": "query", 444 | "description": "Specifies whether the embedded tweet should automatically show the original message in the case that the embedded Tweet is a reply", 445 | "required": false, 446 | "type": "string" 447 | }, 448 | { 449 | "name": "hide_thread", 450 | "in": "query", 451 | "description": "Specifies whether the embedded Tweet html should include a 'script' element pointing to widgets.js", 452 | "required": false, 453 | "type": "string" 454 | }, 455 | { 456 | "name": "align", 457 | "in": "query", 458 | "description": "Specifies whether the embedded Tweet should be left aligned", 459 | "required": false, 460 | "type": "string" 461 | }, 462 | { 463 | "name": "related", 464 | "in": "query", 465 | "description": "A value for the TWT related parameters", 466 | "required": false, 467 | "type": "string" 468 | }, 469 | { 470 | "name": "lang", 471 | "in": "query", 472 | "description": "Languages code for the rendered embed", 473 | "required": false, 474 | "type": "string" 475 | } 476 | ], 477 | "responses": { 478 | "200": { 479 | "description": "Success", 480 | "schema": { 481 | "$ref": "#/definitions/Tweets" 482 | } 483 | } 484 | } 485 | } 486 | }, 487 | "/lists/list": { 488 | "get": { 489 | "description": "Return all lists the authenticating or specified user subscribes to, including their own.", 490 | "security": [ 491 | { 492 | "oauth": ["basic"] 493 | } 494 | ], 495 | "parameters": [ 496 | { 497 | "name": "screen_name", 498 | "in": "query", 499 | "description": "The screen name of the user for whom to return results for Hey jeremey ijikjkhj,kb kukj", 500 | "required": true, 501 | "type": "string" 502 | }, 503 | { 504 | "name": "user_id", 505 | "in": "query", 506 | "description": "The ID of the user for whom to return results for", 507 | "required": true, 508 | "type": "string" 509 | } 510 | ], 511 | "responses": { 512 | "200": { 513 | "description": "Success", 514 | "schema": { 515 | "type": "array", 516 | "items": { 517 | "$ref": "#/definitions/Lists" 518 | } 519 | } 520 | } 521 | } 522 | } 523 | }, 524 | "/lists/statuses": { 525 | "get": { 526 | "description": "Returns a timeline of tweets authored by memebers of the specified list", 527 | "security": [ 528 | { 529 | "oauth": ["basic"] 530 | } 531 | ], 532 | "parameters": [ 533 | { 534 | "name": "list_id", 535 | "in": "query", 536 | "description": "The numerical id of the list", 537 | "required": true, 538 | "type": "string" 539 | }, 540 | { 541 | "name": "slug", 542 | "in": "query", 543 | "description": "You can identify a list by its slug instead of its numerical id", 544 | "required": true, 545 | "type": "string" 546 | }, 547 | { 548 | "name": "owner_screen_name", 549 | "in": "query", 550 | "description": "The screen name of the user who owns the list being requested by a slug", 551 | "required": false, 552 | "type": "string" 553 | }, 554 | { 555 | "name": "owner_id", 556 | "in": "query", 557 | "description": "The user ID of the user who owns the list being requested by a slug", 558 | "required": false, 559 | "type": "string" 560 | }, 561 | { 562 | "name": "since_id", 563 | "in": "query", 564 | "description": "Returns results with an ID greater than the sepcified ID", 565 | "required": false, 566 | "type": "string" 567 | }, 568 | { 569 | "name": "max_id", 570 | "in": "query", 571 | "description": "Returns results with an ID less than or equal to the specified ID", 572 | "required": false, 573 | "type": "string" 574 | }, 575 | { 576 | "name": "count", 577 | "in": "query", 578 | "description": "Specifies the number of results to retrieve per page", 579 | "required": false, 580 | "type": "string" 581 | }, 582 | { 583 | "name": "include_entities", 584 | "in": "query", 585 | "description": "Entities are ON by default", 586 | "required": false, 587 | "type": "string" 588 | }, 589 | { 590 | "name": "include_rts", 591 | "in": "query", 592 | "description": "When set to either true, t or 1, the list timeline will contain native retweets in addition to the standard stream of tweets", 593 | "required": false, 594 | "type": "string" 595 | } 596 | ], 597 | "responses": { 598 | "200": { 599 | "description": "Success", 600 | "schema": { 601 | "type": "array", 602 | "items": { 603 | "$ref": "#/definitions/Tweets" 604 | } 605 | } 606 | } 607 | } 608 | } 609 | }, 610 | "/lists/members/destroy": { 611 | "get": { 612 | "description": "Returns the list of memebers destroy", 613 | "security": [ 614 | { 615 | "oauth": ["basic"] 616 | } 617 | ], 618 | "parameters": [ 619 | { 620 | "name": "list_id", 621 | "in": "query", 622 | "description": "The numerical id of the list", 623 | "required": true, 624 | "type": "string" 625 | }, 626 | { 627 | "name": "slug", 628 | "in": "query", 629 | "description": "You can identify a list by its slug instrad of its numerical id", 630 | "required": true, 631 | "type": "string" 632 | }, 633 | { 634 | "name": "owner_screen_name", 635 | "in": "query", 636 | "description": "The screen name of the user who owns the list being requested by a slug", 637 | "required": false, 638 | "type": "string" 639 | }, 640 | { 641 | "name": "user_id", 642 | "in": "query", 643 | "description": "The id of the user for whom to remove from the list", 644 | "required": false, 645 | "type": "string" 646 | }, 647 | { 648 | "name": "screen_name", 649 | "in": "query", 650 | "description": "The screen name of the user for whom to remove from the list", 651 | "required": false, 652 | "type": "string" 653 | }, 654 | { 655 | "name": "owner_id", 656 | "in": "query", 657 | "description": "The is of the user who wons the list being requested by a slug", 658 | "required": false, 659 | "type": "string" 660 | } 661 | ], 662 | "responses": { 663 | "200": { 664 | "description": "Success" 665 | } 666 | } 667 | } 668 | }, 669 | "/lists/memberships": { 670 | "get": { 671 | "description": "Returns the lists of the specified user has been added to", 672 | "security": [ 673 | { 674 | "oauth": ["basic"] 675 | } 676 | ], 677 | "parameters": [ 678 | { 679 | "name": "user_id", 680 | "in": "query", 681 | "description": "The id of the user for whom to return results for", 682 | "required": false, 683 | "type": "string" 684 | }, 685 | { 686 | "name": "screen_name", 687 | "in": "query", 688 | "description": "The screen name of the user for whom to return results for", 689 | "required": false, 690 | "type": "string" 691 | }, 692 | { 693 | "name": "cursor", 694 | "in": "query", 695 | "description": "Breaks the results into pages", 696 | "required": false, 697 | "type": "string" 698 | }, 699 | { 700 | "name": "filter_to_owned_lists", 701 | "in": "query", 702 | "description": "When set to true, t or 1, will return just lists the authenticating user owns", 703 | "required": false, 704 | "type": "string" 705 | } 706 | ], 707 | "responses": { 708 | "200": { 709 | "description": "Success", 710 | "schema": { 711 | "$ref": "#/definitions/Cursor_lists" 712 | } 713 | } 714 | } 715 | } 716 | }, 717 | "/lists/subscribers": { 718 | "get": { 719 | "description": "Returns the subscribers of the specified list", 720 | "security": [ 721 | { 722 | "oauth": ["basic"] 723 | } 724 | ], 725 | "parameters": [ 726 | { 727 | "name": "list_id", 728 | "in": "query", 729 | "description": "The numerical id of the list", 730 | "required": true, 731 | "type": "string" 732 | }, 733 | { 734 | "name": "slug", 735 | "in": "query", 736 | "description": "You can identify a list by its slug insted of its numerical id", 737 | "required": true, 738 | "type": "string" 739 | }, 740 | { 741 | "name": "owner_screen_name", 742 | "in": "query", 743 | "description": "the screen name of the user who owns the list being requested by a slug", 744 | "required": false, 745 | "type": "string" 746 | }, 747 | { 748 | "name": "owner_id", 749 | "in": "query", 750 | "description": "The user ID of the user who owns the list being requested by a slug", 751 | "required": false, 752 | "type": "string" 753 | }, 754 | { 755 | "name": "cursor", 756 | "in": "query", 757 | "description": "Breaks the results into pages", 758 | "required": false, 759 | "type": "string" 760 | }, 761 | { 762 | "name": "include_entities", 763 | "in": "query", 764 | "description": "Wehn set to either true, t or 1", 765 | "required": false, 766 | "type": "string" 767 | }, 768 | { 769 | "name": "skip_status", 770 | "in": "query", 771 | "description": "When set to either true, t or 1", 772 | "required": false, 773 | "type": "string" 774 | } 775 | ], 776 | "responses": { 777 | "200": { 778 | "description": "Success", 779 | "schema": { 780 | "$ref": "#/definitions/Cursor_lists" 781 | } 782 | } 783 | } 784 | } 785 | }, 786 | "/lists/subscribers/create": { 787 | "post": { 788 | "description": "Subscribes the authenticated user to the specified list", 789 | "security": [ 790 | { 791 | "oauth": ["basic"] 792 | } 793 | ], 794 | "parameters": [ 795 | { 796 | "name": "list_id", 797 | "in": "query", 798 | "description": "The numerical id of the list", 799 | "required": true, 800 | "type": "string" 801 | }, 802 | { 803 | "name": "slug", 804 | "in": "query", 805 | "description": "You can identify a list being requested by a slug", 806 | "required": true, 807 | "type": "string" 808 | }, 809 | { 810 | "name": "owner_screen_name", 811 | "in": "query", 812 | "description": "the screen name of the user who owns the list being requested by a slug", 813 | "required": false, 814 | "type": "string" 815 | }, 816 | { 817 | "name": "owner_id", 818 | "in": "query", 819 | "description": "The user ID of the user who owns the list being requested by a slug", 820 | "required": false, 821 | "type": "string" 822 | } 823 | ], 824 | "responses": { 825 | "200": { 826 | "description": "Success", 827 | "schema": { 828 | "$ref": "#/definitions/Lists" 829 | } 830 | } 831 | } 832 | } 833 | }, 834 | "/lists/subscribers/show": { 835 | "get": { 836 | "description": "Check if the specified user is a subscriber of the specified list", 837 | "security": [ 838 | { 839 | "oauth": ["basic"] 840 | } 841 | ], 842 | "parameters": [ 843 | { 844 | "name": "list_id", 845 | "in": "query", 846 | "description": "The numerical id of the list", 847 | "required": true, 848 | "type": "string" 849 | }, 850 | { 851 | "name": "slug", 852 | "in": "query", 853 | "description": "You can identify a list being requested by a slug", 854 | "required": true, 855 | "type": "string" 856 | }, 857 | { 858 | "name": "owner_screen_name", 859 | "in": "query", 860 | "description": "The screen name of the user who owns the list being requested by a slug", 861 | "required": false, 862 | "type": "string" 863 | }, 864 | { 865 | "name": "user_id", 866 | "in": "query", 867 | "description": "The id of the user for whom to remove from the list", 868 | "required": false, 869 | "type": "string" 870 | }, 871 | { 872 | "name": "screen_name", 873 | "in": "query", 874 | "description": "The screen name of the user for whom to remove from the list", 875 | "required": false, 876 | "type": "string" 877 | }, 878 | { 879 | "name": "owner_id", 880 | "in": "query", 881 | "description": "The is of the user who wons the list being requested by a slug", 882 | "required": false, 883 | "type": "string" 884 | }, 885 | { 886 | "name": "include_entities", 887 | "in": "query", 888 | "description": "Wehn set to either true, t or 1", 889 | "required": false, 890 | "type": "string" 891 | }, 892 | { 893 | "name": "skip_status", 894 | "in": "query", 895 | "description": "When set to either true, t or 1", 896 | "required": false, 897 | "type": "string" 898 | } 899 | ], 900 | "responses": { 901 | "200": { 902 | "description": "Success", 903 | "schema": { 904 | "$ref": "#/definitions/Users" 905 | } 906 | } 907 | } 908 | } 909 | }, 910 | "/lists/subscribers/destroy": { 911 | "get": { 912 | "description": "Returns list of subscribers destroy", 913 | "parameters": [ 914 | { 915 | "name": "list_id", 916 | "in": "query", 917 | "description": "The numerical id of the list", 918 | "required": true, 919 | "type": "string" 920 | }, 921 | { 922 | "name": "slug", 923 | "in": "query", 924 | "description": "You can identify a list being requested by a slug", 925 | "required": true, 926 | "type": "string" 927 | }, 928 | { 929 | "name": "owner_screen_name", 930 | "in": "query", 931 | "description": "the screen name of the user who owns the list being requested by a slug", 932 | "required": false, 933 | "type": "string" 934 | }, 935 | { 936 | "name": "owner_id", 937 | "in": "query", 938 | "description": "The user ID of the user who owns the list being requested by a slug", 939 | "required": false, 940 | "type": "string" 941 | } 942 | ], 943 | "responses": { 944 | "200": { 945 | "description": "Success" 946 | } 947 | } 948 | } 949 | }, 950 | "/lists/members/create_all": { 951 | "get": { 952 | "description": "Returns lists of members create_all", 953 | "security": [ 954 | { 955 | "oauth": ["basic"] 956 | } 957 | ], 958 | "parameters": [ 959 | { 960 | "name": "list_id", 961 | "in": "query", 962 | "description": "The numerical id of the list", 963 | "required": true, 964 | "type": "string" 965 | }, 966 | { 967 | "name": "slug", 968 | "in": "query", 969 | "description": "You can identify a list being requested by a slug", 970 | "required": true, 971 | "type": "string" 972 | }, 973 | { 974 | "name": "owner_screen_name", 975 | "in": "query", 976 | "description": "the screen name of the user who owns the list being requested by a slug", 977 | "required": false, 978 | "type": "string" 979 | }, 980 | { 981 | "name": "owner_id", 982 | "in": "query", 983 | "description": "The user ID of the user who owns the list being requested by a slug", 984 | "required": false, 985 | "type": "string" 986 | }, 987 | { 988 | "name": "user_id", 989 | "in": "query", 990 | "description": "The id of the user for whom to remove from the list", 991 | "required": false, 992 | "type": "string" 993 | }, 994 | { 995 | "name": "screen_name", 996 | "in": "query", 997 | "description": "The screen name of the user for whom to remove from the list", 998 | "required": false, 999 | "type": "string" 1000 | } 1001 | ], 1002 | "responses": { 1003 | "200": { 1004 | "description": "Success" 1005 | } 1006 | } 1007 | } 1008 | }, 1009 | "/list/members/show": { 1010 | "get": { 1011 | "description": "Check if the specified user is a member of the specified list", 1012 | "security": [ 1013 | { 1014 | "oauth": ["basic"] 1015 | } 1016 | ], 1017 | "parameters": [ 1018 | { 1019 | "name": "list_id", 1020 | "in": "query", 1021 | "description": "The numerical id of the list", 1022 | "required": true, 1023 | "type": "string" 1024 | }, 1025 | { 1026 | "name": "slug", 1027 | "in": "query", 1028 | "description": "You can identify a list being requested by a slug", 1029 | "required": true, 1030 | "type": "string" 1031 | }, 1032 | { 1033 | "name": "user_id", 1034 | "in": "query", 1035 | "description": "The id of the user for whom to remove from the list", 1036 | "required": false, 1037 | "type": "string" 1038 | }, 1039 | { 1040 | "name": "screen_name", 1041 | "in": "query", 1042 | "description": "The screen name of the user for whom to remove from the list", 1043 | "required": false, 1044 | "type": "string" 1045 | }, 1046 | { 1047 | "name": "owner_screen_name", 1048 | "in": "query", 1049 | "description": "The screen name of the user who owns the list being requested by a slug", 1050 | "required": false, 1051 | "type": "string" 1052 | }, 1053 | { 1054 | "name": "owner_id", 1055 | "in": "query", 1056 | "description": "The user ID of the user who owns the list being requested by a slug", 1057 | "required": false, 1058 | "type": "string" 1059 | }, 1060 | { 1061 | "name": "include_entities", 1062 | "in": "query", 1063 | "description": "Wehn set to either true, t or 1", 1064 | "required": false, 1065 | "type": "string" 1066 | }, 1067 | { 1068 | "name": "skip_status", 1069 | "in": "query", 1070 | "description": "When set to either true, t or 1", 1071 | "required": false, 1072 | "type": "string" 1073 | } 1074 | ], 1075 | "responses": { 1076 | "200": { 1077 | "description": "Success", 1078 | "schema": { 1079 | "$ref": "#/definitions/Users" 1080 | } 1081 | } 1082 | } 1083 | } 1084 | }, 1085 | "/list/members": { 1086 | "get": { 1087 | "description": "Returns the members of the specified list", 1088 | "security": [ 1089 | { 1090 | "oauth": ["basic"] 1091 | } 1092 | ], 1093 | "parameters": [ 1094 | { 1095 | "name": "list_id", 1096 | "in": "query", 1097 | "description": "The numerical id of the list", 1098 | "required": true, 1099 | "type": "string" 1100 | }, 1101 | { 1102 | "name": "slug", 1103 | "in": "query", 1104 | "description": "You can identify a list being requested by a slug", 1105 | "required": true, 1106 | "type": "string" 1107 | }, 1108 | { 1109 | "name": "owner_screen_name", 1110 | "in": "query", 1111 | "description": "The screen name of the user who owns the list being requested by a slug", 1112 | "required": false, 1113 | "type": "string" 1114 | }, 1115 | { 1116 | "name": "owner_id", 1117 | "in": "query", 1118 | "description": "The user ID of the user who owns the list being requested by a slug", 1119 | "required": false, 1120 | "type": "string" 1121 | }, 1122 | { 1123 | "name": "include_entities", 1124 | "in": "query", 1125 | "description": "Wehn set to either true, t or 1", 1126 | "required": false, 1127 | "type": "string" 1128 | }, 1129 | { 1130 | "name": "skip_status", 1131 | "in": "query", 1132 | "description": "When set to either true, t or 1", 1133 | "required": false, 1134 | "type": "string" 1135 | }, 1136 | { 1137 | "name": "cursor", 1138 | "in": "query", 1139 | "description": "Breaks the results into pages", 1140 | "required": false, 1141 | "type": "string" 1142 | } 1143 | ], 1144 | "responses": { 1145 | "200": { 1146 | "description": "Success", 1147 | "schema": { 1148 | "$ref": "#/definitions/Users" 1149 | } 1150 | } 1151 | } 1152 | } 1153 | }, 1154 | "/list/members/create": { 1155 | "post": { 1156 | "description": "Returns list of members create", 1157 | "security": [ 1158 | { 1159 | "oauth": ["basic"] 1160 | } 1161 | ], 1162 | "parameters": [ 1163 | { 1164 | "name": "list_id", 1165 | "in": "query", 1166 | "description": "The numerical id of the list", 1167 | "required": true, 1168 | "type": "string" 1169 | }, 1170 | { 1171 | "name": "slug", 1172 | "in": "query", 1173 | "description": "You can identify a list being requested by a slug", 1174 | "required": true, 1175 | "type": "string" 1176 | }, 1177 | { 1178 | "name": "screen_name", 1179 | "in": "query", 1180 | "description": "The screen name of the user for whom to remove from the list", 1181 | "required": false, 1182 | "type": "string" 1183 | }, 1184 | { 1185 | "name": "owner_screen_name", 1186 | "in": "query", 1187 | "description": "The screen name of the user who owns the list being requested by a slug", 1188 | "required": false, 1189 | "type": "string" 1190 | }, 1191 | { 1192 | "name": "owner_id", 1193 | "in": "query", 1194 | "description": "The user ID of the user who owns the list being requested by a slug", 1195 | "required": false, 1196 | "type": "string" 1197 | } 1198 | ], 1199 | "responses": { 1200 | "200": { 1201 | "description": "Success" 1202 | } 1203 | } 1204 | } 1205 | }, 1206 | "/lists/destroy": { 1207 | "post": { 1208 | "description": "Returns list of destroy", 1209 | "security": [ 1210 | { 1211 | "oauth": ["basic"] 1212 | } 1213 | ], 1214 | "parameters": [ 1215 | { 1216 | "name": "list_id", 1217 | "in": "query", 1218 | "description": "The numerical id of the list", 1219 | "required": true, 1220 | "type": "string" 1221 | }, 1222 | { 1223 | "name": "slug", 1224 | "in": "query", 1225 | "description": "You can identify a list being requested by a slug", 1226 | "required": true, 1227 | "type": "string" 1228 | }, 1229 | { 1230 | "name": "owner_screen_name", 1231 | "in": "query", 1232 | "description": "The screen name of the user who owns the list being requested by a slug", 1233 | "required": false, 1234 | "type": "string" 1235 | }, 1236 | { 1237 | "name": "owner_id", 1238 | "in": "query", 1239 | "description": "The user ID of the user who owns the list being requested by a slug", 1240 | "required": false, 1241 | "type": "string" 1242 | } 1243 | ], 1244 | "responses": { 1245 | "200": { 1246 | "description": "Success", 1247 | "schema": { 1248 | "$ref": "#/definitions/Lists" 1249 | } 1250 | } 1251 | } 1252 | } 1253 | }, 1254 | "/lists/update": { 1255 | "post": { 1256 | "description": "Returns lists of updates", 1257 | "security": [ 1258 | { 1259 | "oauth": ["basic"] 1260 | } 1261 | ], 1262 | "parameters": [ 1263 | { 1264 | "name": "list_id", 1265 | "in": "query", 1266 | "description": "The numerical id of the list", 1267 | "required": true, 1268 | "type": "string" 1269 | }, 1270 | { 1271 | "name": "slug", 1272 | "in": "query", 1273 | "description": "You can identify a list being requested by a slug", 1274 | "required": true, 1275 | "type": "string" 1276 | }, 1277 | { 1278 | "name": "owner_screen_name", 1279 | "in": "query", 1280 | "description": "The screen name of the user who owns the list being requested by a slug", 1281 | "required": false, 1282 | "type": "string" 1283 | }, 1284 | { 1285 | "name": "owner_id", 1286 | "in": "query", 1287 | "description": "The user ID of the user who owns the list being requested by a slug", 1288 | "required": false, 1289 | "type": "string" 1290 | }, 1291 | { 1292 | "name": "name", 1293 | "in": "query", 1294 | "description": "The name for the list", 1295 | "required": false, 1296 | "type": "string" 1297 | }, 1298 | { 1299 | "name": "mode", 1300 | "in": "query", 1301 | "description": "Whether your list is public or private", 1302 | "required": false, 1303 | "type": "string" 1304 | }, 1305 | { 1306 | "name": "description", 1307 | "in": "query", 1308 | "description": "The description to give the list", 1309 | "required": false, 1310 | "type": "string" 1311 | } 1312 | ], 1313 | "responses": { 1314 | "200": { 1315 | "description": "Success" 1316 | } 1317 | } 1318 | } 1319 | }, 1320 | "/lists/create": { 1321 | "post": { 1322 | "description": "Returns list of create", 1323 | "security": [ 1324 | { 1325 | "oauth": ["basic"] 1326 | } 1327 | ], 1328 | "parameters": [ 1329 | { 1330 | "name": "name", 1331 | "in": "query", 1332 | "description": "The name for the list", 1333 | "required": false, 1334 | "type": "string" 1335 | }, 1336 | { 1337 | "name": "mode", 1338 | "in": "query", 1339 | "description": "Whether your list is public or private", 1340 | "required": false, 1341 | "type": "string" 1342 | }, 1343 | { 1344 | "name": "description", 1345 | "in": "query", 1346 | "description": "The description to give the list", 1347 | "required": false, 1348 | "type": "string" 1349 | } 1350 | ], 1351 | "responses": { 1352 | "200": { 1353 | "description": "Success", 1354 | "schema": { 1355 | "$ref": "#/definitions/Lists" 1356 | } 1357 | } 1358 | } 1359 | } 1360 | }, 1361 | "/lists/show": { 1362 | "get": { 1363 | "description": "Returns list of show", 1364 | "security": [ 1365 | { 1366 | "oauth": ["basic"] 1367 | } 1368 | ], 1369 | "parameters": [ 1370 | { 1371 | "name": "list_id", 1372 | "in": "query", 1373 | "description": "The numerical id of the list", 1374 | "required": true, 1375 | "type": "string" 1376 | }, 1377 | { 1378 | "name": "slug", 1379 | "in": "query", 1380 | "description": "You can identify a list being requested by a slug", 1381 | "required": true, 1382 | "type": "string" 1383 | }, 1384 | { 1385 | "name": "owner_screen_name", 1386 | "in": "query", 1387 | "description": "The screen name of the user who owns the list being requested by a slug", 1388 | "required": false, 1389 | "type": "string" 1390 | }, 1391 | { 1392 | "name": "owner_id", 1393 | "in": "query", 1394 | "description": "The user ID of the user who owns the list being requested by a slug", 1395 | "required": false, 1396 | "type": "string" 1397 | } 1398 | ], 1399 | "responses": { 1400 | "200": { 1401 | "description": "Success", 1402 | "schema": { 1403 | "$ref": "#/definitions/Lists" 1404 | } 1405 | } 1406 | } 1407 | } 1408 | }, 1409 | "/lists/subscriptions": { 1410 | "get": { 1411 | "description": "Returns list of subscriptions", 1412 | "security": [ 1413 | { 1414 | "oauth": ["basic"] 1415 | } 1416 | ], 1417 | "parameters": [ 1418 | { 1419 | "name": "screen_name", 1420 | "in": "query", 1421 | "description": "The screen name of the user", 1422 | "required": false, 1423 | "type": "string" 1424 | }, 1425 | { 1426 | "name": "user_id", 1427 | "in": "query", 1428 | "description": "The id of the user for whom to return results for", 1429 | "required": false, 1430 | "type": "string" 1431 | }, 1432 | { 1433 | "name": "count", 1434 | "in": "query", 1435 | "description": "The amount of results to return per page", 1436 | "required": false, 1437 | "type": "string" 1438 | }, 1439 | { 1440 | "name": "cursor", 1441 | "in": "query", 1442 | "description": "Breaks the results into pages", 1443 | "required": false, 1444 | "type": "string" 1445 | } 1446 | ], 1447 | "responses": { 1448 | "200": { 1449 | "description": "Success", 1450 | "schema": { 1451 | "$ref": "#/definitions/Cursor_lists" 1452 | } 1453 | } 1454 | } 1455 | } 1456 | }, 1457 | "/list/members/destroy_all": { 1458 | "get": { 1459 | "description": "Returns lists of destroy all", 1460 | "security": [ 1461 | { 1462 | "oauth": ["basic"] 1463 | } 1464 | ], 1465 | "parameters": [ 1466 | { 1467 | "name": "list_id", 1468 | "in": "query", 1469 | "description": "The numerical id of the list", 1470 | "required": true, 1471 | "type": "string" 1472 | }, 1473 | { 1474 | "name": "slug", 1475 | "in": "query", 1476 | "description": "You can identify a list being requested by a slug", 1477 | "required": true, 1478 | "type": "string" 1479 | }, 1480 | { 1481 | "name": "user_id", 1482 | "in": "query", 1483 | "description": "The id of the user for whom to remove from the list", 1484 | "required": false, 1485 | "type": "string" 1486 | }, 1487 | { 1488 | "name": "screen_name", 1489 | "in": "query", 1490 | "description": "The screen name of the user for whom to remove from the list", 1491 | "required": false, 1492 | "type": "string" 1493 | }, 1494 | { 1495 | "name": "owner_screen_name", 1496 | "in": "query", 1497 | "description": "The screen name of the user who owns the list being requested by a slug", 1498 | "required": false, 1499 | "type": "string" 1500 | }, 1501 | { 1502 | "name": "owner_id", 1503 | "in": "query", 1504 | "description": "The user ID of the user who owns the list being requested by a slug", 1505 | "required": false, 1506 | "type": "string" 1507 | } 1508 | ], 1509 | "responses": { 1510 | "200": { 1511 | "description": "Success", 1512 | "schema": { 1513 | "$ref": "#/definitions/Cursor_lists" 1514 | } 1515 | } 1516 | } 1517 | } 1518 | }, 1519 | "/direct_messages/sent": { 1520 | "get": { 1521 | "description": "return 20 most recent direct messages sent", 1522 | "parameters": [ 1523 | { 1524 | "name": "since_id", 1525 | "in": "query", 1526 | "required": false, 1527 | "type": "string" 1528 | }, 1529 | { 1530 | "name": "max_id", 1531 | "in": "query", 1532 | "required": false, 1533 | "type": "string" 1534 | }, 1535 | { 1536 | "name": "count", 1537 | "in": "query", 1538 | "required": false, 1539 | "type": "string" 1540 | }, 1541 | { 1542 | "name": "page", 1543 | "in": "query", 1544 | "required": false, 1545 | "type": "string" 1546 | }, 1547 | { 1548 | "name": "include_entities", 1549 | "in": "query", 1550 | "required": false, 1551 | "type": "string" 1552 | } 1553 | ], 1554 | "responses": { 1555 | "200": { 1556 | "description": "OK", 1557 | "schema": { 1558 | "type": "array", 1559 | "items": { 1560 | "$ref": "#/definitions/Messages" 1561 | } 1562 | } 1563 | } 1564 | } 1565 | } 1566 | }, 1567 | "/direct_messages/show": { 1568 | "get": { 1569 | "description": "returns a single direct message specified by an id", 1570 | "security": [ 1571 | { 1572 | "oauth": ["basic"] 1573 | } 1574 | ], 1575 | "parameters": [ 1576 | { 1577 | "name": "id", 1578 | "in": "query", 1579 | "description": "ID of direct message", 1580 | "type": "string", 1581 | "required": true 1582 | } 1583 | ], 1584 | "responses": { 1585 | "200": { 1586 | "description": "OK", 1587 | "schema": { 1588 | "type": "array", 1589 | "items": { 1590 | "$ref": "#/definitions/Messages" 1591 | } 1592 | } 1593 | } 1594 | } 1595 | } 1596 | }, 1597 | "/search/tweets": { 1598 | "get": { 1599 | "description": "returns collection of relevant Tweets matching query", 1600 | "security": [ 1601 | { 1602 | "oauth": ["basic"] 1603 | } 1604 | ], 1605 | "parameters": [ 1606 | { 1607 | "name": "q", 1608 | "in": "query", 1609 | "description": "URL-encoded search query of 500 characters max", 1610 | "type": "string", 1611 | "required": true 1612 | }, 1613 | { 1614 | "name": "geocode", 1615 | "in": "query", 1616 | "description": "returns tweets by users located within given radius", 1617 | "type": "string", 1618 | "required": false 1619 | }, 1620 | { 1621 | "name": "lang", 1622 | "in": "query", 1623 | "description": "restricts tweets to a given language", 1624 | "type": "string", 1625 | "required": false 1626 | }, 1627 | { 1628 | "name": "locale", 1629 | "in": "query", 1630 | "description": "language of query you are sending", 1631 | "type": "string", 1632 | "required": false 1633 | }, 1634 | { 1635 | "name": "result_type", 1636 | "in": "query", 1637 | "description": "specifies type of search results you prefer", 1638 | "type": "string", 1639 | "required": false 1640 | }, 1641 | { 1642 | "name": "count", 1643 | "in": "query", 1644 | "description": "number of tweets to return", 1645 | "type": "string" 1646 | }, 1647 | { 1648 | "name": "until", 1649 | "in": "query", 1650 | "description": "returns tweets created before given date", 1651 | "type": "string" 1652 | }, 1653 | { 1654 | "name": "since_id", 1655 | "in": "query", 1656 | "description": "return results with ID greater than specified", 1657 | "type": "string" 1658 | }, 1659 | { 1660 | "name": "max_id", 1661 | "in": "query", 1662 | "description": "returns results with an ID less than/equal to specified ID", 1663 | "type": "string" 1664 | }, 1665 | { 1666 | "name": "include_entities", 1667 | "in": "query", 1668 | "description": "whether or not to include entities", 1669 | "type": "string" 1670 | }, 1671 | { 1672 | "name": "callback", 1673 | "in": "query", 1674 | "description": "response will use the callback with given name", 1675 | "type": "string" 1676 | } 1677 | ], 1678 | "responses": { 1679 | "200": { 1680 | "description": "OK", 1681 | "schema": { 1682 | "type": "array", 1683 | "items": { 1684 | "$ref": "#/definitions/Tweets" 1685 | } 1686 | } 1687 | } 1688 | } 1689 | } 1690 | }, 1691 | "/saved_searches/list": { 1692 | "get": { 1693 | "description": "Returns the authenticated user's saved search queries", 1694 | "security": [ 1695 | { 1696 | "oauth": ["basic"] 1697 | } 1698 | ], 1699 | "responses": { 1700 | "200": { 1701 | "description": "Success", 1702 | "schema": { 1703 | "type": "array", 1704 | "items": { 1705 | "$ref": "#/definitions/Query" 1706 | } 1707 | } 1708 | } 1709 | } 1710 | } 1711 | }, 1712 | "/saved_searches/show/{id}": { 1713 | "get": { 1714 | "description": "Retrieve the information for the saved search represented by the given id", 1715 | "security": [ 1716 | { 1717 | "oauth": ["basic"] 1718 | } 1719 | ], 1720 | "parameters": [ 1721 | { 1722 | "name": "id", 1723 | "in": "path", 1724 | "description": "The id of the saved search", 1725 | "required": true, 1726 | "type": "string" 1727 | } 1728 | ], 1729 | "responses": { 1730 | "200": { 1731 | "description": "Success", 1732 | "schema": { 1733 | "$ref": "#/definitions/Query" 1734 | } 1735 | } 1736 | } 1737 | } 1738 | }, 1739 | "/saved_searches/create": { 1740 | "post": { 1741 | "description": "Create a new saved search for the authenticated user", 1742 | "security": [ 1743 | { 1744 | "oauth": ["basic"] 1745 | } 1746 | ], 1747 | "parameters": [ 1748 | { 1749 | "name": "query", 1750 | "in": "query", 1751 | "description": "The query of the search the user would like to save", 1752 | "required": true, 1753 | "type": "string" 1754 | } 1755 | ], 1756 | "responses": { 1757 | "200": { 1758 | "description": "Success", 1759 | "schema": { 1760 | "$ref": "#/definitions/Query" 1761 | } 1762 | } 1763 | } 1764 | } 1765 | }, 1766 | "/saved_searches/destroy/{id}": { 1767 | "post": { 1768 | "description": "Destroy a saved search for the authenticating user", 1769 | "security": [ 1770 | { 1771 | "oauth": ["basic"] 1772 | } 1773 | ], 1774 | "parameters": [ 1775 | { 1776 | "name": "id", 1777 | "in": "path", 1778 | "description": "The id of the saved search", 1779 | "required": true, 1780 | "type": "string" 1781 | } 1782 | ], 1783 | "responses": { 1784 | "200": { 1785 | "description": "Success", 1786 | "schema": { 1787 | "$ref": "#/definitions/Query" 1788 | } 1789 | } 1790 | } 1791 | } 1792 | }, 1793 | "/direct_messages": { 1794 | "get": { 1795 | "description": "return 20 most recent direct messages sent to user", 1796 | "security": [ 1797 | { 1798 | "oauth": ["basic"] 1799 | } 1800 | ], 1801 | "parameters": [ 1802 | { 1803 | "name": "since_id", 1804 | "in": "query", 1805 | "description": "return results with ID greater than specified", 1806 | "type": "string" 1807 | }, 1808 | { 1809 | "name": "max_id", 1810 | "in": "query", 1811 | "description": "returns results with an ID less than/equal to specified ID", 1812 | "type": "string" 1813 | }, 1814 | { 1815 | "name": "include_entities", 1816 | "in": "query", 1817 | "description": "whether or not to include entities", 1818 | "type": "string" 1819 | }, 1820 | { 1821 | "name": "skip_status", 1822 | "in": "query", 1823 | "description": "whether or not to include status", 1824 | "type": "string" 1825 | } 1826 | ], 1827 | "responses": { 1828 | "200": { 1829 | "description": "OK", 1830 | "schema": { 1831 | "type": "array", 1832 | "items": { 1833 | "$ref": "#/definitions/Messages" 1834 | } 1835 | } 1836 | } 1837 | } 1838 | } 1839 | }, 1840 | "/direct_messages/destroy": { 1841 | "post": { 1842 | "description": "destroys direct messages specified in required ID", 1843 | "security": [ 1844 | { 1845 | "oauth": ["basic"] 1846 | } 1847 | ], 1848 | "parameters": [ 1849 | { 1850 | "name": "id", 1851 | "in": "query", 1852 | "description": "ID of direct message to delete", 1853 | "type": "string", 1854 | "required": true 1855 | }, 1856 | { 1857 | "name": "include_entities", 1858 | "in": "query", 1859 | "description": "whether or not to include entities", 1860 | "type": "string" 1861 | } 1862 | ], 1863 | "responses": { 1864 | "200": { 1865 | "description": "OK", 1866 | "schema": { 1867 | "$ref": "#/definitions/Messages" 1868 | } 1869 | } 1870 | } 1871 | } 1872 | }, 1873 | "/direct_messages/new": { 1874 | "post": { 1875 | "description": "sends a new direct message to specified user", 1876 | "security": [ 1877 | { 1878 | "oauth": ["basic"] 1879 | } 1880 | ], 1881 | "parameters": [ 1882 | { 1883 | "name": "user_id", 1884 | "in": "query", 1885 | "description": "description", 1886 | "type": "string", 1887 | "required": true 1888 | }, 1889 | { 1890 | "name": "screen_name", 1891 | "in": "query", 1892 | "description": "screen name of user receiving message", 1893 | "type": "string" 1894 | }, 1895 | { 1896 | "name": "text", 1897 | "in": "query", 1898 | "description": "text of your direct message", 1899 | "type": "string", 1900 | "required": true 1901 | } 1902 | ], 1903 | "responses": { 1904 | "200": { 1905 | "description": "OK", 1906 | "schema": { 1907 | "$ref": "#/definitions/Messages" 1908 | } 1909 | } 1910 | } 1911 | } 1912 | }, 1913 | "/friends/ids": { 1914 | "get": { 1915 | "description": "returns a cursored collection of user IDs followed by user", 1916 | "security": [ 1917 | { 1918 | "oauth": ["basic"] 1919 | } 1920 | ], 1921 | "parameters": [ 1922 | { 1923 | "name": "user_id", 1924 | "in": "query", 1925 | "description": "ID of user for whom to return results for", 1926 | "type": "string" 1927 | }, 1928 | { 1929 | "name": "screen_name", 1930 | "in": "query", 1931 | "description": "screen name of user for whom to return results for", 1932 | "type": "string" 1933 | }, 1934 | { 1935 | "name": "cursor", 1936 | "in": "query", 1937 | "description": "causes list of connections to be broken in pages", 1938 | "type": "string" 1939 | }, 1940 | { 1941 | "name": "stringify_ids", 1942 | "in": "query", 1943 | "description": "IDs converted to strings", 1944 | "type": "string" 1945 | }, 1946 | { 1947 | "name": "count", 1948 | "in": "query", 1949 | "description": "number of IDs to attempt retrieval of", 1950 | "type": "string" 1951 | } 1952 | ], 1953 | "responses": { 1954 | "200": { 1955 | "description": "OK", 1956 | "schema": { 1957 | "$ref": "#/definitions/Cursor_ids" 1958 | } 1959 | } 1960 | } 1961 | } 1962 | }, 1963 | "/followers/ids": { 1964 | "get": { 1965 | "description": "returns a cursored collection of user IDs following the user", 1966 | "security": [ 1967 | { 1968 | "oauth": ["basic"] 1969 | } 1970 | ], 1971 | "parameters": [ 1972 | { 1973 | "name": "user_id", 1974 | "in": "query", 1975 | "description": "ID of user for whom to return results for", 1976 | "type": "string" 1977 | }, 1978 | { 1979 | "name": "screen_name", 1980 | "in": "query", 1981 | "description": "screen name of user for whom to return results for", 1982 | "type": "string" 1983 | }, 1984 | { 1985 | "name": "cursor", 1986 | "in": "query", 1987 | "description": "causes list of connections to be broken in pages", 1988 | "type": "string" 1989 | }, 1990 | { 1991 | "name": "stringify_ids", 1992 | "in": "query", 1993 | "description": "IDs converted to strings", 1994 | "type": "string" 1995 | }, 1996 | { 1997 | "name": "count", 1998 | "in": "query", 1999 | "description": "number of IDs to attempt retrieval of", 2000 | "type": "string" 2001 | } 2002 | ], 2003 | "responses": { 2004 | "200": { 2005 | "description": "OK", 2006 | "schema": { 2007 | "$ref": "#/definitions/Cursor_ids" 2008 | } 2009 | } 2010 | } 2011 | } 2012 | }, 2013 | "/friendships/incoming": { 2014 | "get": { 2015 | "description": "returns collection of IDs of users with pending follow request", 2016 | "security": [ 2017 | { 2018 | "oauth": ["basic"] 2019 | } 2020 | ], 2021 | "parameters": [ 2022 | { 2023 | "name": "cursor", 2024 | "in": "query", 2025 | "description": "causes list of connections to be broken in pages", 2026 | "type": "string" 2027 | }, 2028 | { 2029 | "name": "stringify_ids", 2030 | "in": "query", 2031 | "description": "IDs converted to strings", 2032 | "type": "string" 2033 | } 2034 | ], 2035 | "responses": { 2036 | "200": { 2037 | "description": "OK", 2038 | "schema": { 2039 | "$ref": "#/definitions/Cursor_ids" 2040 | } 2041 | } 2042 | } 2043 | } 2044 | }, 2045 | "/friendships/outgoing": { 2046 | "get": { 2047 | "description": "returns collection of IDs of users with pending follow request from the user", 2048 | "security": [ 2049 | { 2050 | "oauth": ["basic"] 2051 | } 2052 | ], 2053 | "parameters": [ 2054 | { 2055 | "name": "cursor", 2056 | "in": "query", 2057 | "description": "causes list of connections to be broken in pages", 2058 | "type": "string" 2059 | }, 2060 | { 2061 | "name": "stringify_ids", 2062 | "in": "query", 2063 | "description": "IDs converted to strings", 2064 | "type": "string" 2065 | } 2066 | ], 2067 | "responses": { 2068 | "200": { 2069 | "description": "OK", 2070 | "schema": { 2071 | "$ref": "#/definitions/Cursor_ids" 2072 | } 2073 | } 2074 | } 2075 | } 2076 | }, 2077 | "/friendships/create": { 2078 | "post": { 2079 | "description": "allows users to follow user sepcified by ID", 2080 | "security": [ 2081 | { 2082 | "oauth": ["basic"] 2083 | } 2084 | ], 2085 | "parameters": [ 2086 | { 2087 | "name": "screen_name", 2088 | "in": "query", 2089 | "description": "screen name of user for whom to befriend", 2090 | "type": "string" 2091 | }, 2092 | { 2093 | "name": "user_id", 2094 | "in": "query", 2095 | "description": "ID of user for whom to befriend", 2096 | "type": "string" 2097 | }, 2098 | { 2099 | "name": "follow", 2100 | "in": "query", 2101 | "description": "enable notifications for target user", 2102 | "type": "string" 2103 | } 2104 | ], 2105 | "responses": { 2106 | "200": { 2107 | "description": "OK", 2108 | "schema": { 2109 | "$ref": "#/definitions/Users" 2110 | } 2111 | } 2112 | } 2113 | } 2114 | }, 2115 | "/friendships/destroy": { 2116 | "post": { 2117 | "description": "allows user to unfollow user psecified by ID", 2118 | "security": [ 2119 | { 2120 | "oauth": ["basic"] 2121 | } 2122 | ], 2123 | "parameters": [ 2124 | { 2125 | "name": "screen_name", 2126 | "in": "query", 2127 | "description": "screen name of user for whom to befriend", 2128 | "type": "string", 2129 | "required": true 2130 | }, 2131 | { 2132 | "name": "user_id", 2133 | "in": "query", 2134 | "description": "ID of user for whom to befriend", 2135 | "type": "string", 2136 | "required": true 2137 | } 2138 | ], 2139 | "responses": { 2140 | "200": { 2141 | "description": "OK", 2142 | "schema": { 2143 | "$ref": "#/definitions/Users" 2144 | } 2145 | } 2146 | } 2147 | } 2148 | }, 2149 | "/friendships/update": { 2150 | "post": { 2151 | "description": "Allows one to enable or disable settings for specified user", 2152 | "security": [ 2153 | { 2154 | "oauth": ["basic"] 2155 | } 2156 | ], 2157 | "parameters": [ 2158 | { 2159 | "name": "screen_name", 2160 | "in": "query", 2161 | "description": "screen name of user for whom to befriend", 2162 | "type": "string", 2163 | "required": true 2164 | }, 2165 | { 2166 | "name": "user_id", 2167 | "in": "query", 2168 | "description": "ID of user for whom to befriend", 2169 | "type": "string", 2170 | "required": true 2171 | }, 2172 | { 2173 | "name": "device", 2174 | "in": "query", 2175 | "description": "enable/disable device notifications for user", 2176 | "type": "string", 2177 | "required": true 2178 | }, 2179 | { 2180 | "name": "retweets", 2181 | "in": "query", 2182 | "description": "enable/disable retweets from target user", 2183 | "type": "string", 2184 | "required": true 2185 | } 2186 | ], 2187 | "responses": { 2188 | "200": { 2189 | "description": "OK", 2190 | "schema": { 2191 | "$ref": "#/definitions/Friendship" 2192 | } 2193 | } 2194 | } 2195 | } 2196 | }, 2197 | "/friendships/show": { 2198 | "get": { 2199 | "description": "returns detailed info about relationship between two users", 2200 | "security": [ 2201 | { 2202 | "oauth": ["basic"] 2203 | } 2204 | ], 2205 | "parameters": [ 2206 | { 2207 | "name": "source_id", 2208 | "in": "query", 2209 | "description": "user id of subject user", 2210 | "type": "string" 2211 | }, 2212 | { 2213 | "name": "source_screen_name", 2214 | "in": "query", 2215 | "description": "screen_name of subject user", 2216 | "type": "string" 2217 | }, 2218 | { 2219 | "name": "target_id", 2220 | "in": "query", 2221 | "description": "user id of target user", 2222 | "type": "string", 2223 | "required": true 2224 | }, 2225 | { 2226 | "name": "target_screen_name", 2227 | "in": "query", 2228 | "description": "screen name of target user", 2229 | "type": "string", 2230 | "required": true 2231 | } 2232 | ], 2233 | "responses": { 2234 | "200": { 2235 | "description": "OK", 2236 | "schema": { 2237 | "$ref": "#/definitions/Friendship" 2238 | } 2239 | } 2240 | } 2241 | } 2242 | }, 2243 | "/account/settings": { 2244 | "get": { 2245 | "summary": "returns settings for user", 2246 | "description": "returns settings for user", 2247 | "security": [ 2248 | { 2249 | "oauth": ["basic"] 2250 | } 2251 | ], 2252 | "responses": { 2253 | "200": { 2254 | "description": "OK", 2255 | "schema": { 2256 | "$ref": "#/definitions/Settings" 2257 | } 2258 | } 2259 | } 2260 | }, 2261 | "post": { 2262 | "summary": "updates user's settings", 2263 | "description": "updates user's settings", 2264 | "security": [ 2265 | { 2266 | "oauth": ["basic"] 2267 | } 2268 | ], 2269 | "parameters": [ 2270 | { 2271 | "name": "trend_location_woeid", 2272 | "in": "query", 2273 | "description": "the Yahoo! Where On Earth ID to user as defaul tend location", 2274 | "type": "string" 2275 | }, 2276 | { 2277 | "name": "sleep_time_enabled", 2278 | "in": "query", 2279 | "description": "enables/disables sleep time, silencing notifications", 2280 | "type": "string" 2281 | }, 2282 | { 2283 | "name": "start_sleep_time", 2284 | "in": "query", 2285 | "description": "the hour that sleep time should begin if enabled", 2286 | "type": "string" 2287 | }, 2288 | { 2289 | "name": "end_sleep_time", 2290 | "in": "query", 2291 | "description": "the hour that sleep time should end if enabled", 2292 | "type": "string" 2293 | }, 2294 | { 2295 | "name": "time_zone", 2296 | "in": "query", 2297 | "description": "timezone dates and times should be displayed in", 2298 | "type": "string" 2299 | }, 2300 | { 2301 | "name": "lang", 2302 | "in": "query", 2303 | "description": "language which Twitter should render in for the user", 2304 | "type": "string" 2305 | } 2306 | ], 2307 | "responses": { 2308 | "200": { 2309 | "description": "OK", 2310 | "schema": { 2311 | "$ref": "#/definitions/Settings" 2312 | } 2313 | } 2314 | } 2315 | } 2316 | }, 2317 | "/account/update_delivery_device": { 2318 | "post": { 2319 | "summary": "sets which device Twitter delivers updates to for user", 2320 | "description": "sets which device Twitter delivers updates to for user", 2321 | "security": [ 2322 | { 2323 | "oauth": ["basic"] 2324 | } 2325 | ], 2326 | "parameters": [ 2327 | { 2328 | "name": "device", 2329 | "in": "query", 2330 | "description": "must be one of sms, none", 2331 | "type": "string", 2332 | "required": true 2333 | }, 2334 | { 2335 | "name": "include_entities", 2336 | "in": "query", 2337 | "description": "whether or not to include entities", 2338 | "type": "string" 2339 | } 2340 | ], 2341 | "responses": { 2342 | "200": { 2343 | "description": "OK", 2344 | "schema": { 2345 | "$ref": "#/definitions/Settings" 2346 | } 2347 | } 2348 | } 2349 | } 2350 | }, 2351 | "/account/update_profile": { 2352 | "post": { 2353 | "summary": "sets values that users ar eable to set under Account tab", 2354 | "description": "sets values that users ar eable to set under Account tab", 2355 | "security": [ 2356 | { 2357 | "oauth": ["basic"] 2358 | } 2359 | ], 2360 | "parameters": [ 2361 | { 2362 | "name": "name", 2363 | "in": "query", 2364 | "description": "full name of profile", 2365 | "type": "string" 2366 | }, 2367 | { 2368 | "name": "url", 2369 | "in": "query", 2370 | "description": "url associated with profile", 2371 | "type": "string" 2372 | }, 2373 | { 2374 | "name": "location", 2375 | "in": "query", 2376 | "description": "city or country describing where user of account is.", 2377 | "type": "string" 2378 | }, 2379 | { 2380 | "name": "description", 2381 | "in": "query", 2382 | "description": "a description of user owning account", 2383 | "type": "string" 2384 | }, 2385 | { 2386 | "name": "include_entities", 2387 | "in": "query", 2388 | "description": "whether or not to include entities", 2389 | "type": "string" 2390 | }, 2391 | { 2392 | "name": "skip_status", 2393 | "in": "query", 2394 | "description": "whether or not to include statuses in response", 2395 | "type": "string" 2396 | } 2397 | ], 2398 | "responses": { 2399 | "200": { 2400 | "description": "OK", 2401 | "schema": { 2402 | "$ref": "#/definitions/Settings" 2403 | } 2404 | } 2405 | } 2406 | } 2407 | }, 2408 | "/account/update_profile_background_image": { 2409 | "post": { 2410 | "summary": "updates user's profile background image", 2411 | "description": "updates user's profile background image", 2412 | "security": [ 2413 | { 2414 | "oauth": ["basic"] 2415 | } 2416 | ], 2417 | "consumes": ["multipart/form-data"], 2418 | "parameters": [ 2419 | { 2420 | "name": "tile", 2421 | "in": "query", 2422 | "description": "whether or not to tile background image", 2423 | "type": "string" 2424 | }, 2425 | { 2426 | "name": "use", 2427 | "in": "query", 2428 | "description": "display background image or not", 2429 | "type": "string" 2430 | }, 2431 | { 2432 | "name": "include_entities", 2433 | "in": "query", 2434 | "description": "whether or not to include entities", 2435 | "type": "string" 2436 | }, 2437 | { 2438 | "name": "skip_status", 2439 | "in": "query", 2440 | "description": "whether or not to include status in returned user objects", 2441 | "type": "string" 2442 | }, 2443 | { 2444 | "name": "file", 2445 | "in": "formData", 2446 | "description": "image to replace background image of profile", 2447 | "required": true, 2448 | "type": "file" 2449 | } 2450 | ], 2451 | "responses": { 2452 | "200": { 2453 | "description": "OK", 2454 | "schema": { 2455 | "$ref": "#/definitions/Settings" 2456 | } 2457 | } 2458 | } 2459 | } 2460 | }, 2461 | "/account/update_profile_colors": { 2462 | "post": { 2463 | "summary": "sets one or more hex values that controls color scheme", 2464 | "description": "sets one or more hex values that controls color scheme", 2465 | "security": [ 2466 | { 2467 | "oauth": ["basic"] 2468 | } 2469 | ], 2470 | "parameters": [ 2471 | { 2472 | "name": "profile_background_color", 2473 | "in": "query", 2474 | "description": "profile background color", 2475 | "type": "string" 2476 | }, 2477 | { 2478 | "name": "profile_link_color", 2479 | "in": "query", 2480 | "description": "profile link color", 2481 | "type": "string" 2482 | }, 2483 | { 2484 | "name": "profile_sidebar_border_color", 2485 | "in": "query", 2486 | "description": "profile sidebar's border color", 2487 | "type": "string" 2488 | }, 2489 | { 2490 | "name": "profile_sidebar_fill_color", 2491 | "in": "query", 2492 | "description": "profile's sidebar background color", 2493 | "type": "string" 2494 | }, 2495 | { 2496 | "name": "profile_text_color", 2497 | "in": "query", 2498 | "description": "profile text color", 2499 | "type": "string" 2500 | }, 2501 | { 2502 | "name": "include_entities", 2503 | "in": "query", 2504 | "description": "whether or not to include entities", 2505 | "type": "string" 2506 | }, 2507 | { 2508 | "name": "skip_status", 2509 | "in": "query", 2510 | "description": "whether or not to include statuses", 2511 | "type": "string" 2512 | } 2513 | ], 2514 | "responses": { 2515 | "200": { 2516 | "description": "OK", 2517 | "schema": { 2518 | "$ref": "#/definitions/Settings" 2519 | } 2520 | } 2521 | } 2522 | } 2523 | }, 2524 | "/account/update_profile_image": { 2525 | "post": { 2526 | "summary": "updates user's profile image", 2527 | "description": "updates user's profile image", 2528 | "security": [ 2529 | { 2530 | "oauth": ["basic"] 2531 | } 2532 | ], 2533 | "consumes": ["multipart/form-data"], 2534 | "parameters": [ 2535 | { 2536 | "name": "skip_status", 2537 | "in": "query", 2538 | "description": "whether or not to include statuses", 2539 | "type": "string" 2540 | }, 2541 | { 2542 | "name": "image", 2543 | "in": "formData", 2544 | "description": "image to be set as profile image", 2545 | "type": "file", 2546 | "required": true 2547 | } 2548 | ], 2549 | "responses": { 2550 | "200": { 2551 | "description": "OK", 2552 | "schema": { 2553 | "$ref": "#/definitions/Settings" 2554 | } 2555 | } 2556 | } 2557 | } 2558 | }, 2559 | "/blocks/list": { 2560 | "get": { 2561 | "summary": "disallows retweets and device notifications from a user", 2562 | "description": "disallows retweets and device notifications from a user", 2563 | "security": [ 2564 | { 2565 | "oauth": ["basic"] 2566 | } 2567 | ], 2568 | "parameters": [ 2569 | { 2570 | "name": "include_entities", 2571 | "in": "query", 2572 | "description": "whether or not to include entities", 2573 | "type": "string" 2574 | }, 2575 | { 2576 | "name": "skip_status", 2577 | "in": "query", 2578 | "description": "whether or not to include statuses in response", 2579 | "type": "string" 2580 | }, 2581 | { 2582 | "name": "cursor", 2583 | "in": "query", 2584 | "description": "breaks block of user to be broken up into pages", 2585 | "type": "string" 2586 | } 2587 | ], 2588 | "responses": { 2589 | "200": { 2590 | "description": "OK", 2591 | "schema": { 2592 | "$ref": "#/definitions/Cursor_users" 2593 | } 2594 | } 2595 | } 2596 | } 2597 | }, 2598 | "/blocks/ids": { 2599 | "get": { 2600 | "summary": "returns array of numeric user ids of blocked users", 2601 | "description": "returns array of numeric user ids of blocked users", 2602 | "security": [ 2603 | { 2604 | "oauth": ["basic"] 2605 | } 2606 | ], 2607 | "parameters": [ 2608 | { 2609 | "name": "stringify_ids", 2610 | "in": "query", 2611 | "description": "returns array of numeric IDs as string IDs", 2612 | "type": "string" 2613 | }, 2614 | { 2615 | "name": "cursor", 2616 | "in": "query", 2617 | "description": "breaks up block of user IDs into pages", 2618 | "type": "string" 2619 | } 2620 | ], 2621 | "responses": { 2622 | "200": { 2623 | "description": "OK", 2624 | "schema": { 2625 | "$ref": "#/definitions/Cursor_users" 2626 | } 2627 | } 2628 | } 2629 | } 2630 | }, 2631 | "/blocks/create": { 2632 | "post": { 2633 | "summary": "blocks the specified user", 2634 | "description": "blocks the specified user", 2635 | "security": [ 2636 | { 2637 | "oauth": ["basic"] 2638 | } 2639 | ], 2640 | "parameters": [ 2641 | { 2642 | "name": "screen_name", 2643 | "in": "query", 2644 | "description": "screen name of user to be blocked", 2645 | "type": "string", 2646 | "required": true 2647 | }, 2648 | { 2649 | "name": "user_id", 2650 | "in": "query", 2651 | "description": "ID of user to be blocked", 2652 | "type": "string", 2653 | "required": true 2654 | }, 2655 | { 2656 | "name": "include_entities", 2657 | "in": "query", 2658 | "description": "whether or not to include entities", 2659 | "type": "string" 2660 | }, 2661 | { 2662 | "name": "skip_status", 2663 | "in": "query", 2664 | "description": "whether or not to skip statuses", 2665 | "type": "string" 2666 | } 2667 | ], 2668 | "responses": { 2669 | "200": { 2670 | "description": "OK", 2671 | "schema": { 2672 | "$ref": "#/definitions/Users" 2673 | } 2674 | } 2675 | } 2676 | } 2677 | }, 2678 | "/blocks/destroy": { 2679 | "post": { 2680 | "summary": "un-blocks the specified user", 2681 | "description": "un-blocks the specified user", 2682 | "security": [ 2683 | { 2684 | "oauth": ["basic"] 2685 | } 2686 | ], 2687 | "parameters": [ 2688 | { 2689 | "name": "screen_name", 2690 | "in": "query", 2691 | "description": "screen name of user to be un-blocked", 2692 | "type": "string", 2693 | "required": true 2694 | }, 2695 | { 2696 | "name": "user_id", 2697 | "in": "query", 2698 | "description": "ID of user to be un-blocked", 2699 | "type": "string", 2700 | "required": true 2701 | }, 2702 | { 2703 | "name": "include_entities", 2704 | "in": "query", 2705 | "description": "whether or not to include entities", 2706 | "type": "string" 2707 | }, 2708 | { 2709 | "name": "skip_status", 2710 | "in": "query", 2711 | "description": "whether or not to skip statuses", 2712 | "type": "string" 2713 | } 2714 | ], 2715 | "responses": { 2716 | "200": { 2717 | "description": "OK", 2718 | "schema": { 2719 | "$ref": "#/definitions/Users" 2720 | } 2721 | } 2722 | } 2723 | } 2724 | }, 2725 | "/users/lookup": { 2726 | "get": { 2727 | "summary": "returns fully-hydrated user objects up to 100", 2728 | "description": "returns fully-hydrated user objects up to 100", 2729 | "security": [ 2730 | { 2731 | "oauth": ["basic"] 2732 | } 2733 | ], 2734 | "parameters": [ 2735 | { 2736 | "name": "screen_name", 2737 | "in": "query", 2738 | "description": "screen name of user to lookup", 2739 | "type": "string" 2740 | }, 2741 | { 2742 | "name": "user_id", 2743 | "in": "query", 2744 | "description": "ID of user to lookup", 2745 | "type": "string" 2746 | }, 2747 | { 2748 | "name": "include_entities", 2749 | "in": "query", 2750 | "description": "whether or not to include entities", 2751 | "type": "string" 2752 | } 2753 | ], 2754 | "responses": { 2755 | "200": { 2756 | "description": "OK", 2757 | "schema": { 2758 | "type": "array", 2759 | "items": { 2760 | "$ref": "#/definitions/Users" 2761 | } 2762 | } 2763 | } 2764 | } 2765 | } 2766 | }, 2767 | "/users/show": { 2768 | "get": { 2769 | "summary": "returns a variety of info about specified user", 2770 | "description": "returns a variety of info about specified user", 2771 | "security": [ 2772 | { 2773 | "oauth": ["basic"] 2774 | } 2775 | ], 2776 | "parameters": [ 2777 | { 2778 | "name": "screen_name", 2779 | "in": "query", 2780 | "description": "screen name of user to be shown", 2781 | "type": "string", 2782 | "required": true 2783 | }, 2784 | { 2785 | "name": "user_id", 2786 | "in": "query", 2787 | "description": "ID of user to be shown", 2788 | "type": "string", 2789 | "required": true 2790 | }, 2791 | { 2792 | "name": "include_entities", 2793 | "in": "query", 2794 | "description": "whether or not to include entities", 2795 | "type": "string" 2796 | } 2797 | ], 2798 | "responses": { 2799 | "200": { 2800 | "description": "OK", 2801 | "schema": { 2802 | "$ref": "#/definitions/Users" 2803 | } 2804 | } 2805 | } 2806 | } 2807 | }, 2808 | "/users/search": { 2809 | "get": { 2810 | "summary": "simple relevance-based user search", 2811 | "description": "simple relevance-based user search", 2812 | "security": [ 2813 | { 2814 | "oauth": ["basic"] 2815 | } 2816 | ], 2817 | "parameters": [ 2818 | { 2819 | "name": "q", 2820 | "in": "query", 2821 | "description": "the search query to run against people search", 2822 | "type": "string", 2823 | "required": true 2824 | }, 2825 | { 2826 | "name": "page", 2827 | "in": "query", 2828 | "description": "specifies the page of results to receive", 2829 | "type": "string" 2830 | }, 2831 | { 2832 | "name": "count", 2833 | "in": "query", 2834 | "description": "number of people to return per page", 2835 | "type": "string" 2836 | }, 2837 | { 2838 | "name": "include_entities", 2839 | "in": "query", 2840 | "description": "whether or not to include entities", 2841 | "type": "string" 2842 | } 2843 | ], 2844 | "responses": { 2845 | "200": { 2846 | "description": "OK", 2847 | "schema": { 2848 | "type": "array", 2849 | "items": { 2850 | "$ref": "#/definitions/Users" 2851 | } 2852 | } 2853 | } 2854 | } 2855 | } 2856 | }, 2857 | "/users/contributees": { 2858 | "get": { 2859 | "summary": "collection of users specified user can contribute to", 2860 | "description": "collection of users specified user can contribute to", 2861 | "security": [ 2862 | { 2863 | "oauth": ["basic"] 2864 | } 2865 | ], 2866 | "parameters": [ 2867 | { 2868 | "name": "screen_name", 2869 | "in": "query", 2870 | "description": "screen name of user that is contributed to", 2871 | "type": "string", 2872 | "required": true 2873 | }, 2874 | { 2875 | "name": "user_id", 2876 | "in": "query", 2877 | "description": "ID of user to that is contributed to", 2878 | "type": "string", 2879 | "required": true 2880 | }, 2881 | { 2882 | "name": "include_entities", 2883 | "in": "query", 2884 | "description": "whether or not to include entities", 2885 | "type": "string" 2886 | }, 2887 | { 2888 | "name": "skip_status", 2889 | "in": "query", 2890 | "description": "whether or not to skip statuses", 2891 | "type": "string" 2892 | } 2893 | ], 2894 | "responses": { 2895 | "200": { 2896 | "description": "OK", 2897 | "schema": { 2898 | "type": "array", 2899 | "items": { 2900 | "$ref": "#/definitions/Users" 2901 | } 2902 | } 2903 | } 2904 | } 2905 | } 2906 | }, 2907 | "/users/contributors": { 2908 | "get": { 2909 | "summary": "collection of users that can contribute to specified account", 2910 | "description": "collection of users that can contribute to specified account", 2911 | "security": [ 2912 | { 2913 | "oauth": ["basic"] 2914 | } 2915 | ], 2916 | "parameters": [ 2917 | { 2918 | "name": "screen_name", 2919 | "in": "query", 2920 | "description": "screen name of user contributing", 2921 | "type": "string", 2922 | "required": true 2923 | }, 2924 | { 2925 | "name": "user_id", 2926 | "in": "query", 2927 | "description": "ID of user contributing", 2928 | "type": "string", 2929 | "required": true 2930 | }, 2931 | { 2932 | "name": "include_entities", 2933 | "in": "query", 2934 | "description": "whether or not to include entities", 2935 | "type": "string" 2936 | }, 2937 | { 2938 | "name": "skip_status", 2939 | "in": "query", 2940 | "description": "whether or not to skip statuses", 2941 | "type": "string" 2942 | } 2943 | ], 2944 | "responses": { 2945 | "200": { 2946 | "description": "OK", 2947 | "schema": { 2948 | "type": "array", 2949 | "items": { 2950 | "$ref": "#/definitions/Users" 2951 | } 2952 | } 2953 | } 2954 | } 2955 | } 2956 | }, 2957 | "/geo/id/{place_id}": { 2958 | "get": { 2959 | "description": "Returns all the information about a know place", 2960 | "security": [ 2961 | { 2962 | "oauth": ["basic"] 2963 | } 2964 | ], 2965 | "parameters": [ 2966 | { 2967 | "name": "place_id", 2968 | "in": "path", 2969 | "description": "A place in the world", 2970 | "required": true, 2971 | "type": "string" 2972 | } 2973 | ], 2974 | "responses": { 2975 | "200": { 2976 | "description": "Success", 2977 | "schema": { 2978 | "type": "array", 2979 | "items": { 2980 | "$ref": "#/definitions/Places" 2981 | } 2982 | } 2983 | } 2984 | } 2985 | } 2986 | }, 2987 | "/geo/reverse_geoncode": { 2988 | "get": { 2989 | "description": "Given a latitude and a longitude, searches for up to 20 places that can be used as a place_id when updatting a status", 2990 | "security": [ 2991 | { 2992 | "oauth": ["basic"] 2993 | } 2994 | ], 2995 | "parameters": [ 2996 | { 2997 | "name": "lat", 2998 | "in": "query", 2999 | "description": "The latitude to search around", 3000 | "required": true, 3001 | "type": "string" 3002 | }, 3003 | { 3004 | "name": "long", 3005 | "in": "query", 3006 | "description": "The longtitude to search around", 3007 | "required": true, 3008 | "type": "string" 3009 | }, 3010 | { 3011 | "name": "accuracy", 3012 | "in": "query", 3013 | "description": "A hint on region in which to search", 3014 | "required": false, 3015 | "type": "string" 3016 | }, 3017 | { 3018 | "name": "granularity", 3019 | "in": "query", 3020 | "description": "This is the minimal granularity of place types to return", 3021 | "required": false, 3022 | "type": "string" 3023 | }, 3024 | { 3025 | "name": "max_results", 3026 | "in": "query", 3027 | "description": "A hint as to the number of results to return", 3028 | "required": false, 3029 | "type": "string" 3030 | }, 3031 | { 3032 | "name": "callback", 3033 | "in": "query", 3034 | "description": "If supplied, the responses will use the JSON format with a callback of the given name", 3035 | "required": false, 3036 | "type": "string" 3037 | } 3038 | ], 3039 | "responses": { 3040 | "200": { 3041 | "description": "Success", 3042 | "schema": { 3043 | "type": "array", 3044 | "items": { 3045 | "$ref": "#/definitions/Places" 3046 | } 3047 | } 3048 | } 3049 | } 3050 | } 3051 | }, 3052 | "/geo/search": { 3053 | "get": { 3054 | "description": "Search for places that can be attached to a statuses/updates", 3055 | "security": [ 3056 | { 3057 | "oauth": ["basic"] 3058 | } 3059 | ], 3060 | "parameters": [ 3061 | { 3062 | "name": "lat", 3063 | "in": "query", 3064 | "description": "The latitude to search around", 3065 | "required": true, 3066 | "type": "string" 3067 | }, 3068 | { 3069 | "name": "long", 3070 | "in": "query", 3071 | "description": "The longtitude to search around", 3072 | "required": true, 3073 | "type": "string" 3074 | }, 3075 | { 3076 | "name": "query", 3077 | "in": "query", 3078 | "description": "Free-form text to match against while executing a geo-based query", 3079 | "required": true, 3080 | "type": "string" 3081 | }, 3082 | { 3083 | "name": "ip", 3084 | "in": "query", 3085 | "description": "An Ip address", 3086 | "required": true, 3087 | "type": "string" 3088 | }, 3089 | { 3090 | "name": "accuracy", 3091 | "in": "query", 3092 | "description": "A hint on region in which to search", 3093 | "required": false, 3094 | "type": "string" 3095 | }, 3096 | { 3097 | "name": "granularity", 3098 | "in": "query", 3099 | "description": "This is the minimal granularity of place types to return", 3100 | "required": false, 3101 | "type": "string" 3102 | }, 3103 | { 3104 | "name": "contained_within", 3105 | "in": "query", 3106 | "description": "This is the place_id which you would like to restrict the search results to", 3107 | "required": false, 3108 | "type": "string" 3109 | }, 3110 | { 3111 | "name": "attribute:street_address", 3112 | "in": "query", 3113 | "description": "This parameter searches for places which have this givven street address", 3114 | "required": false, 3115 | "type": "string" 3116 | }, 3117 | { 3118 | "name": "callback", 3119 | "in": "query", 3120 | "description": "If supplied, the responses will use the JSON format with a callback of the given name", 3121 | "required": false, 3122 | "type": "string" 3123 | } 3124 | ], 3125 | "responses": { 3126 | "200": { 3127 | "description": "Success", 3128 | "schema": { 3129 | "type": "array", 3130 | "items": { 3131 | "$ref": "#/definitions/Places" 3132 | } 3133 | } 3134 | } 3135 | } 3136 | } 3137 | }, 3138 | "/geo/similar_places": { 3139 | "get": { 3140 | "description": "Locates places near the given coordinates which are similar in name", 3141 | "security": [ 3142 | { 3143 | "oauth": ["basic"] 3144 | } 3145 | ], 3146 | "parameters": [ 3147 | { 3148 | "name": "lat", 3149 | "in": "query", 3150 | "description": "The latitude to search around", 3151 | "required": true, 3152 | "type": "string" 3153 | }, 3154 | { 3155 | "name": "long", 3156 | "in": "query", 3157 | "description": "The longtitude to search around", 3158 | "required": true, 3159 | "type": "string" 3160 | }, 3161 | { 3162 | "name": "name", 3163 | "in": "query", 3164 | "description": "The name a place is known as", 3165 | "required": true, 3166 | "type": "string" 3167 | }, 3168 | { 3169 | "name": "contained_within", 3170 | "in": "query", 3171 | "description": "This is the place_id which you would like to restrict the search results to", 3172 | "required": false, 3173 | "type": "string" 3174 | }, 3175 | { 3176 | "name": "attribute:street_address", 3177 | "in": "query", 3178 | "description": "This parameter searches for places which have this givven street address", 3179 | "required": false, 3180 | "type": "string" 3181 | }, 3182 | { 3183 | "name": "callback", 3184 | "in": "query", 3185 | "description": "If supplied, the responses will use the JSON format with a callback of the given name", 3186 | "required": false, 3187 | "type": "string" 3188 | } 3189 | ], 3190 | "responses": { 3191 | "200": { 3192 | "description": "Success", 3193 | "schema": { 3194 | "type": "array", 3195 | "items": { 3196 | "$ref": "#/definitions/Places" 3197 | } 3198 | } 3199 | } 3200 | } 3201 | } 3202 | }, 3203 | "/geo/places": { 3204 | "get": { 3205 | "description": "Create a new place object at the given latitude and logitude", 3206 | "security": [ 3207 | { 3208 | "oauth": ["basic"] 3209 | } 3210 | ], 3211 | "parameters": [ 3212 | { 3213 | "name": "lat", 3214 | "in": "query", 3215 | "description": "The latitude to search around", 3216 | "required": true, 3217 | "type": "string" 3218 | }, 3219 | { 3220 | "name": "long", 3221 | "in": "query", 3222 | "description": "The longtitude to search around", 3223 | "required": true, 3224 | "type": "string" 3225 | }, 3226 | { 3227 | "name": "name", 3228 | "in": "query", 3229 | "description": "The name a place is known as", 3230 | "required": true, 3231 | "type": "string" 3232 | }, 3233 | { 3234 | "name": "token", 3235 | "in": "query", 3236 | "description": "The token found in the response from geo/similar_places", 3237 | "required": true, 3238 | "type": "string" 3239 | }, 3240 | { 3241 | "name": "contained_within", 3242 | "in": "query", 3243 | "description": "This is the place_id which you would like to restrict the search results to", 3244 | "required": false, 3245 | "type": "string" 3246 | }, 3247 | { 3248 | "name": "attribute:street_address", 3249 | "in": "query", 3250 | "description": "This parameter searches for places which have this givven street address", 3251 | "required": false, 3252 | "type": "string" 3253 | }, 3254 | { 3255 | "name": "callback", 3256 | "in": "query", 3257 | "description": "If supplied, the responses will use the JSON format with a callback of the given name", 3258 | "required": false, 3259 | "type": "string" 3260 | } 3261 | ], 3262 | "responses": { 3263 | "200": { 3264 | "description": "Success", 3265 | "schema": { 3266 | "$ref": "#/definitions/Places" 3267 | } 3268 | } 3269 | } 3270 | } 3271 | }, 3272 | "/trends/place": { 3273 | "get": { 3274 | "description": "Returns the top 10 trending topics for a specific WOEID", 3275 | "security": [ 3276 | { 3277 | "oauth": ["basic"] 3278 | } 3279 | ], 3280 | "parameters": [ 3281 | { 3282 | "name": "id", 3283 | "in": "query", 3284 | "description": "The yahoo where on earch id", 3285 | "required": true, 3286 | "type": "string" 3287 | }, 3288 | { 3289 | "name": "exclude", 3290 | "in": "query", 3291 | "description": "Setting this equal to hashtages will remove all hashtages from the trends list", 3292 | "required": true, 3293 | "type": "string" 3294 | } 3295 | ], 3296 | "responses": { 3297 | "200": { 3298 | "description": "Success", 3299 | "schema": { 3300 | "$ref": "#/definitions/TrendInfo" 3301 | } 3302 | } 3303 | } 3304 | } 3305 | }, 3306 | "/trends/available": { 3307 | "get": { 3308 | "description": "Returns the availability", 3309 | "security": [ 3310 | { 3311 | "oauth": ["basic"] 3312 | } 3313 | ], 3314 | "responses": { 3315 | "200": { 3316 | "description": "Success", 3317 | "schema": { 3318 | "type": "array", 3319 | "items": { 3320 | "$ref": "#/definitions/Location" 3321 | } 3322 | } 3323 | } 3324 | } 3325 | } 3326 | }, 3327 | "/trends/closest": { 3328 | "get": { 3329 | "description": "Returns the location that Twitter has trending topic information for", 3330 | "security": [ 3331 | { 3332 | "oauth": ["basic"] 3333 | } 3334 | ], 3335 | "parameters": [ 3336 | { 3337 | "name": "lat", 3338 | "in": "query", 3339 | "description": "If provided with a long parameter the available trend locations wil be stored by distance", 3340 | "required": true, 3341 | "type": "string" 3342 | }, 3343 | { 3344 | "name": "long", 3345 | "in": "query", 3346 | "description": "If provided with a lat parameters the available trend locations will be sorted by distance", 3347 | "required": true, 3348 | "type": "string" 3349 | } 3350 | ], 3351 | "responses": { 3352 | "200": { 3353 | "description": "Success", 3354 | "schema": { 3355 | "type": "array", 3356 | "items": { 3357 | "$ref": "#/definitions/Location" 3358 | } 3359 | } 3360 | } 3361 | } 3362 | } 3363 | }, 3364 | "/users/report_spam": { 3365 | "post": { 3366 | "description": "Returna users report spam", 3367 | "security": [ 3368 | { 3369 | "oauth": ["basic"] 3370 | } 3371 | ], 3372 | "parameters": [ 3373 | { 3374 | "name": "screen_name", 3375 | "in": "query", 3376 | "description": "The ID or screen_name of the user you want to report as a spammer", 3377 | "required": false, 3378 | "type": "string" 3379 | }, 3380 | { 3381 | "name": "user_id", 3382 | "in": "query", 3383 | "description": "The ID of the user you want to report as a spammer", 3384 | "required": false, 3385 | "type": "string" 3386 | } 3387 | ], 3388 | "responses": { 3389 | "200": { 3390 | "description": "Success", 3391 | "schema": { 3392 | "$ref": "#/definitions/Users" 3393 | } 3394 | } 3395 | } 3396 | } 3397 | }, 3398 | "/help/configuration": { 3399 | "get": { 3400 | "description": "Returns the current configuration used by Twitter including twitter.com slugs which are not usernames", 3401 | "security": [ 3402 | { 3403 | "oauth": ["basic"] 3404 | } 3405 | ], 3406 | "responses": { 3407 | "200": { 3408 | "description": "Success", 3409 | "schema": { 3410 | "$ref": "#/definitions/Help_Config" 3411 | } 3412 | } 3413 | } 3414 | } 3415 | }, 3416 | "/help/languages": { 3417 | "get": { 3418 | "description": "Returns the list of languages supported by Twitter along with the language code supported by Twitter", 3419 | "security": [ 3420 | { 3421 | "oauth": ["basic"] 3422 | } 3423 | ], 3424 | "responses": { 3425 | "200": { 3426 | "description": "Success", 3427 | "schema": { 3428 | "type": "array", 3429 | "items": { 3430 | "$ref": "#/definitions/Help_Language" 3431 | } 3432 | } 3433 | } 3434 | } 3435 | } 3436 | }, 3437 | "/help/privacy": { 3438 | "get": { 3439 | "description": "Returns Twitter's privacy policy", 3440 | "security": [ 3441 | { 3442 | "oauth": ["basic"] 3443 | } 3444 | ], 3445 | "responses": { 3446 | "200": { 3447 | "description": "Success", 3448 | "schema": { 3449 | "$ref": "#/definitions/Help_Privacy" 3450 | } 3451 | } 3452 | } 3453 | } 3454 | }, 3455 | "/help/tos": { 3456 | "get": { 3457 | "description": "Returns the Twitter Terms of Service", 3458 | "security": [ 3459 | { 3460 | "oauth": ["basic"] 3461 | } 3462 | ], 3463 | "responses": { 3464 | "200": { 3465 | "description": "Success", 3466 | "schema": { 3467 | "$ref": "#/definitions/Help_Tos" 3468 | } 3469 | } 3470 | } 3471 | } 3472 | }, 3473 | "/application/rate_limit_status": { 3474 | "get": { 3475 | "description": "Returns the current rate limits for methods belonging to the specified resource families", 3476 | "security": [ 3477 | { 3478 | "oauth": ["basic"] 3479 | } 3480 | ], 3481 | "parameters": [ 3482 | { 3483 | "name": "resources", 3484 | "in": "query", 3485 | "description": "A comma-separated list of resource families you want to know the current rate limit disposition for", 3486 | "required": false, 3487 | "type": "array", 3488 | "items": { 3489 | "type": "string" 3490 | } 3491 | } 3492 | ], 3493 | "responses": { 3494 | "200": { 3495 | "description": "Success" 3496 | } 3497 | } 3498 | } 3499 | } 3500 | }, 3501 | "definitions": { 3502 | "Tweets": { 3503 | "type": "object", 3504 | "properties": { 3505 | "contributors": { 3506 | "type": "array", 3507 | "items": { 3508 | "$ref": "#/definitions/Contributors" 3509 | } 3510 | }, 3511 | "coordinates": { 3512 | "$ref": "#/definitions/Coordinates" 3513 | }, 3514 | "created_at": { 3515 | "type": "string" 3516 | }, 3517 | "current_user_retweet": { 3518 | "$ref": "#/definitions/Tweets" 3519 | }, 3520 | "entities": { 3521 | "$ref": "#/definitions/Entities" 3522 | }, 3523 | "favorite_count": { 3524 | "type": "integer" 3525 | }, 3526 | "favorited": { 3527 | "type": "boolean" 3528 | }, 3529 | "filter_level": { 3530 | "type": "string" 3531 | }, 3532 | "id": { 3533 | "type": "integer" 3534 | }, 3535 | "id_str": { 3536 | "type": "string" 3537 | }, 3538 | "in_reply_to_screen_name": { 3539 | "type": "string" 3540 | }, 3541 | "in_reply_to_status_id": { 3542 | "type": "integer" 3543 | }, 3544 | "in_reply_to_status_id_str": { 3545 | "type": "string" 3546 | }, 3547 | "in_reply_to_user_id": { 3548 | "type": "integer" 3549 | }, 3550 | "in_reply_to_user_id_str": { 3551 | "type": "string" 3552 | }, 3553 | "lang": { 3554 | "type": "string" 3555 | }, 3556 | "place": { 3557 | "$ref": "#/definitions/Places" 3558 | }, 3559 | "possibly_sensitive": { 3560 | "type": "boolean" 3561 | }, 3562 | "quoted_status_id": { 3563 | "type": "integer" 3564 | }, 3565 | "quoted_status_id_str": { 3566 | "type": "string" 3567 | }, 3568 | "quoted_status": { 3569 | "$ref": "#/definitions/Tweets" 3570 | }, 3571 | "scopes": { 3572 | "type": "object", 3573 | "additionalProperties": {} 3574 | }, 3575 | "retweet_count": { 3576 | "type": "integer" 3577 | }, 3578 | "retweeted": { 3579 | "type": "boolean" 3580 | }, 3581 | "retweeted_status": { 3582 | "$ref": "#/definitions/Tweets" 3583 | }, 3584 | "source": { 3585 | "type": "string" 3586 | }, 3587 | "text": { 3588 | "type": "string" 3589 | }, 3590 | "truncated": { 3591 | "type": "string" 3592 | }, 3593 | "user": { 3594 | "$ref": "#/definitions/Users" 3595 | }, 3596 | "withheld_copyright": { 3597 | "type": "boolean" 3598 | }, 3599 | "withheld_countries": { 3600 | "type": "array", 3601 | "items": { 3602 | "type": "string" 3603 | } 3604 | }, 3605 | "withheld_scope": { 3606 | "type": "string" 3607 | } 3608 | } 3609 | }, 3610 | "Contributors": { 3611 | "type": "object", 3612 | "properties": { 3613 | "id": { 3614 | "type": "integer" 3615 | }, 3616 | "id_str": { 3617 | "type": "string" 3618 | }, 3619 | "screen_name": { 3620 | "type": "string" 3621 | } 3622 | } 3623 | }, 3624 | "Coordinates": { 3625 | "type": "object", 3626 | "properties": { 3627 | "coordinates": { 3628 | "type": "array", 3629 | "items": { 3630 | "type": "number" 3631 | } 3632 | }, 3633 | "type": { 3634 | "type": "string" 3635 | } 3636 | } 3637 | }, 3638 | "Users": { 3639 | "type": "object", 3640 | "properties": { 3641 | "contributors_enabled": { 3642 | "type": "boolean" 3643 | }, 3644 | "created_at": { 3645 | "type": "string" 3646 | }, 3647 | "default_profile": { 3648 | "type": "boolean" 3649 | }, 3650 | "default_profile_image": { 3651 | "type": "boolean" 3652 | }, 3653 | "description": { 3654 | "type": "string" 3655 | }, 3656 | "entities": { 3657 | "$ref": "#/definitions/Entities" 3658 | }, 3659 | "favorites_count": { 3660 | "type": "integer" 3661 | }, 3662 | "follow_request_sent": { 3663 | "type": "boolean" 3664 | }, 3665 | "following": { 3666 | "type": "boolean" 3667 | }, 3668 | "followers_count": { 3669 | "type": "integer" 3670 | }, 3671 | "friends_count": { 3672 | "type": "integer" 3673 | }, 3674 | "geo_enabled": { 3675 | "type": "boolean" 3676 | }, 3677 | "id": { 3678 | "type": "integer" 3679 | }, 3680 | "id_str": { 3681 | "type": "string" 3682 | }, 3683 | "is_translator": { 3684 | "type": "boolean" 3685 | }, 3686 | "lang": { 3687 | "type": "string" 3688 | }, 3689 | "listed_count": { 3690 | "type": "integer" 3691 | }, 3692 | "location": { 3693 | "type": "string" 3694 | }, 3695 | "name": { 3696 | "type": "string" 3697 | }, 3698 | "notifications": { 3699 | "type": "boolean" 3700 | }, 3701 | "profile_background_color": { 3702 | "type": "string" 3703 | }, 3704 | "profile_background_image_url": { 3705 | "type": "string" 3706 | }, 3707 | "profile_background_image_url_https": { 3708 | "type": "string" 3709 | }, 3710 | "profile_background_tile": { 3711 | "type": "string" 3712 | }, 3713 | "profile_banner_url": { 3714 | "type": "string" 3715 | }, 3716 | "profile_image_url": { 3717 | "type": "string" 3718 | }, 3719 | "profile_image_url_https": { 3720 | "type": "string" 3721 | }, 3722 | "profile_link_color": { 3723 | "type": "string" 3724 | }, 3725 | "profile_sidebar_border_color": { 3726 | "type": "string" 3727 | }, 3728 | "profile_sidebar_fill_color": { 3729 | "type": "string" 3730 | }, 3731 | "profile_text_color": { 3732 | "type": "string" 3733 | }, 3734 | "profile_use_background_image": { 3735 | "type": "boolean" 3736 | }, 3737 | "protected": { 3738 | "type": "boolean" 3739 | }, 3740 | "screen_name": { 3741 | "type": "string" 3742 | }, 3743 | "show_all_inline_media": { 3744 | "type": "boolean" 3745 | }, 3746 | "status": { 3747 | "$ref": "#/definitions/Tweets" 3748 | }, 3749 | "statuses_count": { 3750 | "type": "integer" 3751 | }, 3752 | "time_zone": { 3753 | "type": "string" 3754 | }, 3755 | "url": { 3756 | "type": "string" 3757 | }, 3758 | "utc_offset": { 3759 | "type": "integer" 3760 | }, 3761 | "verified": { 3762 | "type": "boolean" 3763 | }, 3764 | "withheld_in_countries": { 3765 | "type": "string" 3766 | }, 3767 | "withheld_scope": { 3768 | "type": "string" 3769 | } 3770 | } 3771 | }, 3772 | "Entities": { 3773 | "type": "object", 3774 | "properties": { 3775 | "hashtags": { 3776 | "type": "array", 3777 | "items": { 3778 | "$ref": "#/definitions/Hashtags" 3779 | } 3780 | }, 3781 | "media": { 3782 | "type": "array", 3783 | "items": { 3784 | "$ref": "#/definitions/Media" 3785 | } 3786 | }, 3787 | "urls": { 3788 | "type": "array", 3789 | "items": { 3790 | "$ref": "#/definitions/URL" 3791 | } 3792 | }, 3793 | "user_mentions": { 3794 | "type": "array", 3795 | "items": { 3796 | "$ref": "#/definitions/User_Mention" 3797 | } 3798 | } 3799 | } 3800 | }, 3801 | "Hashtags": { 3802 | "type": "object", 3803 | "properties": { 3804 | "indices": { 3805 | "type": "array", 3806 | "items": { 3807 | "type": "integer" 3808 | } 3809 | }, 3810 | "text": { 3811 | "type": "string" 3812 | } 3813 | } 3814 | }, 3815 | "Media": { 3816 | "type": "object", 3817 | "properties": { 3818 | "display_url": { 3819 | "type": "string" 3820 | }, 3821 | "expanded_url": { 3822 | "type": "string" 3823 | }, 3824 | "id": { 3825 | "type": "integer" 3826 | }, 3827 | "id_str": { 3828 | "type": "string" 3829 | }, 3830 | "indices": { 3831 | "type": "array", 3832 | "items": { 3833 | "type": "integer" 3834 | } 3835 | }, 3836 | "media_url": { 3837 | "type": "string" 3838 | }, 3839 | "media_url_https": { 3840 | "type": "string" 3841 | }, 3842 | "sizes": { 3843 | "$ref": "#/definitions/Sizes" 3844 | }, 3845 | "source_status_id": { 3846 | "type": "integer" 3847 | }, 3848 | "source_status_id_str": { 3849 | "type": "integer" 3850 | }, 3851 | "type": { 3852 | "type": "string" 3853 | }, 3854 | "url": { 3855 | "type": "string" 3856 | } 3857 | } 3858 | }, 3859 | "Size": { 3860 | "type": "object", 3861 | "properties": { 3862 | "h": { 3863 | "type": "integer" 3864 | }, 3865 | "resize": { 3866 | "type": "string" 3867 | }, 3868 | "w": { 3869 | "type": "integer" 3870 | } 3871 | } 3872 | }, 3873 | "Sizes": { 3874 | "type": "object", 3875 | "properties": { 3876 | "thumb": { 3877 | "$ref": "#/definitions/Size" 3878 | }, 3879 | "large": { 3880 | "$ref": "#/definitions/Size" 3881 | }, 3882 | "medium": { 3883 | "$ref": "#/definitions/Size" 3884 | }, 3885 | "small": { 3886 | "$ref": "#/definitions/Size" 3887 | } 3888 | } 3889 | }, 3890 | "URL": { 3891 | "type": "object", 3892 | "properties": { 3893 | "display_url": { 3894 | "type": "string" 3895 | }, 3896 | "expanded_url": { 3897 | "type": "string" 3898 | }, 3899 | "indices": { 3900 | "type": "string" 3901 | }, 3902 | "url": { 3903 | "type": "string" 3904 | } 3905 | } 3906 | }, 3907 | "User_Mention": { 3908 | "type": "object", 3909 | "properties": { 3910 | "id": { 3911 | "type": "integer" 3912 | }, 3913 | "id_str": { 3914 | "type": "string" 3915 | }, 3916 | "indices": { 3917 | "type": "array", 3918 | "items": { 3919 | "type": "integer" 3920 | } 3921 | }, 3922 | "name": { 3923 | "type": "string" 3924 | }, 3925 | "screen_name": { 3926 | "type": "string" 3927 | } 3928 | } 3929 | }, 3930 | "Places": { 3931 | "type": "object", 3932 | "properties": { 3933 | "attributes": { 3934 | "type": "object", 3935 | "additionalProperties": {} 3936 | }, 3937 | "bounding_box": { 3938 | "$ref": "#/definitions/Bounding_box" 3939 | }, 3940 | "country": { 3941 | "type": "string" 3942 | }, 3943 | "country_code": { 3944 | "type": "string" 3945 | }, 3946 | "full_name": { 3947 | "type": "string" 3948 | }, 3949 | "id": { 3950 | "type": "string" 3951 | }, 3952 | "name": { 3953 | "type": "string" 3954 | }, 3955 | "place_type": { 3956 | "type": "string" 3957 | }, 3958 | "url": { 3959 | "type": "string" 3960 | } 3961 | } 3962 | }, 3963 | "Bounding_box": { 3964 | "type": "object", 3965 | "properties": { 3966 | "coordinates": { 3967 | "type": "array", 3968 | "items": { 3969 | "type": "array", 3970 | "items": { 3971 | "type": "number" 3972 | } 3973 | } 3974 | }, 3975 | "type": { 3976 | "type": "string" 3977 | } 3978 | } 3979 | }, 3980 | "Lists": { 3981 | "type": "object", 3982 | "properties": { 3983 | "created_at": { 3984 | "type": "string" 3985 | }, 3986 | "slug": { 3987 | "type": "string" 3988 | }, 3989 | "name": { 3990 | "type": "string" 3991 | }, 3992 | "description": { 3993 | "type": "string" 3994 | }, 3995 | "mode": { 3996 | "type": "string" 3997 | }, 3998 | "following": { 3999 | "type": "boolean" 4000 | }, 4001 | "user": { 4002 | "$ref": "#/definitions/Users" 4003 | }, 4004 | "member_count": { 4005 | "type": "integer" 4006 | }, 4007 | "id_str": { 4008 | "type": "string" 4009 | }, 4010 | "subscriber_count": { 4011 | "type": "integer" 4012 | }, 4013 | "id": { 4014 | "type": "integer" 4015 | }, 4016 | "uri": { 4017 | "type": "string" 4018 | } 4019 | } 4020 | }, 4021 | "Cursor_lists": { 4022 | "type": "object", 4023 | "properties": { 4024 | "previous_cursor": { 4025 | "type": "integer" 4026 | }, 4027 | "lists": { 4028 | "type": "array", 4029 | "items": { 4030 | "$ref": "#/definitions/Lists" 4031 | } 4032 | }, 4033 | "previous_cursor_str": { 4034 | "type": "string" 4035 | }, 4036 | "next_cursor": { 4037 | "type": "integer" 4038 | }, 4039 | "next_cursor_str": { 4040 | "type": "string" 4041 | } 4042 | } 4043 | }, 4044 | "Cursor_users": { 4045 | "type": "object", 4046 | "properties": { 4047 | "previous_cursor": { 4048 | "type": "integer" 4049 | }, 4050 | "users": { 4051 | "type": "array", 4052 | "items": { 4053 | "$ref": "#/definitions/Users" 4054 | } 4055 | }, 4056 | "previous_cursor_str": { 4057 | "type": "string" 4058 | }, 4059 | "next_cursor": { 4060 | "type": "integer" 4061 | }, 4062 | "next_cursor_str": { 4063 | "type": "string" 4064 | } 4065 | } 4066 | }, 4067 | "Cursor_ids": { 4068 | "type": "object", 4069 | "properties": { 4070 | "previous_cursor": { 4071 | "type": "integer" 4072 | }, 4073 | "users": { 4074 | "type": "array", 4075 | "items": { 4076 | "type": "integer" 4077 | } 4078 | }, 4079 | "previous_cursor_str": { 4080 | "type": "string" 4081 | }, 4082 | "next_cursor": { 4083 | "type": "integer" 4084 | }, 4085 | "next_cursor_str": { 4086 | "type": "string" 4087 | } 4088 | } 4089 | }, 4090 | "Messages": { 4091 | "type": "object", 4092 | "properties": { 4093 | "created_at": { 4094 | "type": "string" 4095 | }, 4096 | "entities": { 4097 | "$ref": "#/definitions/Entities" 4098 | }, 4099 | "id": { 4100 | "type": "integer" 4101 | }, 4102 | "id_string": { 4103 | "type": "string" 4104 | }, 4105 | "recipient": { 4106 | "$ref": "#/definitions/Users" 4107 | }, 4108 | "recipient_id": { 4109 | "type": "integer" 4110 | }, 4111 | "recipient_screen_name": { 4112 | "type": "string" 4113 | }, 4114 | "sender": { 4115 | "$ref": "#/definitions/Users" 4116 | }, 4117 | "sender_id": { 4118 | "type": "integer" 4119 | }, 4120 | "sender_screen_name": { 4121 | "type": "string" 4122 | }, 4123 | "text": { 4124 | "type": "string" 4125 | } 4126 | } 4127 | }, 4128 | "Query": { 4129 | "type": "object", 4130 | "properties": { 4131 | "created_at": { 4132 | "type": "string" 4133 | }, 4134 | "id": { 4135 | "type": "integer" 4136 | }, 4137 | "id_str": { 4138 | "type": "string" 4139 | }, 4140 | "name": { 4141 | "type": "string" 4142 | }, 4143 | "position": { 4144 | "type": "string" 4145 | }, 4146 | "query": { 4147 | "type": "string" 4148 | } 4149 | } 4150 | }, 4151 | "Friendship": { 4152 | "type": "object", 4153 | "properties": { 4154 | "relationship": { 4155 | "$ref": "#/definitions/Targets" 4156 | }, 4157 | "source": { 4158 | "$ref": "#/definitions/Source" 4159 | } 4160 | } 4161 | }, 4162 | "Targets": { 4163 | "type": "object", 4164 | "properties": { 4165 | "target": { 4166 | "$ref": "#/definitions/Target" 4167 | } 4168 | } 4169 | }, 4170 | "Target": { 4171 | "type": "object", 4172 | "properties": { 4173 | "id_str": { 4174 | "type": "string" 4175 | }, 4176 | "id": { 4177 | "type": "integer" 4178 | }, 4179 | "followed_by": { 4180 | "type": "boolean" 4181 | }, 4182 | "screen_name": { 4183 | "type": "string" 4184 | }, 4185 | "following": { 4186 | "type": "boolean" 4187 | } 4188 | } 4189 | }, 4190 | "Source": { 4191 | "type": "object", 4192 | "properties": { 4193 | "can_dm": { 4194 | "type": "boolean" 4195 | }, 4196 | "blocking": { 4197 | "type": "boolean" 4198 | }, 4199 | "id_str": { 4200 | "type": "boolean" 4201 | }, 4202 | "all_replies": { 4203 | "type": "boolean" 4204 | }, 4205 | "want_retweets": { 4206 | "type": "boolean" 4207 | }, 4208 | "id": { 4209 | "type": "integer" 4210 | }, 4211 | "marked_spam": { 4212 | "type": "boolean" 4213 | }, 4214 | "followed_by": { 4215 | "type": "boolean" 4216 | }, 4217 | "notifications_enable": { 4218 | "type": "boolean" 4219 | }, 4220 | "screen_name": { 4221 | "type": "string" 4222 | }, 4223 | "following": { 4224 | "type": "boolean" 4225 | } 4226 | } 4227 | }, 4228 | "Settings": { 4229 | "type": "object", 4230 | "properties": { 4231 | "sleep_time": { 4232 | "$ref": "#/definitions/Sleep" 4233 | }, 4234 | "use_cookie_personalization": { 4235 | "type": "boolean" 4236 | }, 4237 | "trend_location": { 4238 | "type": "array", 4239 | "items": { 4240 | "$ref": "#/definitions/Location" 4241 | } 4242 | }, 4243 | "language": { 4244 | "type": "string" 4245 | }, 4246 | "discoverable_by_email": { 4247 | "type": "boolean" 4248 | }, 4249 | "always_use_https": { 4250 | "type": "boolean" 4251 | }, 4252 | "protected": { 4253 | "type": "boolean" 4254 | }, 4255 | "geo_enabled": { 4256 | "type": "boolean" 4257 | }, 4258 | "show_all_inline_media": { 4259 | "type": "boolean" 4260 | }, 4261 | "screen_name": { 4262 | "type": "string" 4263 | } 4264 | } 4265 | }, 4266 | "Sleep": { 4267 | "type": "object", 4268 | "properties": { 4269 | "end_time": { 4270 | "type": "string" 4271 | }, 4272 | "enabled": { 4273 | "type": "boolean" 4274 | }, 4275 | "start_time": { 4276 | "type": "string" 4277 | } 4278 | } 4279 | }, 4280 | "Location": { 4281 | "type": "object", 4282 | "properties": { 4283 | "name": { 4284 | "type": "string" 4285 | }, 4286 | "placeType": { 4287 | "$ref": "#/definitions/PlaceType" 4288 | }, 4289 | "woeid": { 4290 | "type": "integer" 4291 | }, 4292 | "country": { 4293 | "type": "string" 4294 | }, 4295 | "url": { 4296 | "type": "string" 4297 | }, 4298 | "countryCode": { 4299 | "type": "string" 4300 | }, 4301 | "parentid": { 4302 | "type": "integer" 4303 | } 4304 | } 4305 | }, 4306 | "PlaceType": { 4307 | "type": "object", 4308 | "properties": { 4309 | "name": { 4310 | "type": "string" 4311 | }, 4312 | "code": { 4313 | "type": "integer" 4314 | } 4315 | } 4316 | }, 4317 | "TrendInfo": { 4318 | "type": "object", 4319 | "properties": { 4320 | "as_of": { 4321 | "type": "string" 4322 | }, 4323 | "created_at": { 4324 | "type": "string" 4325 | }, 4326 | "locations": { 4327 | "type": "array", 4328 | "items": { 4329 | "$ref": "#/definitions/Location" 4330 | } 4331 | }, 4332 | "trends": { 4333 | "type": "array", 4334 | "items": { 4335 | "$ref": "#/definitions/Trends" 4336 | } 4337 | } 4338 | } 4339 | }, 4340 | "Trends": { 4341 | "type": "object", 4342 | "properties": { 4343 | "events": { 4344 | "type": "string" 4345 | }, 4346 | "name": { 4347 | "type": "string" 4348 | }, 4349 | "promoted_content": { 4350 | "type": "string" 4351 | }, 4352 | "query": { 4353 | "type": "string" 4354 | }, 4355 | "url": { 4356 | "type": "string" 4357 | } 4358 | } 4359 | }, 4360 | "Help_Config": { 4361 | "type": "object", 4362 | "properties": { 4363 | "dm_text_character_limit": { 4364 | "type": "integer" 4365 | }, 4366 | "characters_reserved_per_media": { 4367 | "type": "integer" 4368 | }, 4369 | "max_media_per_upload": { 4370 | "type": "integer" 4371 | }, 4372 | "non_username_paths": { 4373 | "type": "array", 4374 | "items": { 4375 | "type": "string" 4376 | } 4377 | }, 4378 | "photo_size_limit": { 4379 | "type": "integer" 4380 | }, 4381 | "photo_sizes": { 4382 | "$ref": "#/definitions/Sizes" 4383 | } 4384 | } 4385 | }, 4386 | "Help_Language": { 4387 | "type": "object", 4388 | "properties": { 4389 | "code": { 4390 | "type": "string" 4391 | }, 4392 | "status": { 4393 | "type": "string" 4394 | }, 4395 | "name": { 4396 | "type": "string" 4397 | } 4398 | } 4399 | }, 4400 | "Help_Privacy": { 4401 | "type": "object", 4402 | "properties": { 4403 | "privacy": { 4404 | "type": "string" 4405 | } 4406 | } 4407 | }, 4408 | "Help_Tos": { 4409 | "type": "object", 4410 | "properties": { 4411 | "Tos": { 4412 | "type": "string" 4413 | } 4414 | } 4415 | } 4416 | } 4417 | } 4418 | -------------------------------------------------------------------------------- /demo/index.js: -------------------------------------------------------------------------------- 1 | var live = document.getElementById("live"); 2 | var hoverPreviewEnabledCheckbox = document.getElementById( 3 | "hoverPreviewEnabled", 4 | ); 5 | 6 | function render() { 7 | live.style.backgroundColor = "transparent"; 8 | var result = document.getElementById("live-result"); 9 | try { 10 | var formatter = new JSONFormatter(JSON.parse(live.value), 1, { 11 | hoverPreviewEnabled: hoverPreviewEnabledCheckbox.checked, 12 | }); 13 | result.innerHTML = ""; 14 | result.appendChild(formatter.render()); 15 | } catch (e) { 16 | live.style.backgroundColor = "rgba(255, 87, 34, 0.35)"; 17 | } 18 | } 19 | live.addEventListener("keyup", render); 20 | hoverPreviewEnabledCheckbox.addEventListener("change", render); 21 | render(); 22 | 23 | var complex = { 24 | numbers: [1, 2, 3], 25 | boolean: true, 26 | null: null, 27 | number: 123, 28 | anObject: { 29 | a: "b", 30 | e: "d", 31 | c: 'f"', 32 | }, 33 | string: "Hello World", 34 | url: "https://github.com/mohsen1/json-formatter-js", 35 | date: new Date(), 36 | func: function add(a, b) { 37 | return a + b; 38 | }, 39 | }; 40 | 41 | var deep = { a: { b: { c: { d: {} } } } }; 42 | 43 | var examples = [ 44 | { title: "Complex", json: complex }, 45 | { title: "Number", json: 42 }, 46 | { title: "null", json: null }, 47 | { title: "Empty Object", json: Object.create(null) }, 48 | { title: "Empty Array", json: [] }, 49 | { title: "Deep", json: deep }, 50 | { title: "Dark", json: complex, config: { theme: "dark" } }, 51 | { 52 | title: "Sorted Keys", 53 | json: complex, 54 | config: { sortPropertiesBy: (a, b) => a > b }, 55 | }, 56 | { 57 | title: "Very large array", 58 | json: Array(1000) 59 | .fill(0) 60 | .map(() => Math.ceil(Math.random() * 1000)), 61 | config: { maxLength: 100 }, 62 | }, 63 | ]; 64 | 65 | var result = document.querySelector(".result"); 66 | 67 | examples.forEach(function (example) { 68 | var title = document.createElement("h3"); 69 | var formatter = new JSONFormatter(example.json, 1, example.config); 70 | 71 | title.innerText = example.title; 72 | 73 | result.appendChild(title); 74 | var el = formatter.render(); 75 | 76 | if (example.config && example.config.theme === "dark") { 77 | el.style.backgroundColor = "#1E1E1E"; 78 | } 79 | 80 | result.appendChild(el); 81 | }); 82 | 83 | fetch("demo/giant.json").then(function (resp) { 84 | resp.json().then(function (giant) { 85 | var giantFormatter = new JSONFormatter(giant, 2, { 86 | hoverPreviewEnabled: true, 87 | }); 88 | var title = document.createElement("h3"); 89 | 90 | title.innerText = "Giant JSON"; 91 | result.appendChild(title); 92 | 93 | console.time("Rendering giant JSON"); 94 | result.appendChild(giantFormatter.render()); 95 | console.timeEnd("Rendering giant JSON"); 96 | }); 97 | }); 98 | -------------------------------------------------------------------------------- /demo/webpack.config.js: -------------------------------------------------------------------------------- 1 | var path = require("path"); 2 | 3 | module.exports = { 4 | devtool: "sourcemap", 5 | context: __dirname, 6 | entry: "./index.js", 7 | output: { 8 | path: path.join(__dirname, "../dist/demo"), 9 | filename: "index.js", 10 | }, 11 | }; 12 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 31 | 32 | 33 |
34 |
35 | 43 | 51 |
52 |

JSONFormatter

53 |

Render JSON objects in HTML with a collapsible navigation.

54 |

55 | JSON Formatter project on GitHub 60 |

61 |
62 |

Usage

63 |
64 |

Simple usage in ES6

65 | 75 | 76 |
86 |
import JSONFormatter from 'json-formatter-js'
 89 | 
 90 | const myJSON = {ans: 42};
 91 | 
 92 | const formatter = new JSONFormatter(myJSON);
 93 | 
 94 | document.body.appendChild(formatter.render());
 95 |   
96 |
97 |
98 |

Playground

99 |
100 |

101 | Updating the JSON value in this textarea renders a new formatter on the 102 | right. 103 |

104 | 105 | 106 | 111 | 114 | 115 | 116 |

117 | 118 | 121 |

122 | 123 |
107 | 110 | 112 |
113 |
124 |
125 |

Examples

126 |
127 | 128 | 129 | -------------------------------------------------------------------------------- /mocks/less.ts: -------------------------------------------------------------------------------- 1 | export default {}; 2 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "json-formatter-js", 3 | "version": "2.5.6", 4 | "description": "JSON Formatter core library ", 5 | "main": "dist/json-formatter.cjs", 6 | "module": "dist/json-formatter.mjs", 7 | "browser": "dist/json-formatter.umd.js", 8 | "types": "dist/index.d.ts", 9 | "exports": { 10 | ".": { 11 | "import": "./dist/json-formatter.mjs", 12 | "require": "./dist/json-formatter.cjs", 13 | "browser": "./dist/json-formatter.umd.cjs", 14 | "types": "./dist/index.d.ts", 15 | "default": "./dist/json-formatter.cjs" 16 | } 17 | }, 18 | "scripts": { 19 | "build": "rollup -c", 20 | "dev": "rollup -c rollup.dev.config.js", 21 | "test": "jest" 22 | }, 23 | "jest": { 24 | "transform": { 25 | ".(ts|tsx)": "ts-jest" 26 | }, 27 | "testRegex": "test/spec.ts", 28 | "moduleNameMapper": { 29 | ".*\\.less$": "/mocks/less.ts" 30 | }, 31 | "moduleFileExtensions": [ 32 | "ts", 33 | "tsx", 34 | "js" 35 | ], 36 | "testEnvironment": "jsdom" 37 | }, 38 | "repository": { 39 | "type": "git", 40 | "url": "git+https://github.com/mohsen1/json-formatter-js.git" 41 | }, 42 | "keywords": [ 43 | "json" 44 | ], 45 | "author": "Mohsen Azimi ", 46 | "license": "MIT", 47 | "bugs": { 48 | "url": "https://github.com/mohsen1/json-formatter-js/issues" 49 | }, 50 | "homepage": "https://github.com/mohsen1/json-formatter-js#readme", 51 | "devDependencies": { 52 | "@types/jest": "^29.5.12", 53 | "css-loader": "^7.1.2", 54 | "jest": "^29.7.0", 55 | "jest-environment-jsdom": "^29.7.0", 56 | "less": "^4.2.0", 57 | "less-loader": "^12.2.0", 58 | "prettier": "^3.3.2", 59 | "rollup": "^2.79.2", 60 | "rollup-plugin-less": "^1.1.2", 61 | "rollup-plugin-livereload": "^1.0.4", 62 | "rollup-plugin-serve": "^1.0.1", 63 | "rollup-plugin-terser": "^5.1.2", 64 | "rollup-plugin-typescript2": "^0.24.3", 65 | "ts-jest": "^29.1.5", 66 | "typescript": "^5.5.2", 67 | "webpack-dev-server": "^5.0.4" 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | import typescript from "rollup-plugin-typescript2"; 2 | import { terser } from "rollup-plugin-terser"; 3 | import less from "rollup-plugin-less"; 4 | import pkg from "./package.json"; 5 | 6 | export default { 7 | input: "src/index.ts", 8 | output: [ 9 | { 10 | file: pkg.main, 11 | format: "cjs", 12 | }, 13 | { 14 | file: pkg.module, 15 | format: "es", 16 | }, 17 | { 18 | file: pkg.browser, 19 | format: "umd", 20 | name: "JSONFormatter", 21 | }, 22 | ], 23 | external: [...Object.keys(pkg.dependencies || {})], 24 | plugins: [ 25 | typescript({ 26 | typescript: require("typescript"), 27 | include: ["src/*.ts+(|x)"], 28 | verbosity: 3, 29 | }), 30 | terser(), // minifies generated bundles 31 | less({ 32 | insert: true, 33 | output: "dist/json-formatter.css", 34 | }), 35 | ], 36 | }; 37 | -------------------------------------------------------------------------------- /rollup.dev.config.js: -------------------------------------------------------------------------------- 1 | import typescript from "rollup-plugin-typescript2"; 2 | import { terser } from "rollup-plugin-terser"; 3 | import less from "rollup-plugin-less"; 4 | import pkg from "./package.json"; 5 | import serve from "rollup-plugin-serve"; 6 | import livereload from "rollup-plugin-livereload"; 7 | 8 | export default { 9 | input: "src/index.ts", 10 | output: [ 11 | { 12 | file: pkg.browser, 13 | format: "umd", 14 | name: "JSONFormatter", 15 | }, 16 | ], 17 | external: [...Object.keys(pkg.dependencies || {})], 18 | plugins: [ 19 | typescript({ 20 | typescript: require("typescript"), 21 | include: ["src/*.ts+(|x)"], 22 | verbosity: 3, 23 | }), 24 | terser(), // minifies generated bundles 25 | less({ 26 | insert: true, 27 | output: "dist/json-formatter.css", 28 | }), 29 | serve(), 30 | livereload(), 31 | ], 32 | }; 33 | -------------------------------------------------------------------------------- /server.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var webpack = require("webpack"); 3 | var webpackDevServer = require("webpack-dev-server"); 4 | var PORT = process.env.PORT || 8080; 5 | var config = require("./webpack.config.js"); 6 | config.entry.app.unshift( 7 | `webpack-dev-server/client?http://localhost:{PORT}/`, 8 | "webpack/hot/dev-server", 9 | ); 10 | var compiler = webpack(config); 11 | var server = new webpackDevServer(compiler, { 12 | progress: true, 13 | quiet: true, 14 | publicPath: config.output.publicPath, 15 | }); 16 | server.listen( 17 | PORT, 18 | console.log.bind( 19 | null, 20 | `Development server started at http://localhost:${PORT}`, 21 | ), 22 | ); 23 | -------------------------------------------------------------------------------- /src/helpers.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Escapes `"` charachters from string 3 | */ 4 | function escapeString(str: string): string { 5 | return str.replace(/"/g, '\\"'); 6 | } 7 | 8 | export function getType(value: any): string { 9 | if (value === null) { 10 | return "null"; 11 | } 12 | return typeof value; 13 | } 14 | 15 | /* 16 | * Determines if a value is an object 17 | */ 18 | export function isObject(value: any): boolean { 19 | var type = typeof value; 20 | return !!value && type == "object"; 21 | } 22 | 23 | /* 24 | * Gets constructor name of an object. 25 | * From http://stackoverflow.com/a/332429 26 | * 27 | */ 28 | export function getObjectName(object: Object): string { 29 | if (object === undefined) { 30 | return ""; 31 | } 32 | if (object === null) { 33 | return "Object"; 34 | } 35 | if (typeof object === "object" && !object.constructor) { 36 | return "Object"; 37 | } 38 | 39 | const funcNameRegex = /function ([^(]*)/; 40 | const results = funcNameRegex.exec(object.constructor.toString()); 41 | if (results && results.length > 1) { 42 | return results[1]; 43 | } else { 44 | return ""; 45 | } 46 | } 47 | 48 | /* 49 | * Generates inline preview for a JavaScript object based on a type and value 50 | */ 51 | export function getValuePreview( 52 | type: string, 53 | object: Object, 54 | value: string, 55 | ): string { 56 | if (type === "null" || type === "undefined") { 57 | return type; 58 | } 59 | 60 | if (type === "string" || type === "stringifiable") { 61 | value = '"' + escapeString(value) + '"'; 62 | } 63 | if (type === "function") { 64 | // Remove content of the function 65 | return ( 66 | object 67 | .toString() 68 | .replace(/[\r\n]/g, "") 69 | .replace(/\{.*\}/, "") + "{…}" 70 | ); 71 | } 72 | return value; 73 | } 74 | 75 | /* 76 | * Generates inline preview for a JavaScript object 77 | */ 78 | export function getPreview(object: any): string { 79 | let value = ""; 80 | if (isObject(object)) { 81 | value = getObjectName(object); 82 | if (Array.isArray(object)) value += "[" + object.length + "]"; 83 | } else { 84 | value = getValuePreview(getType(object), object, object); 85 | } 86 | return value; 87 | } 88 | 89 | /* 90 | * Generates a prefixed CSS class name 91 | */ 92 | export function cssClass(className: string): string { 93 | return `json-formatter-${className}`; 94 | } 95 | 96 | /* 97 | * Creates a new DOM element wiht given type and class 98 | * TODO: move me to helpers 99 | */ 100 | export function createElement( 101 | type: string, 102 | className?: string, 103 | content?: Element | string, 104 | ): Element { 105 | const el = document.createElement(type); 106 | if (className) { 107 | el.classList.add(cssClass(className)); 108 | } 109 | if (content !== undefined) { 110 | if (content instanceof Node) { 111 | el.appendChild(content); 112 | } else { 113 | el.appendChild(document.createTextNode(String(content))); 114 | } 115 | } 116 | return el; 117 | } 118 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import { 2 | getType, 3 | isObject, 4 | getObjectName, 5 | getValuePreview, 6 | getPreview, 7 | cssClass, 8 | createElement, 9 | } from "./helpers"; 10 | 11 | import "./style.less"; 12 | 13 | const DATE_STRING_REGEX = 14 | /(^\d{1,4}[\.|\\/|-]\d{1,2}[\.|\\/|-]\d{1,4})(\s*(?:0?[1-9]:[0-5]|1(?=[012])\d:[0-5])\d\s*[ap]m)?$/; 15 | const PARTIAL_DATE_REGEX = /\d{2}:\d{2}:\d{2} GMT-\d{4}/; 16 | const JSON_DATE_REGEX = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/; 17 | const URL_REGEX = /^https?:\/\//; 18 | 19 | // When toggleing, don't animated removal or addition of more than a few items 20 | const MAX_ANIMATED_TOGGLE_ITEMS = 10; 21 | 22 | const requestAnimationFrame = 23 | window.requestAnimationFrame || 24 | function (cb: () => void) { 25 | cb(); 26 | return 0; 27 | }; 28 | 29 | export interface JSONFormatterConfiguration { 30 | hoverPreviewEnabled?: boolean; 31 | hoverPreviewArrayCount?: number; 32 | hoverPreviewFieldCount?: number; 33 | animateOpen?: boolean; 34 | animateClose?: boolean; 35 | theme?: string; 36 | useToJSON?: boolean; 37 | sortPropertiesBy?: (a: string, b: string) => number; 38 | maxArrayItems?: number; 39 | exposePath?: boolean; 40 | } 41 | 42 | const _defaultConfig: JSONFormatterConfiguration = { 43 | hoverPreviewEnabled: false, 44 | hoverPreviewArrayCount: 100, 45 | hoverPreviewFieldCount: 5, 46 | animateOpen: true, 47 | animateClose: true, 48 | theme: null, 49 | useToJSON: true, 50 | sortPropertiesBy: null, 51 | maxArrayItems: 100, 52 | exposePath: false, 53 | }; 54 | 55 | /** 56 | * @class JSONFormatter 57 | * 58 | * JSONFormatter allows you to render JSON objects in HTML with a 59 | * **collapsible** navigation. 60 | */ 61 | export default class JSONFormatter { 62 | // Hold the open state after the toggler is used 63 | private _isOpen: boolean = null; 64 | 65 | // A reference to the element that we render to 66 | private element: Element; 67 | 68 | /** 69 | * @param {object} json The JSON object you want to render. It has to be an 70 | * object or array. Do NOT pass raw JSON string. 71 | * 72 | * @param {number} [open=1] his number indicates up to how many levels the 73 | * rendered tree should expand. Set it to `0` to make the whole tree collapsed 74 | * or set it to `Infinity` to expand the tree deeply 75 | * 76 | * @param {object} [config=defaultConfig] - 77 | * defaultConfig = { 78 | * hoverPreviewEnabled: false, 79 | * hoverPreviewArrayCount: 100, 80 | * hoverPreviewFieldCount: 5 81 | * } 82 | * 83 | * Available configurations: 84 | * #####Hover Preview 85 | * * `hoverPreviewEnabled`: enable preview on hover 86 | * * `hoverPreviewArrayCount`: number of array items to show in preview Any 87 | * array larger than this number will be shown as `Array[XXX]` where `XXX` 88 | * is length of the array. 89 | * * `hoverPreviewFieldCount`: number of object properties to show for object 90 | * preview. Any object with more properties that thin number will be 91 | * truncated. 92 | * 93 | * @param {string} [key=undefined] The key that this object in it's parent 94 | * context 95 | * 96 | * @param {string[]} [path=undefined] An array of key used to correlate the DOM element to the original JSON 97 | * 98 | * @param {[number, number]} [arrayRange=undefined] A range (min, max) of items. This is available when the parent node is an array range. 99 | */ 100 | constructor( 101 | public json: any, 102 | private open = 1, 103 | private config: JSONFormatterConfiguration = _defaultConfig, 104 | private key?: string, 105 | private displayKey?: string, 106 | private path: string[] = [], 107 | private arrayRange?: [number, number], 108 | ) { 109 | // Setting default values for config object 110 | if (this.config.hoverPreviewEnabled === undefined) { 111 | this.config.hoverPreviewEnabled = _defaultConfig.hoverPreviewEnabled; 112 | } 113 | if (this.config.hoverPreviewArrayCount === undefined) { 114 | this.config.hoverPreviewArrayCount = 115 | _defaultConfig.hoverPreviewArrayCount; 116 | } 117 | if (this.config.hoverPreviewFieldCount === undefined) { 118 | this.config.hoverPreviewFieldCount = 119 | _defaultConfig.hoverPreviewFieldCount; 120 | } 121 | if (this.config.useToJSON === undefined) { 122 | this.config.useToJSON = _defaultConfig.useToJSON; 123 | } 124 | 125 | if (this.config.maxArrayItems === undefined) { 126 | this.config.maxArrayItems = _defaultConfig.maxArrayItems; 127 | } 128 | 129 | if (this.key === "") { 130 | this.key = '""'; 131 | } 132 | 133 | if (this.displayKey === undefined) { 134 | this.displayKey = this.key; 135 | } 136 | } 137 | 138 | /* 139 | * is formatter open? 140 | */ 141 | private get isOpen(): boolean { 142 | if (this._isOpen !== null) { 143 | return this._isOpen; 144 | } else { 145 | return this.open > 0; 146 | } 147 | } 148 | 149 | /* 150 | * set open state (from toggler) 151 | */ 152 | private set isOpen(value: boolean) { 153 | this._isOpen = value; 154 | } 155 | 156 | /* 157 | * is this a date string? 158 | */ 159 | private get isDate(): boolean { 160 | return ( 161 | this.json instanceof Date || 162 | (this.type === "string" && 163 | (DATE_STRING_REGEX.test(this.json) || 164 | JSON_DATE_REGEX.test(this.json) || 165 | PARTIAL_DATE_REGEX.test(this.json))) 166 | ); 167 | } 168 | 169 | /* 170 | * is this a URL string? 171 | */ 172 | private get isUrl(): boolean { 173 | return this.type === "string" && URL_REGEX.test(this.json); 174 | } 175 | 176 | /* 177 | * is this an array? 178 | */ 179 | private get isArray(): boolean { 180 | return Array.isArray(this.json); 181 | } 182 | 183 | /* 184 | * is this an array with too many elements? 185 | */ 186 | private get isLargeArray(): boolean { 187 | return this.isArray && this.json.length > this.config.maxArrayItems; 188 | } 189 | 190 | /* 191 | * is this an array range? 192 | */ 193 | private get isArrayRange(): boolean { 194 | return ( 195 | this.isArray && 196 | this.arrayRange !== undefined && 197 | this.arrayRange.length == 2 198 | ); 199 | } 200 | 201 | /* 202 | * is this an object? 203 | * Note: In this context arrays are object as well 204 | */ 205 | private get isObject(): boolean { 206 | return isObject(this.json); 207 | } 208 | 209 | /* 210 | * is this an empty object with no properties? 211 | */ 212 | private get isEmptyObject(): boolean { 213 | return !this.keys.length && !this.isArray; 214 | } 215 | 216 | /* 217 | * is this an empty object or array? 218 | */ 219 | private get isEmpty(): boolean { 220 | return ( 221 | this.isEmptyObject || (this.keys && !this.keys.length && this.isArray) 222 | ); 223 | } 224 | 225 | /* 226 | * does this has a `toJSON` method and is it configured to be used? 227 | * This means that it has it's own renderer for JSON.stringify (Date, Mongo's ObjectID, etc.) 228 | */ 229 | private get useToJSON(): boolean { 230 | return this.config.useToJSON && this.type === "stringifiable"; 231 | } 232 | 233 | /* 234 | * did we recieve a key argument? 235 | * This means that the formatter was called as a sub formatter of a parent formatter 236 | */ 237 | private get hasKey(): boolean { 238 | return typeof this.key !== "undefined"; 239 | } 240 | 241 | /* 242 | * if this is an object, get constructor function name 243 | */ 244 | private get constructorName(): string { 245 | return getObjectName(this.json); 246 | } 247 | 248 | /* 249 | * get type of this value. Returns "null" for null objects 250 | * Possible values: all JavaScript primitive types plus "array" and "null" 251 | */ 252 | private get type(): string { 253 | if (this.config.useToJSON && this.json && this.json["toJSON"]) { 254 | return "stringifiable"; 255 | } 256 | return getType(this.json); 257 | } 258 | 259 | /* 260 | * get object keys 261 | * If there is an empty key we pad it wit quotes to make it visible 262 | */ 263 | private get keys(): string[] { 264 | if (this.isObject) { 265 | let keys = Object.keys(this.json); 266 | 267 | // Split long arrays into multiple groups 268 | if (this.isLargeArray) { 269 | let keysCount = Math.ceil(this.json.length / this.config.maxArrayItems); 270 | keys = []; 271 | for (let i = 0; i < keysCount; i++) { 272 | const min = i * this.config.maxArrayItems; 273 | const max = Math.min( 274 | this.json.length - 1, 275 | min + (this.config.maxArrayItems - 1), 276 | ); 277 | keys.push(`${min} … ${max}`); 278 | } 279 | } 280 | 281 | return !this.isArray && this.config.sortPropertiesBy 282 | ? keys.sort(this.config.sortPropertiesBy) 283 | : keys; 284 | } else { 285 | return []; 286 | } 287 | } 288 | 289 | /** 290 | * Toggles `isOpen` state 291 | * 292 | */ 293 | toggleOpen() { 294 | this.isOpen = !this.isOpen; 295 | 296 | if (this.element) { 297 | if (this.isOpen) { 298 | this.appendChildren(this.config.animateOpen); 299 | } else { 300 | this.removeChildren(this.config.animateClose); 301 | } 302 | this.element.classList.toggle(cssClass("open")); 303 | } 304 | } 305 | 306 | /** 307 | * Open all children up to a certain depth. 308 | * Allows actions such as expand all/collapse all 309 | * 310 | */ 311 | openAtDepth(depth = 1) { 312 | if (depth < 0) { 313 | return; 314 | } 315 | 316 | this.open = depth; 317 | this.isOpen = depth !== 0; 318 | 319 | if (this.element) { 320 | this.removeChildren(false); 321 | 322 | if (depth === 0) { 323 | this.element.classList.remove(cssClass("open")); 324 | } else { 325 | this.appendChildren(this.config.animateOpen); 326 | this.element.classList.add(cssClass("open")); 327 | } 328 | } 329 | } 330 | 331 | /** 332 | * Generates inline preview 333 | * 334 | * @returns {string} 335 | */ 336 | getInlinepreview() { 337 | if (this.isArray) { 338 | // if array length is greater then 100 it shows "Array[101]" 339 | if (this.json.length > this.config.hoverPreviewArrayCount) { 340 | return `Array[${this.json.length}]`; 341 | } else { 342 | return `[${this.json.map(getPreview).join(", ")}]`; 343 | } 344 | } else { 345 | const keys = this.keys; 346 | 347 | // the first five keys (like Chrome Developer Tool) 348 | const narrowKeys = keys.slice(0, this.config.hoverPreviewFieldCount); 349 | 350 | // json value schematic information 351 | const kvs = narrowKeys.map( 352 | (key) => `${key}:${getPreview(this.json[key])}`, 353 | ); 354 | 355 | // if keys count greater then 5 then show ellipsis 356 | const ellipsis = 357 | keys.length >= this.config.hoverPreviewFieldCount ? "…" : ""; 358 | 359 | return `{${kvs.join(", ")}${ellipsis}}`; 360 | } 361 | } 362 | 363 | /** 364 | * Renders an HTML element and installs event listeners 365 | * 366 | * @returns {HTMLDivElement} 367 | */ 368 | render(): HTMLDivElement { 369 | // construct the root element and assign it to this.element 370 | this.element = createElement("div", "row"); 371 | 372 | // construct the toggler link 373 | const togglerLink = this.isObject 374 | ? createElement("a", "toggler-link") 375 | : createElement("span"); 376 | 377 | // if this is an object we need a wrapper span (toggler) 378 | if (this.isObject && !this.useToJSON) { 379 | togglerLink.appendChild(createElement("span", "toggler")); 380 | } 381 | 382 | // if this is child of a parent formatter we need to append the key 383 | if (this.isArrayRange) { 384 | togglerLink.appendChild( 385 | createElement("span", "range", `[${this.displayKey}]`), 386 | ); 387 | } else if (this.hasKey) { 388 | togglerLink.appendChild( 389 | createElement("span", "key", `${this.displayKey}:`), 390 | ); 391 | 392 | // add path to node data 393 | if (this.config.exposePath) 394 | (this.element).dataset.path = JSON.stringify(this.path); 395 | } 396 | 397 | // Value for objects and arrays 398 | if (this.isObject && !this.useToJSON) { 399 | // construct the value holder element 400 | const value = createElement("span", "value"); 401 | 402 | // we need a wrapper span for objects 403 | const objectWrapperSpan = createElement("span"); 404 | 405 | // get constructor name and append it to wrapper span 406 | if (!this.isArrayRange) { 407 | const constructorName = createElement( 408 | "span", 409 | "constructor-name", 410 | this.constructorName, 411 | ); 412 | objectWrapperSpan.appendChild(constructorName); 413 | } 414 | 415 | // if it's an array append the array specific elements like brackets and length 416 | if (this.isArray && !this.isArrayRange) { 417 | const arrayWrapperSpan = createElement("span"); 418 | arrayWrapperSpan.appendChild(createElement("span", "bracket", "[")); 419 | arrayWrapperSpan.appendChild( 420 | createElement("span", "number", this.json.length), 421 | ); 422 | arrayWrapperSpan.appendChild(createElement("span", "bracket", "]")); 423 | objectWrapperSpan.appendChild(arrayWrapperSpan); 424 | } 425 | 426 | // append object wrapper span to toggler link 427 | value.appendChild(objectWrapperSpan); 428 | togglerLink.appendChild(value); 429 | 430 | // Primitive values 431 | } else { 432 | // make a value holder element 433 | const value = this.isUrl ? createElement("a") : createElement("span"); 434 | 435 | // add type and other type related CSS classes 436 | value.classList.add(cssClass(this.type)); 437 | if (this.isDate) { 438 | value.classList.add(cssClass("date")); 439 | } 440 | if (this.isUrl) { 441 | value.classList.add(cssClass("url")); 442 | value.setAttribute("href", this.json); 443 | } 444 | 445 | // Append value content to value element 446 | const valuePreview = getValuePreview( 447 | this.type, 448 | this.json, 449 | this.useToJSON ? this.json.toJSON() : this.json, 450 | ); 451 | value.appendChild(document.createTextNode(valuePreview)); 452 | 453 | // append the value element to toggler link 454 | togglerLink.appendChild(value); 455 | } 456 | 457 | // if hover preview is enabled, append the inline preview element 458 | if (this.isObject && this.config.hoverPreviewEnabled) { 459 | const preview = createElement("span", "preview-text"); 460 | preview.appendChild(document.createTextNode(this.getInlinepreview())); 461 | togglerLink.appendChild(preview); 462 | } 463 | 464 | // construct a children element 465 | const children = createElement("div", "children"); 466 | 467 | // set CSS classes for children 468 | if (this.isObject) { 469 | children.classList.add(cssClass("object")); 470 | } 471 | if (this.isArray) { 472 | children.classList.add(cssClass("array")); 473 | } 474 | if (this.isEmpty) { 475 | children.classList.add(cssClass("empty")); 476 | } 477 | 478 | // set CSS classes for root element 479 | if (this.config && this.config.theme) { 480 | this.element.classList.add(cssClass(this.config.theme)); 481 | } 482 | if (this.isOpen) { 483 | this.element.classList.add(cssClass("open")); 484 | } 485 | 486 | // append toggler and children elements to root element 487 | this.element.appendChild(togglerLink); 488 | this.element.appendChild(children); 489 | 490 | // if formatter is set to be open call appendChildren 491 | if (this.isObject && this.isOpen) { 492 | this.appendChildren(); 493 | } 494 | 495 | // add event listener for toggling 496 | if (this.isObject && !this.useToJSON) { 497 | togglerLink.addEventListener("click", this.toggleOpen.bind(this)); 498 | } 499 | 500 | return this.element; 501 | } 502 | 503 | /** 504 | * Appends all the children to children element 505 | * Animated option is used when user triggers this via a click 506 | */ 507 | appendChildren(animated: boolean = false) { 508 | const children = this.element.querySelector(`div.${cssClass("children")}`); 509 | 510 | if (!children || this.isEmpty) { 511 | return; 512 | } 513 | 514 | const append = (key: string, index: number) => { 515 | const range: [number, number] = this.isLargeArray 516 | ? [ 517 | index * this.config.maxArrayItems, 518 | Math.min( 519 | this.json.length - 1, 520 | index * this.config.maxArrayItems + 521 | (this.config.maxArrayItems - 1), 522 | ), 523 | ] 524 | : undefined; 525 | const displayKey = this.isArrayRange 526 | ? (this.arrayRange[0] + index).toString() 527 | : key; 528 | const json = range 529 | ? this.json.slice(range[0], range[1] + 1) 530 | : this.json[key]; 531 | const formatter = new JSONFormatter( 532 | json, 533 | this.open - 1, 534 | this.config, 535 | key, 536 | displayKey, 537 | range ? this.path : this.path.concat(displayKey), 538 | range, 539 | ); 540 | children.appendChild(formatter.render()); 541 | }; 542 | 543 | if (animated) { 544 | let index = 0; 545 | const addAChild = () => { 546 | const key = this.keys[index]; 547 | append(key, index); 548 | 549 | index += 1; 550 | 551 | if (index < this.keys.length) { 552 | if (index > MAX_ANIMATED_TOGGLE_ITEMS) { 553 | addAChild(); 554 | } else { 555 | requestAnimationFrame(addAChild); 556 | } 557 | } 558 | }; 559 | 560 | requestAnimationFrame(addAChild); 561 | } else { 562 | this.keys.forEach((key, index) => append(key, index)); 563 | } 564 | } 565 | 566 | /** 567 | * Removes all the children from children element 568 | * Animated option is used when user triggers this via a click 569 | */ 570 | removeChildren(animated: boolean = false) { 571 | const childrenElement = this.element.querySelector( 572 | `div.${cssClass("children")}`, 573 | ) as HTMLDivElement; 574 | 575 | if (animated) { 576 | let childrenRemoved = 0; 577 | const removeAChild = () => { 578 | if (childrenElement && childrenElement.children.length) { 579 | childrenElement.removeChild(childrenElement.children[0]); 580 | childrenRemoved += 1; 581 | if (childrenRemoved > MAX_ANIMATED_TOGGLE_ITEMS) { 582 | removeAChild(); 583 | } else { 584 | requestAnimationFrame(removeAChild); 585 | } 586 | } 587 | }; 588 | requestAnimationFrame(removeAChild); 589 | } else { 590 | if (childrenElement) { 591 | childrenElement.innerHTML = ""; 592 | } 593 | } 594 | } 595 | } 596 | -------------------------------------------------------------------------------- /src/style.less: -------------------------------------------------------------------------------- 1 | .theme( 2 | @default-color: black, 3 | @string-color: green, 4 | @number-color: blue, 5 | @boolean-color: red, 6 | @null-color: #855a00, 7 | @undefined-color: rgb(202, 11, 105), 8 | @function-color: #FF20ED, 9 | @rotate-time: 100ms, 10 | @toggler-opacity: 0.6, 11 | @toggler-color: #45376f, 12 | @bracket-color: blue, 13 | @key-color: #00008b, 14 | @url-color: blue ) { 15 | font-family: monospace; 16 | &, 17 | a, 18 | a:hover { 19 | color: @default-color; 20 | text-decoration: none; 21 | } 22 | 23 | .json-formatter-row { 24 | margin-left: 1rem; 25 | } 26 | 27 | .json-formatter-children { 28 | &.json-formatter-empty { 29 | opacity: 0.5; 30 | margin-left: 1rem; 31 | 32 | &:after { 33 | display: none; 34 | } 35 | &.json-formatter-object:after { 36 | content: "No properties"; 37 | } 38 | &.json-formatter-array:after { 39 | content: "[]"; 40 | } 41 | } 42 | } 43 | 44 | .json-formatter-string, 45 | .json-formatter-stringifiable { 46 | color: @string-color; 47 | white-space: pre; 48 | word-wrap: break-word; 49 | } 50 | .json-formatter-number { 51 | color: @number-color; 52 | } 53 | .json-formatter-boolean { 54 | color: @boolean-color; 55 | } 56 | .json-formatter-null { 57 | color: @null-color; 58 | } 59 | .json-formatter-undefined { 60 | color: @undefined-color; 61 | } 62 | .json-formatter-function { 63 | color: @function-color; 64 | } 65 | .json-formatter-date { 66 | background-color: fade(@default-color, 5%); 67 | } 68 | .json-formatter-url { 69 | text-decoration: underline; 70 | color: @url-color; 71 | cursor: pointer; 72 | } 73 | 74 | .json-formatter-bracket { 75 | color: @bracket-color; 76 | } 77 | .json-formatter-key { 78 | color: @key-color; 79 | padding-right: 0.2rem; 80 | } 81 | 82 | .json-formatter-toggler-link { 83 | cursor: pointer; 84 | } 85 | 86 | .json-formatter-toggler { 87 | line-height: 1.2rem; 88 | font-size: 0.7rem; 89 | vertical-align: middle; 90 | opacity: @toggler-opacity; 91 | cursor: pointer; 92 | padding-right: 0.2rem; 93 | 94 | &:after { 95 | display: inline-block; 96 | transition: transform @rotate-time ease-in; 97 | content: "►"; 98 | } 99 | } 100 | 101 | // Inline preview on hover (optional) 102 | > a > .json-formatter-preview-text { 103 | opacity: 0; 104 | transition: opacity 0.15s ease-in; 105 | font-style: italic; 106 | } 107 | &:hover > a > .json-formatter-preview-text { 108 | opacity: 0.6; 109 | } 110 | 111 | // Open state 112 | &.json-formatter-open { 113 | > .json-formatter-toggler-link .json-formatter-toggler:after { 114 | transform: rotate(90deg); 115 | } 116 | > .json-formatter-children:after { 117 | display: inline-block; 118 | } 119 | > a > .json-formatter-preview-text { 120 | display: none; 121 | } 122 | &.json-formatter-empty:after { 123 | display: block; 124 | } 125 | } 126 | } 127 | 128 | // Default theme 129 | .json-formatter-row { 130 | .theme(); 131 | } 132 | 133 | // Dark theme 134 | .json-formatter-dark.json-formatter-row { 135 | .theme( 136 | @default-color: white, 137 | @string-color: #31f031, 138 | @number-color: #66c2ff, 139 | @boolean-color: #EC4242, 140 | @null-color: #EEC97D, 141 | @undefined-color: rgb(239, 143, 190), 142 | @function-color: #FD48CB, 143 | @rotate-time: 100ms, 144 | @toggler-opacity: 0.6, 145 | @toggler-color: #45376f, 146 | @bracket-color: #9494ff, 147 | @key-color: #23a0db, 148 | @url-color: #027bff); 149 | } 150 | -------------------------------------------------------------------------------- /src/style.less.d.ts: -------------------------------------------------------------------------------- 1 | export const theme: string; 2 | -------------------------------------------------------------------------------- /test/spec.ts: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | import { default as JSONFormatter } from "../src/index"; 3 | 4 | describe("null", () => { 5 | it('should render "null"', () => { 6 | const formatter = new JSONFormatter(null); 7 | const el = formatter.render(); 8 | expect(el.textContent).toContain("null"); 9 | }); 10 | }); 11 | 12 | describe("undefined", () => { 13 | it('should render "undefined"', () => { 14 | const formatter = new JSONFormatter(undefined); 15 | 16 | expect(formatter.render().textContent).toContain("undefined"); 17 | }); 18 | }); 19 | 20 | describe("object function constructor", () => { 21 | it('should output "Format"', () => { 22 | function Format() {} 23 | const obj = new Format(); 24 | 25 | const formatter = new JSONFormatter(obj); 26 | expect(formatter["constructorName"]).toEqual("Format"); 27 | }); 28 | 29 | it('should output "BrokenFormat"', () => { 30 | const failConstructor = "function BrokenFormat() {Object.assign(}"; 31 | const funcNameRegex = /function ([^(]*)/; 32 | const results = funcNameRegex.exec(failConstructor.toString()); 33 | expect(results[1]).toEqual("BrokenFormat"); 34 | }); 35 | }); 36 | 37 | describe("function", () => { 38 | it("should render the function", () => { 39 | const formatter = new JSONFormatter(function add(a, b) { 40 | return a + b; 41 | }); 42 | const elementText = formatter.render().textContent; 43 | 44 | expect(elementText).toContain("function"); 45 | expect(elementText).toContain("add"); 46 | expect(elementText).toContain("(a, b)"); 47 | expect( 48 | elementText.trim().match(/function\s[^\(]*\([^\)]*\)\s*(.*)/)[1], 49 | ).toEqual("{…}"); 50 | }); 51 | }); 52 | 53 | describe("string", () => { 54 | it('should render "Hello World!"', () => { 55 | const formatter = new JSONFormatter("Hello World!"); 56 | 57 | expect(formatter.render().textContent).toContain("Hello World"); 58 | }); 59 | }); 60 | 61 | describe("date string", () => { 62 | const formatter = new JSONFormatter(new Date(0).toString()); 63 | 64 | it('should render "' + new Date(0).toString() + '"', () => { 65 | expect(formatter.render().textContent).toContain( 66 | '"' + new Date(0).toString() + '"', 67 | ); 68 | }); 69 | 70 | it("should assing date class to date string", () => { 71 | const formatter = new JSONFormatter("2015-12-05T18:58:53.727Z"); 72 | expect( 73 | formatter.render().querySelector(".json-formatter-date"), 74 | ).not.toBeNull(); 75 | }); 76 | }); 77 | 78 | describe("date", () => { 79 | const date = new Date(); 80 | const formatter = new JSONFormatter(date); 81 | 82 | it("should assing date class to date string", () => { 83 | expect( 84 | formatter.render().querySelector(".json-formatter-date"), 85 | ).not.toBeNull(); 86 | }); 87 | 88 | it('should render "' + date.toJSON() + '" if useToJSON is true', () => { 89 | expect(formatter.render().textContent).toContain('"' + date.toJSON() + '"'); 90 | }); 91 | 92 | it('should render "No properties" if useToJSON is false', () => { 93 | const formatter = new JSONFormatter(date, 1, { useToJSON: false }); 94 | expect(formatter.render().textContent).toContain("Date"); 95 | }); 96 | }); 97 | 98 | describe("url string", () => { 99 | const formatter = new JSONFormatter("https://example.com"); 100 | 101 | it('should render "https://example.com"', () => { 102 | expect(formatter.render().textContent).toContain('"https://example.com"'); 103 | }); 104 | 105 | it('should make a link and add class "url"', () => { 106 | expect( 107 | formatter.render().querySelector("a.json-formatter-url"), 108 | ).not.toEqual(null); 109 | }); 110 | }); 111 | 112 | describe("url detection shouldn't generate false positive for words starting with http", () => { 113 | const formatter = new JSONFormatter("httpstatus"); 114 | 115 | it("should not make a link and add class 'url'", () => { 116 | expect(formatter.render().querySelector("a.json-formatter-url")).toEqual( 117 | null, 118 | ); 119 | }); 120 | }); 121 | 122 | describe("object with empty property", () => { 123 | const formatter = new JSONFormatter({ "": true }); 124 | 125 | it("should render true", () => { 126 | expect( 127 | formatter.render().querySelector(".json-formatter-boolean").textContent, 128 | ).toEqual("true"); 129 | }); 130 | }); 131 | 132 | describe("openAtDepth after rendering", () => { 133 | const formatter = new JSONFormatter( 134 | { depth1: { depth2: { depth3: { depth4: 21 } } } }, 135 | Infinity, 136 | { 137 | animateOpen: false, 138 | animateClose: false, 139 | }, 140 | ); 141 | const element = formatter.render(); 142 | 143 | it("should open at depth 1", () => { 144 | formatter.openAtDepth(); 145 | expect(element.outerHTML).toContain("depth1"); 146 | expect(element.outerHTML).not.toContain("depth2"); 147 | expect(element.outerHTML).not.toContain("depth3"); 148 | expect(element.outerHTML).not.toContain("depth4"); 149 | }); 150 | 151 | it("should collapses all", () => { 152 | formatter.openAtDepth(0); 153 | expect(element.outerHTML).not.toContain("depth1"); 154 | }); 155 | 156 | it("should expand all", () => { 157 | formatter.openAtDepth(Infinity); 158 | expect(element.outerHTML).toContain("depth1"); 159 | expect(element.outerHTML).toContain("depth2"); 160 | expect(element.outerHTML).toContain("depth3"); 161 | expect(element.outerHTML).toContain("depth4"); 162 | expect(element.outerHTML).toContain("21"); 163 | }); 164 | }); 165 | 166 | describe("openAtDepth before any rendering", () => { 167 | const formatter = new JSONFormatter( 168 | { depth1: { depth2: { depth3: { depth4: 21 } } } }, 169 | Infinity, 170 | { 171 | animateOpen: false, 172 | animateClose: false, 173 | }, 174 | ); 175 | 176 | it("should open at depth 1", () => { 177 | formatter.openAtDepth(); 178 | const element = formatter.render(); 179 | expect(element.outerHTML).toContain("depth1"); 180 | expect(element.outerHTML).not.toContain("depth2"); 181 | expect(element.outerHTML).not.toContain("depth3"); 182 | expect(element.outerHTML).not.toContain("depth4"); 183 | }); 184 | }); 185 | 186 | describe("toggleOpen after rendering", () => { 187 | it("should toggle", () => { 188 | const formatter = new JSONFormatter( 189 | { depth1: { depth2: { depth3: { depth4: 21 } } } }, 190 | Infinity, 191 | { 192 | animateOpen: false, 193 | animateClose: false, 194 | }, 195 | ); 196 | const element = formatter.render(); 197 | 198 | expect(element.outerHTML).toContain("Object"); 199 | expect(element.outerHTML).toContain("depth1"); 200 | 201 | formatter.toggleOpen(); 202 | 203 | expect(element.outerHTML).toContain("Object"); 204 | expect(element.outerHTML).not.toContain("depth1"); 205 | expect(element.outerHTML).not.toContain("depth2"); 206 | expect(element.outerHTML).not.toContain("depth3"); 207 | expect(element.outerHTML).not.toContain("depth4"); 208 | }); 209 | }); 210 | 211 | describe("toggleOpen before any rendering", () => { 212 | it("should toggle", () => { 213 | const formatter = new JSONFormatter( 214 | { depth1: { depth2: { depth3: { depth4: 21 } } } }, 215 | Infinity, 216 | { 217 | animateOpen: false, 218 | animateClose: false, 219 | }, 220 | ); 221 | formatter.toggleOpen(); 222 | const element = formatter.render(); 223 | expect(element.outerHTML).toContain("Object"); 224 | expect(element.outerHTML).not.toContain("depth1"); 225 | expect(element.outerHTML).not.toContain("depth2"); 226 | expect(element.outerHTML).not.toContain("depth3"); 227 | expect(element.outerHTML).not.toContain("depth4"); 228 | }); 229 | }); 230 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "es2015", 5 | "allowSyntheticDefaultImports": false, 6 | "moduleResolution": "node", 7 | "sourceMap": true, 8 | "lib": ["dom", "es2015"], 9 | "types": ["jest"], 10 | "declaration": true 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var path = require("path"); 4 | 5 | module.exports = { 6 | devtool: "sourcemap", 7 | entry: { 8 | app: ["./src/index.ts"], 9 | }, 10 | output: { 11 | path: path.join(__dirname, "dist"), 12 | publicPath: "dist", 13 | filename: "json-formatter.js", 14 | library: "JSONFormatter", 15 | libraryTarget: "commonjs2", 16 | umdNamedDefine: true, 17 | }, 18 | resolve: { 19 | extensions: [".ts", ".less"], 20 | }, 21 | module: { 22 | rules: [ 23 | { 24 | test: /\.less$/, 25 | use: ["style-loader", "css-loader", "less-loader"], 26 | }, 27 | { 28 | test: /\.ts$/, 29 | loader: "ts-loader", 30 | }, 31 | ], 32 | }, 33 | optimization: { 34 | minimize: true, 35 | }, 36 | }; 37 | --------------------------------------------------------------------------------