Introduction to the

Leonardo Losoviz

What is an API?

It is a mechanism through which the client can interact with the server

Client

Server

Request

Response

APIs in WordPress

1. REST, via the
WP REST API

2. GraphQL, via WPGraphQL

Included in WP core

Plugin: wpgraphql.com

WP REST API

  • Fixed multiple endpoints
  • Retrieved data corresponds to resource(s)
  • Operates via GET, POST, PUT, DELETE
GET /wp-json/wp/v2/posts
[
  {
    "id": 1,
    "date": "2019-08-02T07:53:57",
    "date_gmt": "2019-08-02T07:53:57",
    "guid": {
      "rendered": "http:\\/\\/newapi.getpop.org\\/?p=1"
    },
    "modified": "2019-10-25T05:54:09",
    "modified_gmt": "2019-10-25T05:54:09",
    "slug": "hello-world",
    "status": "publish",
    "type": "post",
    "link": "https:\\/\\/newapi.getpop.org\\/uncategorized\\/hello-world\\/",
    "title": {
      "rendered": "Hello world!"
    },
    "content": {
      "rendered": "\n<p>Welcome to WordPress. This is your first post. Edit or delete it, then start writing!<\\/p>\n\n\n\n<p>I&#8217;m demonstrating a Youtube video:<\\/p>\n\n\n\n<figure class=\"wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"Introduction to the Component-based API by Leonardo Losoviz | JSConf.Asia 2019\" width=\"580\" height=\"326\" src=\"https:\\/\\/www.youtube.com\\/embed\\/9pT-q0SSYow?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\\/iframe>\n<\\/div><figcaption>This is my presentation in JSConf Asia 2019<\\/figcaption><\\/figure>\n",
      "protected": false
    },
    "excerpt": {
      "rendered": "<p>Welcome to WordPress. This is your first post. Edit or delete it, then start writing! I&#8217;m demonstrating a Youtube video:<\\/p>\n",
      "protected": false
    },
    "author": 1,
    "featured_media": 0,
    "comment_status": "closed",
    "ping_status": "open",
    "sticky": false,
    "template": "",
    "format": "standard",
    "meta": [],
    "categories": [
      1
    ],
    "tags": [],
    "_links": {
      "self": [
        {
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/posts\\/1"
        }
      ],
      "collection": [
        {
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/posts"
        }
      ],
      "about": [
        {
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/types\\/post"
        }
      ],
      "author": [
        {
          "embeddable": true,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/users\\/1"
        }
      ],
      "replies": [
        {
          "embeddable": true,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/comments?post=1"
        }
      ],
      "version-history": [
        {
          "count": 1,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/posts\\/1\\/revisions"
        }
      ],
      "predecessor-version": [
        {
          "id": 1498,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/posts\\/1\\/revisions\\/1498"
        }
      ],
      "wp:attachment": [
        {
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/media?parent=1"
        }
      ],
      "wp:term": [
        {
          "taxonomy": "category",
          "embeddable": true,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/categories?post=1"
        },
        {
          "taxonomy": "post_tag",
          "embeddable": true,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/tags?post=1"
        }
      ],
      "curies": [
        {
          "name": "wp",
          "href": "https:\\/\\/api.w.org\\/{rel}",
          "templated": true
        }
      ]
    }
  },
  {
    "id": 1178,
    "date": "2013-01-11T20:22:19",
    "date_gmt": "2013-01-12T03:22:19",
    "guid": {
      "rendered": "http:\\/\\/wptest.io\\/demo\\/?p=919"
    },
    "modified": "2019-10-25T05:54:09",
    "modified_gmt": "2019-10-25T05:54:09",
    "slug": "markup-html-tags-and-formatting",
    "status": "publish",
    "type": "post",
    "link": "https:\\/\\/newapi.getpop.org\\/markup\\/markup-html-tags-and-formatting\\/",
    "title": {
      "rendered": "Markup: HTML Tags and Formatting"
    },
    "content": {
      "rendered": "\n<h2>Headings<\\/h2>\n\n\n\n<h1>Header one<\\/h1>\n\n\n\n<h2>Header two<\\/h2>\n\n\n\n<h3>Header three<\\/h3>\n\n\n\n<h4>Header four<\\/h4>\n\n\n\n<h5>Header five<\\/h5>\n\n\n\n<h6>Header six<\\/h6>\n\n\n\n<h2>Blockquotes<\\/h2>\n\n\n\n<p>Single line blockquote:<\\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>Stay hungry. Stay foolish.<\\/p><\\/blockquote>\n\n\n\n<p>Multi line blockquote with a cite reference:<\\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>People think focus means saying yes to the thing you&#8217;ve got to focus on. But that&#8217;s not what it means at all. It means saying no to the hundred other good ideas that there are. You have to pick carefully. I&#8217;m actually as proud of the things we haven&#8217;t done as the things I have done. Innovation is saying no to 1,000 things.<\\/p><\\/blockquote>\n\n\n\n<p>Steve Jobs &#8211; Apple Worldwide Developers&#8217; Conference, 1997<\\/p>\n\n\n\n<h2>Tables<\\/h2>\n\n\n\n<table class=\"wp-block-table\"><thead><tr><th>Employee<\\/th><th>Salary<\\/th><th><\\/th><\\/tr><\\/thead><tbody><tr><th><a href=\"http:\\/\\/example.org\\/\">John Doe<\\/a><\\/th><td>$1<\\/td><td>Because that&#8217;s all Steve Jobs needed for a salary.<\\/td><\\/tr><tr><th><a href=\"http:\\/\\/example.org\\/\">Jane Doe<\\/a><\\/th><td>$100K<\\/td><td>For all the blogging she does.<\\/td><\\/tr><tr><th><a href=\"http:\\/\\/example.org\\/\">Fred Bloggs<\\/a><\\/th><td>$100M<\\/td><td>Pictures are worth a thousand words, right? So Jane x 1,000.<\\/td><\\/tr><tr><th><a href=\"http:\\/\\/example.org\\/\">Jane Bloggs<\\/a><\\/th><td>$100B<\\/td><td>With hair like that?! Enough said&#8230;<\\/td><\\/tr><\\/tbody><\\/table>\n\n\n\n<h2>Definition Lists<\\/h2>\n\n\n\n<p>\n\n     Definition List Title\n     Definition list division.\n     Startup\n     A startup company or startup is a company or temporary organization designed to search for a repeatable and scalable business model.\n     #dowork\n     Coined by Rob Dyrdek and his personal body guard Christopher &#8220;Big Black&#8221; Boykins, &#8220;Do Work&#8221; works as a self motivator, to motivating your friends.\n     Do It Live\n     I&#8217;ll let Bill O&#8217;Reilly will <a href=\"https:\\/\\/www.youtube.com\\/watch?v=O_HyZ5aW76c\">explain<\\/a> this one.\n\n<\\/p>\n\n\n\n<h2>Unordered Lists (Nested)<\\/h2>\n\n\n\n<ul><li>List item one\n<ul><li>List item one\n<ul><li>List item one<\\/li><li>List item two<\\/li><li>List item three<\\/li><li>List item four<\\/li><\\/ul>\n<\\/li><li>List item two<\\/li><li>List item three<\\/li><li>List item four<\\/li><\\/ul>\n<\\/li><li>List item two<\\/li><li>List item three<\\/li><li>List item four<\\/li><\\/ul>\n\n\n\n<h2>Ordered List (Nested)<\\/h2>\n\n\n\n<ol><li>List item one\n<ol><li>List item one\n<ol><li>List item one<\\/li><li>List item two<\\/li><li>List item three<\\/li><li>List item four<\\/li><\\/ol>\n<\\/li><li>List item two<\\/li><li>List item three<\\/li><li>List item four<\\/li><\\/ol>\n<\\/li><li>List item two<\\/li><li>List item three<\\/li><li>List item four<\\/li><\\/ol>\n\n\n\n<h2>HTML Tags<\\/h2>\n\n\n\n<p>These supported tags come from the WordPress.com code <a href=\"http:\\/\\/en.support.wordpress.com\\/code\\/\">FAQ<\\/a>.<\\/p>\n\n\n\n<p><strong>Address Tag<\\/strong>\n1 Infinite Loop\nCupertino, CA 95014\nUnited States\n<\\/p>\n\n\n\n<p><strong>Anchor Tag (aka. Link)<\\/strong><\\/p>\n\n\n\n<p>This is an example of a <a href=\"http:\\/\\/apple.com\">link<\\/a>.<\\/p>\n\n\n\n<p><strong>Abbreviation Tag<\\/strong><\\/p>\n\n\n\n<p>The abbreviation <abbr title=\"Seriously\">srsly<\\/abbr> stands for &#8220;seriously&#8221;.<\\/p>\n\n\n\n<p><strong>Acronym Tag (<em>deprecated in HTML5<\\/em>)<\\/strong><\\/p>\n\n\n\n<p>The acronym ftw stands for &#8220;for the win&#8221;.<\\/p>\n\n\n\n<p><strong>Big Tag (<em>deprecated in HTML5<\\/em>)<\\/strong><\\/p>\n\n\n\n<p>These tests are a big deal, but this tag is no longer supported in HTML5.<\\/p>\n\n\n\n<p><strong>Cite Tag<\\/strong><\\/p>\n\n\n\n<p>&#8220;Code is poetry.&#8221; &#8211;Automattic<\\/p>\n\n\n\n<p><strong>Code Tag<\\/strong><\\/p>\n\n\n\n<p>You will learn later on in these tests that <code>word-wrap: break-word;<\\/code> will be your best friend.<\\/p>\n\n\n\n<p><strong>Delete Tag<\\/strong><\\/p>\n\n\n\n<p>This tag will let you <del>strikeout text<\\/del>, but this tag is no longer supported in HTML5 (use the <code>&amp;lt;strike&amp;gt;<\\/code> instead).<\\/p>\n\n\n\n<p><strong>Emphasize Tag<\\/strong><\\/p>\n\n\n\n<p>The emphasize tag should <em>italicize<\\/em> text.<\\/p>\n\n\n\n<p><strong>Insert Tag<\\/strong><\\/p>\n\n\n\n<p>This tag should denote <ins>inserted<\\/ins> text.<\\/p>\n\n\n\n<p><strong>Keyboard Tag<\\/strong><\\/p>\n\n\n\n<p>This scarcely known tag emulates keyboard text, which is usually styled like the <code>&amp;lt;code&amp;gt;<\\/code> tag.<\\/p>\n\n\n\n<p><strong>Preformatted Tag<\\/strong><\\/p>\n\n\n\n<p>This tag styles large blocks of code.<\\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">.post-title {\n    margin: 0 0 5px;\n    font-weight: bold;\n    font-size: 38px;\n    line-height: 1.2;\n    and here's a line of some really, really, really, really long text, just to see how the PRE tag handles it and to find out how it overflows;\n}<\\/pre>\n\n\n\n<p><strong>Quote Tag<\\/strong><\\/p>\n\n\n\n<p>Developers, developers, developers\\u2026 &#8211;Steve Ballmer<\\/p>\n\n\n\n<p><strong>Strike Tag (<em>deprecated in HTML5<\\/em>)<\\/strong><\\/p>\n\n\n\n<p>This tag shows <s>strike-through text<\\/s><\\/p>\n\n\n\n<p><strong>Strong Tag<\\/strong><\\/p>\n\n\n\n<p>This tag shows <strong>bold text.<\\/strong><\\/p>\n\n\n\n<p><strong>Subscript Tag<\\/strong><\\/p>\n\n\n\n<p>Getting our science styling on with H<sub>2<\\/sub>O, which should push the &#8220;2&#8221; down.<\\/p>\n\n\n\n<p><strong>Superscript Tag<\\/strong><\\/p>\n\n\n\n<p>Still sticking with science and Isaac Newton&#8217;s E = MC<sup>2<\\/sup>, which should lift the 2 up.<\\/p>\n\n\n\n<p><strong>Teletype Tag (<em>deprecated in HTML5<\\/em>)<\\/strong><\\/p>\n\n\n\n<p>This rarely used tag emulates teletype text, which is usually styled like the <code>&amp;lt;code&amp;gt;<\\/code> tag.<\\/p>\n\n\n\n<p><strong>Variable Tag<\\/strong><\\/p>\n\n\n\n<p>This allows you to denote variables.<\\/p>\n",
      "protected": false
    },
    "excerpt": {
      "rendered": "<p>Headings Header one Header two Header three Header four Header five Header six Blockquotes Single line blockquote: Stay hungry. Stay foolish. Multi line blockquote with a cite reference: People think focus means saying yes to the thing you&#8217;ve got to focus on. But that&#8217;s not what it means at all. It means saying no to [&hellip;]<\\/p>\n",
      "protected": false
    },
    "author": 2,
    "featured_media": 0,
    "comment_status": "closed",
    "ping_status": "open",
    "sticky": false,
    "template": "",
    "format": "standard",
    "meta": [],
    "categories": [
      29
    ],
    "tags": [
      79,
      81,
      96,
      105,
      116
    ],
    "_links": {
      "self": [
        {
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/posts\\/1178"
        }
      ],
      "collection": [
        {
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/posts"
        }
      ],
      "about": [
        {
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/types\\/post"
        }
      ],
      "author": [
        {
          "embeddable": true,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/users\\/2"
        }
      ],
      "replies": [
        {
          "embeddable": true,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/comments?post=1178"
        }
      ],
      "version-history": [
        {
          "count": 1,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/posts\\/1178\\/revisions"
        }
      ],
      "predecessor-version": [
        {
          "id": 1461,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/posts\\/1178\\/revisions\\/1461"
        }
      ],
      "wp:attachment": [
        {
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/media?parent=1178"
        }
      ],
      "wp:term": [
        {
          "taxonomy": "category",
          "embeddable": true,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/categories?post=1178"
        },
        {
          "taxonomy": "post_tag",
          "embeddable": true,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/tags?post=1178"
        }
      ],
      "curies": [
        {
          "name": "wp",
          "href": "https:\\/\\/api.w.org\\/{rel}",
          "templated": true
        }
      ]
    }
  },
  {
    "id": 1177,
    "date": "2013-01-10T20:15:40",
    "date_gmt": "2013-01-11T03:15:40",
    "guid": {
      "rendered": "http:\\/\\/wptest.io\\/demo\\/?p=903"
    },
    "modified": "2019-10-25T05:54:09",
    "modified_gmt": "2019-10-25T05:54:09",
    "slug": "markup-image-alignment",
    "status": "publish",
    "type": "post",
    "link": "https:\\/\\/newapi.getpop.org\\/markup\\/markup-image-alignment\\/",
    "title": {
      "rendered": "Markup: Image Alignment"
    },
    "content": {
      "rendered": "\n<p>Welcome to image alignment! The best way to demonstrate the ebb and flow of the various image positioning options is to nestle them snuggly among an ocean of words. Grab a paddle and let&#8217;s get started.<\\/p>\n\n\n\n<p>On the topic of alignment, it should be noted that users can choose from the options of <em>None<\\/em>, <em>Left<\\/em>, <em>Right, <\\/em>and <em>Center<\\/em>. In addition, they also get the options of <em>Thumbnail<\\/em>, <em>Medium<\\/em>, <em>Large<\\/em> &amp; <em>Fullsize<\\/em>.<\\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img src=\"http:\\/\\/wpthemetestdata.files.wordpress.com\\/2013\\/03\\/image-alignment-580x300.jpg\" alt=\"Image Alignment 580x300\" class=\"wp-image-906\"\\/><\\/figure><\\/div>\n\n\n\n<p>The image above happens to be <em><strong>centered<\\/strong><\\/em>.<\\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignleft\"><img src=\"http:\\/\\/wpthemetestdata.files.wordpress.com\\/2013\\/03\\/image-alignment-150x150.jpg\" alt=\"Image Alignment 150x150\" class=\"wp-image-904\"\\/><\\/figure><\\/div>\n\n\n\n<p>The rest of this paragraph is filler for the sake of seeing the text wrap around the 150&#215;150 image, which is <em><strong>left aligned<\\/strong><\\/em>. <\\/p>\n\n\n\n<p>As you can see the should be some space above, below, and to the right of the image. The text should not be creeping on the image. Creeping is just not right. Images need breathing room too. Let them speak like you words. Let them do their jobs without any hassle from the text. In about one more sentence here, we&#8217;ll see that the text moves from the right of the image down below the image in seamless transition. Again, letting the do it&#8217;s thang. Mission accomplished!<\\/p>\n\n\n\n<p>And now for a <em><strong>massively large image<\\/strong><\\/em>. It also has <em><strong>no alignment<\\/strong><\\/em>.<\\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"http:\\/\\/wpthemetestdata.files.wordpress.com\\/2013\\/03\\/image-alignment-1200x4002.jpg\" alt=\"Image Alignment 1200x400\" class=\"wp-image-907\"\\/><\\/figure>\n\n\n\n<p>The image above, though 1200px wide, should not overflow the content area. It should remain contained with no visible disruption to the flow of content.<\\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignright\"><img src=\"http:\\/\\/wpthemetestdata.files.wordpress.com\\/2013\\/03\\/image-alignment-300x200.jpg\" alt=\"Image Alignment 300x200\" class=\"wp-image-905\"\\/><\\/figure><\\/div>\n\n\n\n<p>And now we&#8217;re going to shift things to the <em><strong>right align<\\/strong><\\/em>. Again, there should be plenty of room above, below, and to the left of the image. Just look at him there\\u2026 Hey guy! Way to rock that right side. I don&#8217;t care what the left aligned image says, you look great. Don&#8217;t let anyone else tell you differently.<\\/p>\n\n\n\n<p>In just a bit here, you should see the text start to wrap below the right aligned image and settle in nicely. There should still be plenty of room and everything should be sitting pretty. Yeah\\u2026 Just like that. It never felt so good to be right.<\\/p>\n\n\n\n<p>And just when you thought we were done, we&#8217;re going to do them all over again with captions!<\\/p>\n\n\n\n<div class=\"wp-block-image size-full wp-image-906\"><figure class=\"aligncenter\"><img src=\"http:\\/\\/wpthemetestdata.files.wordpress.com\\/2013\\/03\\/image-alignment-580x300.jpg\" alt=\"Image Alignment 580x300\" class=\"wp-image-906\"\\/><figcaption>Look at 580&#215;300 getting some <a title=\"Image Settings\" href=\"http:\\/\\/en.support.wordpress.com\\/images\\/image-settings\\/\">caption<\\/a> love.<\\/figcaption><\\/figure><\\/div>\n\n\n\n<p>The image above happens to be <em><strong>centered<\\/strong><\\/em>. The caption also has a link in it, just to see if it does anything funky.<\\/p>\n\n\n\n<div class=\"wp-block-image size-full wp-image-904\"><figure class=\"alignleft\"><img src=\"http:\\/\\/wpthemetestdata.files.wordpress.com\\/2013\\/03\\/image-alignment-150x150.jpg\" alt=\"Image Alignment 150x150\" class=\"wp-image-904\"\\/><figcaption>Itty-bitty caption.<\\/figcaption><\\/figure><\\/div>\n\n\n\n<p>The rest of this paragraph is filler for the sake of seeing the text wrap around the 150&#215;150 image, which is <em><strong>left aligned<\\/strong><\\/em>. <\\/p>\n\n\n\n<p>As you can see the should be some space above, below, and to the right of the image. The text should not be creeping on the image. Creeping is just not right. Images need breathing room too. Let them speak like you words. Let them do their jobs without any hassle from the text. In about one more sentence here, we&#8217;ll see that the text moves from the right of the image down below the image in seamless transition. Again, letting the do it&#8217;s thang. Mission accomplished!<\\/p>\n\n\n\n<p>And now for a <em><strong>massively large image<\\/strong><\\/em>. It also has <em><strong>no alignment<\\/strong><\\/em>.<\\/p>\n\n\n\n<figure class=\"wp-block-image alignnone wp-image-907\"><img src=\"http:\\/\\/wpthemetestdata.files.wordpress.com\\/2013\\/03\\/image-alignment-1200x4002.jpg\" alt=\"Image Alignment 1200x400\" class=\"wp-image-907\"\\/><figcaption>Massive image comment for your eyeballs.<\\/figcaption><\\/figure>\n\n\n\n<p>The image above, though 1200px wide, should not overflow the content area. It should remain contained with no visible disruption to the flow of content.<\\/p>\n\n\n\n<div class=\"wp-block-image size-full wp-image-905\"><figure class=\"alignright\"><img src=\"http:\\/\\/wpthemetestdata.files.wordpress.com\\/2013\\/03\\/image-alignment-300x200.jpg\" alt=\"Image Alignment 300x200\" class=\"wp-image-905\"\\/><figcaption>Feels good to be right all the time.<\\/figcaption><\\/figure><\\/div>\n\n\n\n<p>And now we&#8217;re going to shift things to the <em><strong>right align<\\/strong><\\/em>. Again, there should be plenty of room above, below, and to the left of the image. Just look at him there\\u2026 Hey guy! Way to rock that right side. I don&#8217;t care what the left aligned image says, you look great. Don&#8217;t let anyone else tell you differently.<\\/p>\n\n\n\n<p>In just a bit here, you should see the text start to wrap below the right aligned image and settle in nicely. There should still be plenty of room and everything should be sitting pretty. Yeah\\u2026 Just like that. It never felt so good to be right.<\\/p>\n\n\n\n<p>And that&#8217;s a wrap, yo! You survived the tumultuous waters of alignment. Image alignment achievement unlocked!<\\/p>\n",
      "protected": false
    },
    "excerpt": {
      "rendered": "<p>Welcome to image alignment! The best way to demonstrate the ebb and flow of the various image positioning options is to nestle them snuggly among an ocean of words. Grab a paddle and let&#8217;s get started. On the topic of alignment, it should be noted that users can choose from the options of None, Left, Right, and Center. In [&hellip;]<\\/p>\n",
      "protected": false
    },
    "author": 2,
    "featured_media": 1505,
    "comment_status": "closed",
    "ping_status": "open",
    "sticky": false,
    "template": "",
    "format": "standard",
    "meta": [],
    "categories": [
      29
    ],
    "tags": [
      67,
      71,
      79,
      81,
      106,
      116
    ],
    "_links": {
      "self": [
        {
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/posts\\/1177"
        }
      ],
      "collection": [
        {
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/posts"
        }
      ],
      "about": [
        {
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/types\\/post"
        }
      ],
      "author": [
        {
          "embeddable": true,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/users\\/2"
        }
      ],
      "replies": [
        {
          "embeddable": true,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/comments?post=1177"
        }
      ],
      "version-history": [
        {
          "count": 2,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/posts\\/1177\\/revisions"
        }
      ],
      "predecessor-version": [
        {
          "id": 1519,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/posts\\/1177\\/revisions\\/1519"
        }
      ],
      "wp:featuredmedia": [
        {
          "embeddable": true,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/media\\/1505"
        }
      ],
      "wp:attachment": [
        {
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/media?parent=1177"
        }
      ],
      "wp:term": [
        {
          "taxonomy": "category",
          "embeddable": true,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/categories?post=1177"
        },
        {
          "taxonomy": "post_tag",
          "embeddable": true,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/tags?post=1177"
        }
      ],
      "curies": [
        {
          "name": "wp",
          "href": "https:\\/\\/api.w.org\\/{rel}",
          "templated": true
        }
      ]
    }
  },
  {
    "id": 1176,
    "date": "2013-01-09T09:00:39",
    "date_gmt": "2013-01-09T16:00:39",
    "guid": {
      "rendered": "http:\\/\\/wptest.io\\/demo\\/?p=895"
    },
    "modified": "2019-10-25T05:54:09",
    "modified_gmt": "2019-10-25T05:54:09",
    "slug": "markup-text-alignment",
    "status": "publish",
    "type": "post",
    "link": "https:\\/\\/newapi.getpop.org\\/markup\\/markup-text-alignment\\/",
    "title": {
      "rendered": "Markup: Text Alignment"
    },
    "content": {
      "rendered": "\n<h3>Default<\\/h3>\n\n\n\n<p>This is a paragraph. It should not have any alignment of any kind. It should just flow like you would normally expect. Nothing fancy. Just straight up text, free flowing, with love. Completely neutral and not picking a side or sitting on the fence. It just is. It just freaking is. It likes where it is. It does not feel compelled to pick a side. Leave him be. It will just be better that way. Trust me.<\\/p>\n\n\n\n<h3>Left Align<\\/h3>\n\n\n\n<p>This is a paragraph. It is left aligned. Because of this, it is a bit more liberal in it&#8217;s views. It&#8217;s favorite color is green. Left align tends to be more eco-friendly, but it provides no concrete evidence that it really is. Even though it likes share the wealth evenly, it leaves the equal distribution up to justified alignment.<\\/p>\n\n\n\n<h3>Center Align<\\/h3>\n\n\n\n<p>This is a paragraph. It is center aligned. Center is, but nature, a fence sitter. A flip flopper. It has a difficult time making up its mind. It wants to pick a side. Really, it does. It has the best intentions, but it tends to complicate matters more than help. The best you can do is try to win it over and hope for the best. I hear center align does take bribes.<\\/p>\n\n\n\n<h3>Right Align<\\/h3>\n\n\n\n<p>This is a paragraph. It is right aligned. It is a bit more conservative in it&#8217;s views. It&#8217;s prefers to not be told what to do or how to do it. Right align totally owns a slew of guns and loves to head to the range for some practice. Which is cool and all. I mean, it&#8217;s a pretty good shot from at least four or five football fields away. Dead on. So boss.<\\/p>\n\n\n\n<h3>Justify Align<\\/h3>\n\n\n\n<p>This is a paragraph. It is justify aligned. It gets really mad when people associate it with Justin Timberlake. Typically, justified is pretty straight laced. It likes everything to be in it&#8217;s place and not all cattywampus like the rest of the aligns. I am not saying that makes it better than the rest of the aligns, but it does tend to put off more of an elitist attitude.<\\/p>\n",
      "protected": false
    },
    "excerpt": {
      "rendered": "<p>Default This is a paragraph. It should not have any alignment of any kind. It should just flow like you would normally expect. Nothing fancy. Just straight up text, free flowing, with love. Completely neutral and not picking a side or sitting on the fence. It just is. It just freaking is. It likes where [&hellip;]<\\/p>\n",
      "protected": false
    },
    "author": 2,
    "featured_media": 0,
    "comment_status": "closed",
    "ping_status": "open",
    "sticky": false,
    "template": "",
    "format": "standard",
    "meta": [],
    "categories": [
      29
    ],
    "tags": [
      67,
      79,
      81,
      116
    ],
    "_links": {
      "self": [
        {
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/posts\\/1176"
        }
      ],
      "collection": [
        {
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/posts"
        }
      ],
      "about": [
        {
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/types\\/post"
        }
      ],
      "author": [
        {
          "embeddable": true,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/users\\/2"
        }
      ],
      "replies": [
        {
          "embeddable": true,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/comments?post=1176"
        }
      ],
      "version-history": [
        {
          "count": 1,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/posts\\/1176\\/revisions"
        }
      ],
      "predecessor-version": [
        {
          "id": 1463,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/posts\\/1176\\/revisions\\/1463"
        }
      ],
      "wp:attachment": [
        {
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/media?parent=1176"
        }
      ],
      "wp:term": [
        {
          "taxonomy": "category",
          "embeddable": true,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/categories?post=1176"
        },
        {
          "taxonomy": "post_tag",
          "embeddable": true,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/tags?post=1176"
        }
      ],
      "curies": [
        {
          "name": "wp",
          "href": "https:\\/\\/api.w.org\\/{rel}",
          "templated": true
        }
      ]
    }
  },
  {
    "id": 1174,
    "date": "2013-01-05T11:00:20",
    "date_gmt": "2013-01-05T18:00:20",
    "guid": {
      "rendered": "http:\\/\\/wptest.io\\/demo\\/?p=867"
    },
    "modified": "2019-10-25T05:54:09",
    "modified_gmt": "2019-10-25T05:54:09",
    "slug": "title-with-special-characters",
    "status": "publish",
    "type": "post",
    "link": "https:\\/\\/newapi.getpop.org\\/markup\\/title-with-special-characters\\/",
    "title": {
      "rendered": "Markup: Title With Special Characters"
    },
    "content": {
      "rendered": "\n<p>Putting special characters in the title should have no adverse effect on the layout or functionality.<\\/p>\n\n\n\n<p>Special characters in the post title have been known to cause issues with JavaScript when it is minified, especially in the admin when editing the post itself (ie. issues with metaboxes, media upload, etc.).<\\/p>\n\n\n\n<h2>Latin Character Tests<\\/h2>\n\n\n\n<p>This is a test to see if the fonts used in this theme support basic Latin characters.<\\/p>\n\n\n\n<table class=\"wp-block-table\"><tbody><tr><td>!<\\/td><td>&#8220;<\\/td><td>#<\\/td><td>$<\\/td><td>%<\\/td><td>&amp;<\\/td><td>&#8216;<\\/td><td>(<\\/td><td>)<\\/td><td>*<\\/td><\\/tr><tr><td>+<\\/td><td>,<\\/td><td>&#8211;<\\/td><td>.<\\/td><td>\\/<\\/td><td>0<\\/td><td>1<\\/td><td>2<\\/td><td>3<\\/td><td>4<\\/td><\\/tr><tr><td>5<\\/td><td>6<\\/td><td>7<\\/td><td>8<\\/td><td>9<\\/td><td>:<\\/td><td>;<\\/td><td>&gt;<\\/td><td>=<\\/td><td>&lt;<\\/td><\\/tr><tr><td>?<\\/td><td>@<\\/td><td>A<\\/td><td>B<\\/td><td>C<\\/td><td>D<\\/td><td>E<\\/td><td>F<\\/td><td>G<\\/td><td>H<\\/td><\\/tr><tr><td>I<\\/td><td>J<\\/td><td>K<\\/td><td>L<\\/td><td>M<\\/td><td>N<\\/td><td>O<\\/td><td>P<\\/td><td>Q<\\/td><td>R<\\/td><\\/tr><tr><td>S<\\/td><td>T<\\/td><td>U<\\/td><td>V<\\/td><td>W<\\/td><td>X<\\/td><td>Y<\\/td><td>Z<\\/td><td>[<\\/td><td>\\<\\/td><\\/tr><tr><td>]<\\/td><td>^<\\/td><td>_<\\/td><td>`<\\/td><td>a<\\/td><td>b<\\/td><td>c<\\/td><td>d<\\/td><td>e<\\/td><td>f<\\/td><\\/tr><tr><td>g<\\/td><td>h<\\/td><td>i<\\/td><td>j<\\/td><td>k<\\/td><td>l<\\/td><td>m<\\/td><td>n<\\/td><td>o<\\/td><td>p<\\/td><\\/tr><tr><td>q<\\/td><td>r<\\/td><td>s<\\/td><td>t<\\/td><td>u<\\/td><td>v<\\/td><td>w<\\/td><td>x<\\/td><td>y<\\/td><td>z<\\/td><\\/tr><tr><td>{<\\/td><td>|<\\/td><td>}<\\/td><td>~<\\/td><td><\\/td><td><\\/td><td><\\/td><td><\\/td><td><\\/td><td><\\/td><\\/tr><\\/tbody><\\/table>\n",
      "protected": false
    },
    "excerpt": {
      "rendered": "<p>Putting special characters in the title should have no adverse effect on the layout or functionality. Special characters in the post title have been known to cause issues with JavaScript when it is minified, especially in the admin when editing the post itself (ie. issues with metaboxes, media upload, etc.). Latin Character Tests This is [&hellip;]<\\/p>\n",
      "protected": false
    },
    "author": 2,
    "featured_media": 0,
    "comment_status": "closed",
    "ping_status": "open",
    "sticky": false,
    "template": "",
    "format": "standard",
    "meta": [],
    "categories": [
      29
    ],
    "tags": [
      105,
      116,
      133,
      165
    ],
    "_links": {
      "self": [
        {
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/posts\\/1174"
        }
      ],
      "collection": [
        {
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/posts"
        }
      ],
      "about": [
        {
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/types\\/post"
        }
      ],
      "author": [
        {
          "embeddable": true,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/users\\/2"
        }
      ],
      "replies": [
        {
          "embeddable": true,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/comments?post=1174"
        }
      ],
      "version-history": [
        {
          "count": 1,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/posts\\/1174\\/revisions"
        }
      ],
      "predecessor-version": [
        {
          "id": 1464,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/posts\\/1174\\/revisions\\/1464"
        }
      ],
      "wp:attachment": [
        {
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/media?parent=1174"
        }
      ],
      "wp:term": [
        {
          "taxonomy": "category",
          "embeddable": true,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/categories?post=1174"
        },
        {
          "taxonomy": "post_tag",
          "embeddable": true,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/tags?post=1174"
        }
      ],
      "curies": [
        {
          "name": "wp",
          "href": "https:\\/\\/api.w.org\\/{rel}",
          "templated": true
        }
      ]
    }
  },
  {
    "id": 1173,
    "date": "2013-01-05T10:00:49",
    "date_gmt": "2013-01-05T17:00:49",
    "guid": {
      "rendered": "http:\\/\\/wptest.io\\/demo\\/?p=861"
    },
    "modified": "2019-10-25T05:54:10",
    "modified_gmt": "2019-10-25T05:54:10",
    "slug": "markup-title-with-markup",
    "status": "publish",
    "type": "post",
    "link": "https:\\/\\/newapi.getpop.org\\/markup\\/markup-title-with-markup\\/",
    "title": {
      "rendered": "Markup: Title With Markup"
    },
    "content": {
      "rendered": "\n<p>Verify that:<\\/p>\n\n\n\n<ul><li>The post title renders the word &#8220;with&#8221; in <em>italics<\\/em> and the word &#8220;markup&#8221; in <strong>bold<\\/strong>.<\\/li><li>The post title markup should be removed from the browser window \\/ tab.<\\/li><\\/ul>\n",
      "protected": false
    },
    "excerpt": {
      "rendered": "<p>Verify that: The post title renders the word &#8220;with&#8221; in italics and the word &#8220;markup&#8221; in bold. The post title markup should be removed from the browser window \\/ tab.<\\/p>\n",
      "protected": false
    },
    "author": 2,
    "featured_media": 0,
    "comment_status": "closed",
    "ping_status": "open",
    "sticky": false,
    "template": "",
    "format": "standard",
    "meta": [],
    "categories": [
      29
    ],
    "tags": [
      81,
      105,
      165
    ],
    "_links": {
      "self": [
        {
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/posts\\/1173"
        }
      ],
      "collection": [
        {
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/posts"
        }
      ],
      "about": [
        {
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/types\\/post"
        }
      ],
      "author": [
        {
          "embeddable": true,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/users\\/2"
        }
      ],
      "replies": [
        {
          "embeddable": true,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/comments?post=1173"
        }
      ],
      "version-history": [
        {
          "count": 1,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/posts\\/1173\\/revisions"
        }
      ],
      "predecessor-version": [
        {
          "id": 1465,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/posts\\/1173\\/revisions\\/1465"
        }
      ],
      "wp:attachment": [
        {
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/media?parent=1173"
        }
      ],
      "wp:term": [
        {
          "taxonomy": "category",
          "embeddable": true,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/categories?post=1173"
        },
        {
          "taxonomy": "post_tag",
          "embeddable": true,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/tags?post=1173"
        }
      ],
      "curies": [
        {
          "name": "wp",
          "href": "https:\\/\\/api.w.org\\/{rel}",
          "templated": true
        }
      ]
    }
  },
  {
    "id": 1016,
    "date": "2012-03-15T15:36:32",
    "date_gmt": "2012-03-15T22:36:32",
    "guid": {
      "rendered": "http:\\/\\/wptest.io\\/demo\\/?p=1016"
    },
    "modified": "2019-10-25T05:54:10",
    "modified_gmt": "2019-10-25T05:54:10",
    "slug": "template-featured-image-vertical",
    "status": "publish",
    "type": "post",
    "link": "https:\\/\\/newapi.getpop.org\\/uncategorized\\/template-featured-image-vertical\\/",
    "title": {
      "rendered": "Template: Featured Image (Vertical)"
    },
    "content": {
      "rendered": "\n<p>This post should display a <a href=\"http:\\/\\/en.support.wordpress.com\\/featured-images\\/#setting-a-featured-image\" target=\"_blank\" rel=\"noreferrer noopener\">featured image<\\/a>, if the theme <a href=\"http:\\/\\/codex.wordpress.org\\/Post_Thumbnails\" target=\"_blank\" rel=\"noreferrer noopener\">supports it<\\/a>.<\\/p>\n\n\n\n<p>Non-square images can provide some unique styling issues.<\\/p>\n\n\n\n<p>This post tests a vertical featured image.<\\/p>\n",
      "protected": false
    },
    "excerpt": {
      "rendered": "<p>This post should display a featured image, if the theme supports it. Non-square images can provide some unique styling issues. This post tests a vertical featured image.<\\/p>\n",
      "protected": false
    },
    "author": 2,
    "featured_media": 1504,
    "comment_status": "closed",
    "ping_status": "open",
    "sticky": false,
    "template": "",
    "format": "standard",
    "meta": [],
    "categories": [
      49,
      1
    ],
    "tags": [
      77,
      86,
      93,
      106,
      160
    ],
    "_links": {
      "self": [
        {
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/posts\\/1016"
        }
      ],
      "collection": [
        {
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/posts"
        }
      ],
      "about": [
        {
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/types\\/post"
        }
      ],
      "author": [
        {
          "embeddable": true,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/users\\/2"
        }
      ],
      "replies": [
        {
          "embeddable": true,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/comments?post=1016"
        }
      ],
      "version-history": [
        {
          "count": 1,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/posts\\/1016\\/revisions"
        }
      ],
      "predecessor-version": [
        {
          "id": 1466,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/posts\\/1016\\/revisions\\/1466"
        }
      ],
      "wp:featuredmedia": [
        {
          "embeddable": true,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/media\\/1504"
        }
      ],
      "wp:attachment": [
        {
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/media?parent=1016"
        }
      ],
      "wp:term": [
        {
          "taxonomy": "category",
          "embeddable": true,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/categories?post=1016"
        },
        {
          "taxonomy": "post_tag",
          "embeddable": true,
          "href": "https:\\/\\/newapi.getpop.org\\/wp-json\\/wp\\/v2\\/tags?post=1016"
        }
      ],
      "curies": [
        {
          "name": "wp",
          "href": "https:\\/\\/api.w.org\\/{rel}",
          "templated": true
        }
      ]
    }
  }
]

WPGraphQL

  • Single endpoint
  • Retrieved data matches query
  • Operates via POST
{
  posts {
    id
    title
    url
  }
}
{
  "data": {
    "posts": [
      {
        "id": 1499,
        "title": "COPE with WordPress: Post demo containing plenty of blocks",
        "url": "https://newapi.getpop.org/posts/cope-with-wordpress-post-demo-containing-plenty-of-blocks/"
      },
      {
        "id": 1459,
        "title": "A lovely tango, not with leo",
        "url": "https://newapi.getpop.org/posts/a-lovely-tango/"
      },
      {
        "id": 1,
        "title": "Hello world!",
        "url": "https://newapi.getpop.org/uncategorized/hello-world/"
      }
    ]
  }
}

How do they compare?

WP REST API WPGraphQL
Speed ⚠️
Security ⚠️
Caching
Access Control ⚠️ ⚠️
Simplicity ⚠️
Usable by 👨🏻‍💻 Developers 👨🏻‍💻 Developers

Can we build an API with the features of both REST and GraphQL?

🤔

Yes, we can!

😲

Introduction to the

Let's check out its features

🧞‍♂️

GraphiQL

Client to execute GraphQL queries. Available for wp-admin (private), and with own URL (public)

Interactive Schema

Client to visualize the schema, and explore how entities relate to each other

Custom Endpoints

Different configurations for different users (eg: client/team) or applications (eg: web/mobile)

Persisted Queries

REST + GraphQL: only predefined data is exposed, under own URL. It is cacheable!

Access Control Lists

Define who can access a field: logged-in users, users with some role or capability, custom rules

Public/Private Schema

When authorization fails: indicate why it failed (public), or deny existence of the field (private)

Cache Control Lists

Cache on server, CDN or browser via standard HTTP caching. The max-age is calculated for you

Field Deprecation Lists

Inform your users that your schema has been upgraded, in the response to the query

API Hierarchy

Create a hierarchy of endpoints, providing information in their URL

Enjoying it so far?

😁

There is much more!

Multiple query execution

Schema namespacing 

Nested mutations

Embeddable fields

Composable directives

Interaction with 3rd-party APIs

How do they compare?

WP REST API WPGraphQL GraphQL API
Speed ⚠️
Security ⚠️
Caching
Access Control ⚠️ ⚠️
Simplicity ⚠️
Usable by 👨🏻‍💻 Developers 👨🏻‍💻 Developers 👨‍👩‍👧‍👦 Anyone

Through the
 

 

 

we can...

Power Gutenberg Blocks

Interact with APIs and Cloud services

Make WordPress the OS of the Web

Try it out

👇

Give it a ⭐️ on GitHub ❤️

🙏

Share it with your friends/colleagues 👩🏻‍💻

Talk about it 💬

Help spread the news

Thanks!

👋

Leonardo Losoviz

One parting thought...