RESTful APIs in the Real World Course 2


What you'll be learning

Making RESTful APIs is hard, really hard. There are a lot of concepts to know - resources, representations, HTTP methods, status codes, etc.

Course 1 got us really comfortable with all the terminology. So in episode 2, we're attacking the hard stuff:

  • Using a serializer
  • Token Authentication System (Silex's security system)
  • Hypermedia versus media
  • The HAL hypermedia type
  • The HATEOAS PHP library
  • The HAL Browser
  • Embedding resources (versus adding links)
  • Tricks with Behat for testing API's
  • Pagination and filtering
  • A lot of other pieces in between!

This stuff is not easy. But if you make it through, you'll be armed to attack whatever API need you have. And for documenting your API, see Course 3 (not released yet)

Your Guides

Ryan Weaver Leanna Pelham

Buy Access

Questions? Conversation?

  • 2018-04-11 Victor Bocharsky

    Hey Andreas,

    Womp womp womp... unfortunately, we don't have any courses to cover API docs, but here's a few most popular bundles on GitHub which has good docs will help you with it:
    - FriendsOfPHP/Sami
    - nelmio/NelmioApiDocBundle
    - ApiGen/ApiGen

    I hope this helps.


  • 2018-04-11 andreas

    Hola - the Course 3 ( ) does not exist, can help on how do I can learn the documentation part ?

  • 2017-08-22 Milan Vlach

    You are welcome, mate. Just don't forget our bargain, tho! :D

  • 2017-08-22 weaverryan

    Yo Milan Vlach! You just made our day :). Comment shared in our internal Slack for everyone. Thanks for super nice comment :D :D

  • 2017-08-22 Milan Vlach

    You guys - are creating the best tutorials ever! I mean seriously! If this was A TV channel I would start watching TV again and never missed an episode. Hey, let's make a deal - if I find any newblood I will send them immediately here and on your part -> you will keep up good work! :)

  • 2015-03-12 weaverryan

    Hi Sergio!

    If you own this chapter (or have a subscription), you should see the download link in the upper right on any video page (not this page, but any of the individual chapter pages). If you don't have a subscription, but want to get the source files, you can grab the starting point of the project here: It's on our list to make this an easier download link for non-subscribers :).


  • 2015-03-12 Sergio

    Hello Guys, where is the download link ?

  • 2015-01-08 weaverryan


    Sorry for the delay - the video download is up there now.


  • 2014-12-30 Joan

    Well, just finished my first viewing! Sweet stuff, time to rewatch it and build something now! Congrats guys!

  • 2014-12-26 Nikos C.

    no video download?

  • 2014-12-26 Guest

    no video download available?

  • 2014-12-18 weaverryan

    Hey Jake!

    Ah, philosophical REST questions, they're mostly touch because either nobody has an answer, or the answer makes your life unnecessarily difficult :).

    In this case, this is clearly a "Product collection" representation, just not the normal JSON structure that you usually use. So, philosophically, I think it *is* correct to use the same `/product.json` URL that you use for the normal return. Now, *usually* if an endpoint returns different formats, you're supposed to read the Accept header sent by the client. Normally, the use-case is that your API endpoint returns JSON or XML, and the Accept header tells the server which one the client wants. But here, technically, *this* JSON representation and the normal JSON representation are just different "formats" of the same resource. So one "technically" right answer might be that you give this type of response some new Content-Type (e.g. application/vnd.simple-list+json) and read the Accept header to see if they want this format over the normal one.

    But in practice, that looks *crazy* to me. Go with your query parameter - it still follows most of these rules, but is also pretty practical. Try to minimize custom things like this, but at the same time, if you're building your API for your *own* consumption (i.e. you're not creating a public API), you can bend the rules a bit more.

    Great question - I love (and hate) this stuff! :P

  • 2014-12-18 Jake

    I need help how to setup an endpoint for this scenario...

    I have a resource called Products and the following endpoint returns the list of products: /products.json

    Suppose I want to return a representation which contains only a key/pair of the id and name of the product.

    1: 'CD',
    2: 'Monitor',
    3: 'Keyboard'

    Should passing a parameter be the correct solution for this?


  • 2014-10-06 Hikaru Shindo

    I'm really looking forward to see this course coming up! Can't wait for it ;)

  • 2014-09-16 Luis Lopes

    Looking forward to have this covered :) Thanks!!

  • 2014-09-08 weaverryan

    No timeline currently, but we do have the coding done, which means we're quite far along. Best case-scenario 1 month, but we'll try to release things piece-by-piece. You can press the "Notify Me" button on top and we'll email you when anything comes out :).


  • 2014-09-04 Matt

    Any time frame as to when this course will be released?

  • 2014-07-22 weaverryan

    Ha, awesome! We're working on ep2 (will be *great*), but it's still at least a few weeks out. Make sure you're subscribed for notifications at the top of this page and we'll shoot you an email.


  • 2014-07-19 Zuhair

    Just finished Ep1, can't wait for more programmer battle awesomeness! any updates on when Ep2 is out?

  • 2014-05-28 weaverryan

    Thanks Pascal! Updated :)

  • 2014-05-28 Pascal Borreli

    little typo here HATOEAS => HATEOAS

  • 2014-04-30 weaverryan

    Hi Pablo!

    It will be a bit off in the future, but yes, I think it's still something I'd like to do! In these episodes, we'll cover all the real work and knowledge you need for the REST API. A potential future Symfony version would just show you the specific implementation details inside of Symfony. So it wouldn't have all of the meat that these episodes have, but I think it would still be very useful. If you're on our mailing list, we'll definitely let you know.

    Cheers and you're very welcome :)

  • 2014-04-30 Pablo MarĂ­a Martelletti

    Hi Guys,

    In this post:

    you talked about possibly creating 2 tutorials: one for generic PHP and one for Symfony, using FOSRestBundle. I've already been digging in the first screencast, Rest, but I see that this second episode is still not about Symfony. Are still planning to release this Symfony screencast?

    Cheers! Thanks a lot for your work! :)