bridges for WordPress is an API builder that allows you to construct read-only APIs for your consumers without writing a single line of code.
“But WordPress already has an API!” Ah, a fair observation. We invite you to see how bridges stacks up against the native WordPress REST API.
This page contains full documentation for the bridges WordPress API builder.
Install bridges by downloading it from the homepage, installing it and activating it like a normal WordPress plugin.
You will see the “Bridges” menu item in your WordPress Dashboard. This is the main UI to create and manage your API endpoints. Begin by creating a new Bridge.
Give your Bridge an arbitrary name. It will not be displayed anywhere except the Dashboard. Set the API endpoint slug which sets the complete address your Bridge is accessed at. The slug can contain slashes so you can “nest” API endpoints and construct directories.
Next, select a format that your API will adhere to. We’ll pick JSON in this guide as it’s the most popular API format these days.
Once you hit the “Create” button your first Bridge is ready! If you visit the Bridge URL you’ll get an empty “null” response as you’ve yet to define the schema.
All (useful) Bridges need to have some output. Output is generated by Bridge Elements that are arranged into one nice Schema. A JSON Bridge has one root-level Element, any other Elements are nested into it at various levels. Read the next section on Elements to get acquainted with the different types of Elements Bridges support.
In most JSON APIs the root element would be an Object or a List/Array. In bridges Iterators are also Lists and can be used to output arrays of objects. Let’s add an Object, set the first key to “version” and add a Literal to this first key.
Many Bridge Elements have some sort of configuration. Literal Elements have a simple configuration where the output value is set. Let’s make it output a “1”. This will be our API version. Next add a “posts” key to the Object we created earlier and add a Post Iterator Element. The Post Iterator can be configured to grab a number of WodPress posts. The query can be left blank for a default post-grabbing extravanaganza.
The Post Iterator can also hold only one single object per iteration (per post). This is why it’s important to create more “space” in the schema by setting the iteration element to an Object. Let’s add some simple keys and Post Property Elements to them.
How about that? Finally, let’s return to the root Object Element by using the breadcumbs above the configuration screen and add a new key called “siteurl” and set it to Option. Select the “siteurl” option, exposing it in our API. Compare your work to what we have in this tutorial:
Visit the API URL:
Well done! This should have taken you less than 5 minutes to read along and create. Simple WordPress APIs in mere minutes. Try nesting the Comment and User Iterators into Post Iterators now. Keep reading to find out more about how bridges work and how to create more complex APIs.
bridges has a number of Elements that can be utilized while making a WordPress API. For the JSON API format there are three types of base Elements. These are: lists/objects, iterators, values. List and object elements are mere containers, used to organize values. Iterators loop over some sort of selection and setup a value context. Values produce some value, sometimes based on some context.
This Element requires a Post Iterator context inside as a parent Element. It will look at the current iteration and fetch metadata or a Post property. No filters are called for things like “post_content” and “post_title”, everything is raw. Metadata filters are called.
Exposes WordPress Comment metadata and properties via a Comment Iterator. For this reason this Element has to be a child (not necessarily a direct one) of a Comment Iterator. Available meta keys and properties are provided in the Element configuration screen.
The User Property Element requires a Post Iterator, Comment Iterator or User Iterator parent. Context is retrieved from these iterators in order to select the specific WordPress User the data is being fetched for.
bridges is meant to be a simple but powerful WordPress API constructor. If you require assistance we’re always happy to help. Please message our support department with any feedback you may have. Bugs, issues? We’ll sort them out. Need guidance, missing some features? Hit us up, we got you covered.
bridges free is currently in open public beta. bridges PRO is in a closed beta. If you’d like to send suggestions, have questions or other feedback please contact us any time at email@example.com
bridges is a Pressjitsu, Inc. product
All rights reserved 2019-2020