Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

Sagar Suri
Sagar Suri
6,043 Points

How to create REST API for our website so that I can access data from my website ?

I want to create a REST API for my website.I don't know where to start..please help me..which is the easiest way to create API in minutes.

1 Answer

Patrick Cooney
Patrick Cooney
12,216 Points

Uhhhhhhh, creating an API in minutes is not realistic. Depending on how much time you dedicate to it you can maybe build one in a few days. Take a look at Parse or FatFractal or Kinvey or something similar. You won't have one in minutes but you can have one quickly.

If you're talking about building your own from scratch it depends what you're building. What type of service are you building? What you are building is what will guide what technologies are best for your API. You can build an API in Java, Rails, Node, etc. If you describe what you're building I'll try to help you out. For instance I'm building a mobile app that will involve a lot of chat messages being exchanged. I'm likely going to use Java because of it's ability to handle high loads and scale well. I'm also working on a web app that will allow multiple users to move objects around the same screen concurrently. For that I plan to use Node because it's non-blocking and great at handling real-time stuff over websockets.

Sagar Suri
Sagar Suri
6,043 Points

Thanks a ton bro..Great explanation..I just wanted to fetch posts and all those stuffs which I update on my website..This there any tutorial from where I can learn build an API from scratch in java.My idea is to create a mobile app which will fetch all the posts and registered users.So that if a registered user uses my app he can login back through my app and can continue his work.

Patrick Cooney
Patrick Cooney
12,216 Points

How is your website built? Are you using WordPress or is it hand coded with HTML and CSS? If it's a CMS like WordPress you can use something like this to automatically generate an API response.

If you coded your own site you're going to need to build the API with a server side language. If you're only using the API to send posts to the mobile app I highly advise against Java. It takes a lot of boilerplate code to build even a simple API. I would check out the intro Node.js courses (based on your profile I'm making the assumption that you already know Javascript) here on Treehouse. Towards the end of the videos Chalkers teaches you how to set encoding for your response. Instead of sending back HTML you would send back Javascript objects with an encoding type of text/JSON.

Sagar Suri
Sagar Suri
6,043 Points

I built my website with just HTML and CSS.Thank you so much bro.Really appreciate your help.