New Release: GraphQL for Block Data API

The Block Data API has been successfully serving millions of requests a day, and it is just getting better. We are excited to announce you can now retrieve Block Data via GraphQL.

What is the Block Data API?

The Block Data API is an API for retrieving block editor posts structured as pure JSON data, eliminating the need to parse HTML to get just the data you need. While primarily designed for use in headless architectures with WordPress, the Block Data API can be used anywhere a developer needs to represent block markup as structured data.

If you aren’t familiar with the Block Data API, you can read a full overview on what it does and how it works.

What is GraphQL?

GraphQL is an open-source data query and manipulation language. With GraphQL, developers can request the specific, typed data they need more efficiently than with a traditional REST API.

How do I activate the Block Data API with GraphQL?

Our documentation has instructions on activating the API. The plugin README has information on how to integrate with the WPGraphQL plugin to provide a GraphQL API

Where can I find more information/documentation?

The project Readme has comprehensive information on the Block Data API and its functions.

VIP Themes in the WordPress.com REST API

Today we’re announcing additional functionality for VIP themes in the WordPress.com REST API. Previously, the REST API didn’t load VIP themes which meant custom post types, custom taxonomies, and custom user roles were absent there. For the past couple weeks we’ve been testing VIP themes in the REST API and today that functionality is available for all VIP sites.

For the most part, this will work just as you would expect. REST API specific filters, like rest_api_allowed_post_types will now be in effect. If your theme was already using some of the REST API filters, you may want to check that they’re functioning as expected. It is now even more important to be careful of theme constants like STYLESHEETPATH and TEMPLATEPATH as they’re not available in the REST API context.

If you have any questions about using the WordPress.com REST API, let us know!

Breaking Changes: Twitter API v1 being retired

Twitter will be retiring v1 of their API in the coming weeks.

If your themes or plugins are using the old version of the API or the @Anywhere library, this functionality will stop working during Twitter’s blackout tests and once v1 of the API is completely turned off. Here are some details from official announcement over on the Twitter Developers blog:

If you’re a developer who has built applications with API v1, you should be moving those applications to API v1.1 now.

 

What will happen when API v1 has retired?

When API v1 is finally retired, all authenticated and unauthenticated requests to API v1 will return a HTTP 410 Gone status. Older widgets will receive the same response. This status code signifies that all API v1-era resources are gone and not coming back.

 

What dates should I be aware of?

We will perform the first of what we call “blackout tests” for API v1 on March 5th, 2013. We will not be permanently shutting off API v1 on this date. The @Anywhere framework will be permanently retired on March 5th, as planned.

 

What are blackout tests?

The blackout tests, which will take place on different days of the week and at varying times of day, are meant to help you better understand the impact the retirement will have on your applications and users. API methods will temporarily respond to requests as if the retirement has already happened — with an HTTP 410 Gone.

 

On March 5th, 2013, from around 9:00am to 10:00am PST, we’ll perform the first of these tests, limited only to unauthenticated requests. All unauthenticated requests during that time window will be responded to with a HTTP 410 Gone. Be sure to follow @twitterapi to receive notices before, during, and after the blackout test.

To help you upgrade, we’ve added CodeBird, which is a simple PHP wrapper for the Twitter API, to the VIP Shared Plugins folder. Thanks to the development team at CNN for helping us get this library compatible with the WordPress HTTP API.

Here’s a quick snippet on how to utilize the library in your theme:

// Load the library
wpcom_vip_require_lib( 'codebird' );

// Utilize the library
WP_Codebird::setConsumerKey( 'YOURKEY', 'YOURSECRET' );
$cb = WP_Codebird::getInstance();
$cb->setToken( 'OAUTH_TOKEN', 'OAUTH_TOKEN_SECRET' );

// Make API calls
$tweets = $cb->statuses_userTimeline( /* params */ );

The WordTwit plugin will also be officially deprecated at this time. If you’re currently using this plugin, we recommend switching your sites to use Publicize.

If you have any questions or need help updating your code to utilize Twitter API v1.1, please get in touch.