This website recently got a major rebuild; if you're missing something, let Lorna know.

    Tag: rest


  1. Right-Size Your RESTful API: More Flexibility Without GraphQL


    If 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.

    Read more

  2. Querying the GitHub GraphQL API


    In 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.

    Read more

  3. What Does URI Stand For?


    I 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 …

    Read more

  4. Are Subqueries RESTful?


    Twitter 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

    Read more

  5. Five Clues That Your API isn't RESTful


    I 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:

    Read more

  6. Building A RESTful PHP Server: Routing the Request


    This 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 …

    Read more

  7. Building A RESTful PHP Server: Understanding the Request


    Once 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:

    Read more

  8. GETting RESTful collections - may I filter?


    At 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 …

    Read more

  9. Adding PUT variables to Request Object in Zend Framework


    When 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 …

    Read more

  10. Using Zend_Test for Web Services


    Recently 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 …

    Read more

  11. Status Codes for Web Services


    This 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 …

    Read more

  12. Error Feedback for Web Services


    I 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 …

    Read more

  13. Using curl and PHP to talk to a REST service


    Having 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 …

    Read more

  14. PHP Rest Server (part 3 of 3)


    Edit: 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 …

    Read more

  15. PHP Rest Server (part 2 of 3)


    Edit: 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 …

    Read more

  16. PHP Rest Server (part 1 of 3)


    I 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 …

    Read more

  17. Accessing Incoming PUT Data from PHP


    Recently 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 …

    Read more