-
Right-Size Your RESTful API: More Flexibility Without GraphQL
26 March 2025
Read moreIf you publish a RESTful API and there are situations when you need less (or more!) detail in the API responses from your API - then this post is for you. When I run into this with the teams I advise, the initial problem statement usually arrives more like "We need to move to GraphQL", but this is a solution, not a problem to solve. The problem usually turns out to be either or both of:
the API responses are simply too large for some of the clients or uses cases, users need to select just the fields they want
the API doesn't have enough information in the response payload for this client or use case, users need to choose to include nested data
GraphQL is one way to achieve these things, but this post is about the RESTful way to provide the right level of detail in an API response.
-
Querying the GitHub GraphQL API
27 January 2025
Read moreIn a recent project around open source contributors, I wanted to take a look at which projects a particular user (actually a few of them, but I wrote a wrapper to repeat the process for each handle) maintains. GitHub doesn't show this maintainer relationship, so instead I used the v4 GraphQL API and looked at pull request comments on repositories that the user has access to. I'm sharing my query and the Python script I used to make the API calls to.
-
What Does URI Stand For?
05 March 2014
Read moreI get a lot of complaints about an API that I maintain (http://api.joind.in) which is "missing" the ID field. This ID field is the database's primary key; if the user doesn't have access to the database (they don't), then it seems to me that the primary key …
-
Are Subqueries RESTful?
13 June 2013
Read moreTwitter is great for one-liners, but it's very difficult to carry on any kind of advanced conversation there. Therefore when I saw this tweet yesterday, I knew I'd be picking a different medium to reply:
@lornajane sory for getting on your nervs with #rest,but are subquerys (like couchDB does) restfull to? is there a rule? like .../?type=bla
— Maximilian 'Berghoff (@ElectricMaxxx) June 12, 2013
-
Five Clues That Your API isn't RESTful
23 January 2013
Read moreI get a lot of emails asking me to get involved with API projects, and that means I see a lot of both implemented and planned "RESTful" APIs. Now, I absolutely love REST and for a data-driven application, it would be my first choice. A service of some other description may work better for other scenarios or skill sets, and non-RESTful services can be very, very useful. If you tell me that your service is RESTful, then I expect it to be. If you're not sure, look out for these clues:
-
Building A RESTful PHP Server: Routing the Request
23 January 2012
Read moreThis is the second part of a series, showing how you might write a RESTful API using PHP. This part covers the routing, autoloading, and controller code for the service, and follows on from the first installment which showed how to parse the incoming request to get all the information …
-
Building A RESTful PHP Server: Understanding the Request
19 January 2012
Read moreOnce upon a time, what seems like a lifetime ago, I was away for a couple of weeks, and I wrote a series of posts about serving RESTful APIs from PHP to keep my blog going while I was away. Fast forward a few years and those posts are outdated and still wildly popular - so I thought it was about time I revisited this and showed how I'm writing RESTful PHP servers today!
In the first part of this (probably) 3-part series, we'll begin with the basics. It might seem boring, but the most important thing to get right with REST is parsing all the various elements of the HTTP request and responding accordingly. I've put in code samples from from a small-scale toy project I created to make me think about the steps involved (should I put the code somewhere so you can see it? Let me know). Without further ado, let's dive in and begin by sending all requests through one bootstrap script:
-
GETting RESTful collections - may I filter?
23 March 2010
Read moreAt work at Ibuildings recently, I've been teaching some classes on web services, and its a topic that I've spoken about once or twice at conferences. But something has always bothered me, so I find myself in the unusual position of blogging a question.
RESTful collections
So, when you are …
-
Adding PUT variables to Request Object in Zend Framework
17 August 2009
Read moreWhen I wrote recently about testing web services within Zend Framework, I missed out a really key piece of information! I didn't explain how I was reading the PUT vars in my controller code in the first place - so I'll rectify that omission now.
Its very simple: I have extended …
-
Using Zend_Test for Web Services
13 August 2009
Read moreRecently I had cause to develop a web service and so I wrote some tests to go along with it - or I was about to. When I looked at the asserts available in Zend_Test, they were all geared towards HTML/CSS output - but we can test just as effectively on …
-
Status Codes for Web Services
02 July 2009
Read moreThis the last entry in a mini series on points to consider when designing and building web services. So far there have been posts on error feedback for web services, auth mechanisms for web services, saving state in web services and using version parameters with web services.
Unlike the other …
-
Error Feedback for Web Services
18 May 2009
Read moreI have been thinking, writing and speaking a little bit about web services recently, starting with a few thoughts on authorisation mechanisms for services. Today we'll look at another really important aspect of authoring web services, and one feature that will definitely get used - error handling and feedback! Having clear …
-
Using curl and PHP to talk to a REST service
15 September 2008
Read moreHaving recently written articles about curl and about writing a PHP REST server, I thought I'd complete the circle and put here a few notes on using PHP's curl wrapper as a Rest client. Also I had to look some of this up when I needed to actually do it …
-
PHP Rest Server (part 3 of 3)
05 September 2008
Read moreEdit: I have a newer series of articles on this topic. You can start reading here :)
This is part 3 of my article about writing a restful service server. If you haven't already, you might like to read part 1 (covering the core library and grabbing the information we need …
-
PHP Rest Server (part 2 of 3)
03 September 2008
Read moreEdit: I have a newer series of articles on this topic. You can start reading here :)
This is part 2 of my rest service writing article. In part 1 we saw the library which holds the functionality we will be using, and we also handled the incoming request and captured …
-
PHP Rest Server (part 1 of 3)
01 September 2008
Read moreI recently had reason to write a REST server in PHP, which was very interesting. There aren't a whole lot of resources on this topic around so I thought I'd write an outline of what I did. There is quite a lot to it so I'm publishing in multiple sections …
-
Accessing Incoming PUT Data from PHP
30 July 2008
Read moreRecently I started writing a REST service. I began in the usual way, writing a php script, calling it with a GET request, accessing the variables using the PHP superglobal variable $_GET. I wrote code to handle a POST request and used the variables I found in $_POST. Then I …