Posts tagged with api

Join thousands of developers

Every two weeks, I share practical tips, tutorials, and behind-the-scenes insights from maintaining 300+ open source packages.

No spam. Unsubscribe anytime. You can also follow me on X.

Making sense of API response times

www.codemonkey.io

Mathias Hansen shares how API response time data is used at Geocodio and how to work with this kind of data in MySQL.

The API is the backbone of our business, so over the years we have continously worked to improve and ensure consistent performance. We look at many parameters such as uptime and error rates, but one of the key metrics is API response time. This is how we use this data.

Read more [www.codemonkey.io]

A package that adds resource links to your Laravel API resources

by Freek Van der Herten – 3 minute read

At Spatie we have several projects where the UI is rendered using JavaScript (we're big fans of Inertia). The backend and routes are defined in the Laravel app. The backend sends information to the frontend using API resources.

We often add the available routes the frontend can use as links property on the resource. To avoid having to add all routes manually, my colleague Ruben released a package, called laravel-resource-links that can automatically add resource links to the API resource.

In this post, I'd like to introduce the package to you.

Read more

Automatically detect broken links after a deploy

ohdear.app

You can use the Oh Dear! API to automatically perform health checks on your app after a deploy.

You can use our API to trigger an on demand run of both the uptime check and the broken links checker. If you add this to, say, your deploy script, you can have near-instant validation that your deploy succeeded and didn't break any links & pages.

Read more [ohdear.app]

Verify that your site is still online after a deploy

ohdear.app

At the Oh Dear blog, my colleague Mattias explains how to use our service to verify that your site is still online after a deploy.

You can use our API to trigger an on demand run of both the uptime check and the broken links checker. If you add this to, say, your deploy script, you can have near-instant validation that your deploy succeeded and didn't break any links & pages.

Read more [ohdear.app]

Sending and receiving webhooks in Laravel apps

by Freek Van der Herten – 8 minute read

A webhook is a mechanism where an application can notify an other application that something has happened. Technically, the application sends an HTTP request to that other application. In this blog post, I'd like to introduce you to two packages that we recently released. The first is laravel-webhook-server, which allows you to send webhook requests. The second one is laravel-webhook-client, which makes it easy to receive those webhook request.

Read more

HTTP Toolbox

lornajane.net

Lorna Jane gives a good overview of the tools available when working on an API.

As Web Developers, we need to know how to work with HTTP from every angle. I gave a 2-hour tutorial at PHP UK that included some of my most trusted tools - but it was sold out and a bunch of people asked me if there was video (there wasn't, tutorials make little sense when videoed). Instead, I thought I'd try to set out a self-study version of the workshop (I rarely teach these days so I'm unlikely to deliver it anywhere else).

Read more [lornajane.net]

Giving collections a voice

timacdonald.me

Tim MacDonald demonstrates how you can add logic to a custom collection.

Laravel collections have become an essential part of my codebases and I couldn't imagine working without them. I have found giving collections the voice of the problem domain makes for a much nicer API when compared to the generic collection methods.

Read more [timacdonald.me]

Mo' models mo' problems

sebastiandedeyne.com

Here's another awesome blogpost by my collegue Seb. In this one he explains why you should and how you can create an explicit Vue component API.

When refactoring your UI to components, always keep in mind that props and events are your components public API. Just like when you're modelling your application's domain, try to keep things explicit. Props and events should be enough to tell the outside world everything it needs to know about a component's behavior.

Read more [sebastiandedeyne.com]

Use the same controller to serve multiple formats

twitter.com

Read more [twitter.com]

HTTP Tools Roundup

Curl is not your only tool when creating or testing out APIs. On her blog Lorna Jane Mitchell made a nice list of alternatives.

At a conference a few days ago, I put up a slide with a few of my favourite tools on it. I got some brilliant additional recommendations in return from twitter so I thought I'd collect them all in one place in case anyone is interested - all these tools are excellent for anyone working APIs (so that's everyone!).

https://lornajane.net/posts/2017/http-tools-roundup

Read more

Using Guzzle 6 Middleware in a Laravel Application

Paul Redmond explains how you can use Guzzle 6' middleware to add a HMAC authorization header.

I prefer to keep my dependencies as up-to-date as possible so I decided to learn Guzzle 6 and become more familiar with the middleware. The concepts are pretty straightforward and I have a few patterns that I like to use when building out middleware within my Laravel applications.

https://medium.com/@paulredmond/using-guzzle-6-middleware-in-a-laravel-application-7fbd6d966235

Read more

Moving tech forward with Gomix, Express, and Google Spreadsheets

Matt Stauffer wrote down his experiences with creating a simple app on Gomix, a platform to easily create node powered sites right in your browser.

Gomix is a platform that makes it absurdly easy to spin up a new app (static HTML or Node) and see it online instantly. You can also invite your friends to collaborate, and the moment you make a change in the editor, your site updates. So, at this point I'm using Gomix and Node, and Express is an easy pick.

I strongly considered using Firebase for data storage, but the Gomix team linked me to this Gomix site using Google Spreadsheets as the backing data source and I really wanted to try it out.

So we've now settled: I'll take my old HTML and JavaScript, but instead of the JavaScript loading its data from JSON files, I'll run an Express app on Gomix pulling the data from Google Spreadsheets and output its data in a JSON format. No big deal.

https://mattstauffer.co/blog/moving-tech-forward-with-gomix-express-and-google-spreadsheets

Read more

Easily work with the Twitter Streaming API in PHP

by Freek Van der Herten – 3 minute read

Twitter provides a streaming API with which you can do interesting things such as listen for tweets that contain specific strings or actions a user might take (e.g. liking a tweet, following someone,...). In this post you'll learn an easy way to work with that API. Phirehose When researching on how…

Read more

A developer friendly wrapper around Fractal

Fractal is an amazing package to transform data before using it in an API. Unfortunately working with Fractal can be a bit verbose. That's why we created a wrapper called Fractalistic around it, that makes working with Fractal a bit more developer friendly. It's framework agnostic so you can use it in any PHP project.

Using the vanilla Fractal package data can be transformed like this:

use League\Fractal\Manager;
use League\Fractal\Resource\Collection;

$books = [
   ['id'=>1, 'title'=>'Hogfather', 'characters' => [...]], 
   ['id'=>2, 'title'=>'Game Of Kill Everyone', 'characters' => [...]]
];

$manager = new Manager();

$resource = new Collection($books, new BookTransformer());

$manager->parseIncludes('characters');

$manager->createData($resource)->toArray();

Our Fractalistic wrapper package makes that process a tad easier:

Fractal::create()
   ->collection($books)
   ->transformWith(new BookTransformer())
   ->includeCharacters()
   ->toArray();

There's also a very short syntax available to quickly transform data:

Fractal::create($books, new BookTransformer())->toArray();

If you want to use this package inside Laravel, it's recommend to use laravel-fractal instead. That package contains a few more bells and whistles specifically targetted at Laravel users.

To learn all the options Fractalistic has to offer, head over to the readme on GitHub. If you like it, take a look at our previous open source work as well. There's a list of framework agnostic packages we made on our company site.

Read more