Skip to main content

Our First API (Example) - GoRails

General • Asked by Chris Oliver

Chris, at 10:33, when you open /api/v1/locations/1.json in your browser, I see that you can alternate between raw and parsed views of the json. Which plugin are you using for this?


I am excited about the upcoming API-related videos. A particular question I have and would love to see some aspect of it discussed in the videos is this: How to return custom error codes? http://stackoverflow.com/qu...

Some suggestions I found regarding this: https://blog.rebased.pl/201...


Awesome video, Chris! I built my first api this past weekend and struggled because there were so many different sources out there. Codeschool helped me out the most. But this video would have saved me a few hours!


I'm really excited for this. Awesome job! I love how you gradually introduce topics.

Thanks Matias! :)


Awesome video Chris, cant wait to dive deeper :) Authentication especially

The auth stuff is going to be fun. So many different methods.

If you haven't decided on an auth method yet, I'd love to request JWTs!

+1 for JWT :)


Impeccable timing. I'm building an Android app with a Rails API as its back end. And just when I'm thinking "hmm I wonder how to handle authentication with APIs" in your video you say "we'll dive in talk about things like authentication... etc". :)


Can't wait for the webhooks 🙊


Great stuff Chris, 14 minutes set it all straight with how easy it is. Do you plan to do any stuff around Webhooks (generally, not just Stripe), rate limiting etc as well?

Also, any ideas when we could expect the next video around the API auth + error handling etc? :D

+1 vote for JWT!

Like building webhooks for your customers to use or consuming other service's webhooks?

First auth video will be next week. Going to be recording it tomorrow. :)

I might be slightly biased/specific situation, but I think there's plenty of content already around consuming webhooks from other services (eg your Stripe Webhook or Docusign Webhooks video which can be adapted to other services).

It would be great to get some more insights around best practices for building out our own webhook service for own customers to consume/ be notified, or even extending this to other microservices that we may have running.

Of course, this could also be addressed by implementing a pub/sub system as well, which would also be interesting to get your perspective on!

Look forward to the new videos, great stuff mate!

Yeah that's what I was thinking but just wanted to confirm it. Consuming pretty standard but there's few resources out there that actually talk about sending out webhooks and how to handle responses and exponential backoff and things. I think that'll be a fun set of episodes to do.


I guess I am interested in the versioning and authentication area of it.

Versioning: how to write DRY code with versioning, backwards compatibility without repeating your code.


Chris, I think that you have clearly hit a topic, that a huge group of people have interest in. As far as APIs are concerned, I believe you have material for many more videos :)

I wrote out a list of topics related to APIs and had like over 50 different episodes I could do. That's so many it could fill up the entire next year with only API content. Love it. :D


like the bonus tips at the end.


MOOOOORE!!!

Great video Chris! Can't wait to see the rest of the series!


WTH? I'm about to unsubscribe after watching this video, Rails 5 has the API ONLY MODE and this video was published on December 20, 2016. Why you are showing us the old way of creating ROR APIs???

It's just the basic introduction
I'm sure Chris aware of it

Hey Victor, please be constructive. Angry comments don't help anyone.

A common misconception like you have is that Rails API-only mode is how you should build all Rails APIs, which is flatly incorrect. In some specific cases where you don't want to render a website, you can use API-only mode to strip out most of the Rails functionality that's used for cookies and other web functionality but isn't needed for APIs. Since it removes a lot of Rails features, API-only mode should only be used when you know you really want to disable those features of Rails.

That's why it's not the default and why I'm not talking about it just yet. We will be covering this but it is not the "new way" of doing things as you claim. It is a way of doing things for a specific situation, not all situations.

So again, we're here to help each other learn these things, not shout angry comments at me about something that you believe is incorrect. It's not, and the whole reason I made this episode was to discuss how APIs are not a special thing like you claim. It's a common misunderstanding and one that we can fix if we talk about this stuff in-depth.

Next time instead of telling me I'm stupid, simply ask why I haven't talked about API-only mode and we can all have a much more constructive time together.


Chris-
Love to see file uploads through an API. If it was possible to do direct to S3 that would be the icing on the cake.
Thanks,
Dave


cool I am interested in learning how to use a rails controller for rendering json to use as a AngularJs restful api frontend.


Chris, adding the request.format = :json works only in Application Controller.
Tried to add in the show method directly, it is not working.
Any help to understand this?

You need to change ApplicationController to ApiController in locations_controller.rb.


I had to change the coffee-script version in the Gemfile.lockfile to 1.12.2 to get bundle install to work.


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 27,623+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.