A Lithium brand
Sexy API from Klout
FelipeOliveira
16
Comments
March 13, 2012

 

Klout had an incredible 2011, and as the end of the year approached I felt so proud to be part of such an amazing team! We accomplished a lot, so the holidays came at a great time; it was a much-needed opportunity for the team to catch a break and have some fun with our families. At the same time, I was excited about all the incredible things we were gonna have a blast building. So when January 2nd came along, I was back at Klout HQ ready to go; as is customary at Klout, there was a fun challenge ahead. We’ve been hard at work for the past few months and we’re excited to share with you what we’ve built.

 

The challenge was to re-engineer Klout’s API to sustain its rapid growth and massive traffic—ten billion API calls a month and growing—and also to empower our clients with all the features currently available on Klout.com.

 

a9b13a39-d838-407d-9a08-9e5eb7a8f652.png

 

So I started by concentrating on the problem at hand; I find it much more productive than jumping into the solution or any implementation detail, going against our instinct as engineers. There’s a small select group of companies serving that type of massive API traffic but a peculiar number screams out of the infographic above. Klout is the only one with less than seven hundred employees; we actually only have about 76 troopers! And what does that number represent? That number tells me that as fast as our API should be, we need to be moving even faster as a team–we need killer productivity! Besides, everyone likes to go fast!

 

Let’s Play!

 

As seems to be a recurring fact in my life—see more on Why Did I Fall in Love with Play! Framework?—the technology stack chosen was the always awesome, lean-and-mean, super-duper productive Play! Framework. As I mentioned on my previous blog post, Find Your Klout, Play was designed to provide a powerful, easy to extend infrastructure, it uses fast non-blocking IO, and it uses a stateless model that makes horizontal scaling a cakewalk. There is such a joy that comes every time my terminal sings “play new klout-* –with scala”. And with this type of traffic, our API might just be the most heavily used Play! Framework application to date!

 

Our API has Swagger

 

We were obviously going to create a RESTful API, but there are some components of SOAP (Simple Object Access Protocol) that have a lot of value. Even though I wanted no part of that business, in any shape or form, new or old, and its verbose XML format (remember the productivity factor) the WSDL (Web Service Definition Language) does provides features that aren’t commonly seen in REST. The WSDLallows client proxies to be automatically generated (wsdl2java comes to mind); it also allows developers to create client interfaces easily. How could we accomplish that without deep-diving into thousands of lines of XML? Swagger son! Here’s how Wordnik defines their marvel: “Swagger is a specification and complete framework implementation for describing, producing, consuming, and visualizing RESTful web services.” Swagger allows our API to have a well-defined contract in JSON, the same format we are using on every single endpoint.

 

635df431-ae09-4d2a-a1d2-7dac58b4a788.jpg

 

“Talk is cheap. Show me the code.” – Linus Torvalds

 

  • First of all, add the dependency on Swagger Play to your conf/dependencies.yml and run “play deps”. Then go ahead and define your data transfer class.

f7d6ccef-3d99-42a9-abad-6ad1a7fd5f8d.png

  • Now it’s time to define the controller. All the @Api* annotations are provided by Swagger. The code you are about to see doesn’t do much other instantiating the Score class and setting its value to 100 (I wish that was my Klout score).

10a444f3-ac06-46ec-95f5-01d016be14bd.png

 

  • We created an API trait to define all the business logic used on every endpoint. This trait provides an api method which we wrap each controller action with; this method does the validation, JSON transformation, and it tracks number of calls and response times with StatsD using David Ross’ super useful StatsD module. Stay tuned in our blog for another post on StatsD and our monitoring infrastructure soon.

 

 

10a444f3-ac06-46ec-95f5-01d016be14bd.png

 

  • Now it’s time to define our REST-friendly route for our endpoint, a walk-in-the-park with my beloved Play! Framework. To do that add the following line to conf/routes.

24d72885-083c-47f5-a9ad-52f8fc0d9d7c.png

 

  • Caching is being done using Memcached, re-using Play’s support for it. Jay Taylor, Klout Perks’ lead engineer, wrote a nice wrapper for it.

405af909-d399-43c0-986f-54f1890fe73d.png

 

We’re excited that the Play framework is now commercially supported by Typesafe, along with Akka and the Scala, all of which are firing on all cylinders at Klout. Building on a modern foundation like the Typesafe Stack makes it much easier for our development team to punch above its weight!

 

If you are down to Play! come join us and follow us on Twitter at @_felipera,@dyross, @ladlestein.

 

Unlock Your Klout!

 

16 Comments
anoshalassi
Not applicable

Best House Cleaning Company in Riyadh 0553551993 Tops of Excellence The best شركة تنظيف منازل بالرياض has a lot of proper cleaning operations, which are chosen according to the size of houses or palaces or villas that are treated with cleaning and it is difficult to find all the advantages within any company except when شركة تنظيف فلل بالرياض , we find you all the solutions that raise The house beauty and cleanliness reflect the personality of the owner of the house and our company uses the best materials for effective cleaning well. We provide you with the most important tips that benefit our customers in the cleaning of homes in Riyadh and we are interested in cleaning every piece of furniture in your home without exception We care about the use of disinfectants for the basins or floors to ensure the completion of the cleaning process on the full face, and this is depending on the strongest and best modern methods and the hands of skilled workers to do all the cleaning Here are the options for شركة تنظيف شقق بالرياض that make you enjoy a clean and clean atmosphere Riyadh Cleaning Company gives you an internal cleaning program which is a comprehensive cleaning program with high quality and high quality cleaning of the villas in Riyadh. It is specialized in everything inside the villas of furniture, carpets, antiques, cleaning, carpets, antiques, antiques and all the villas. It also gives the external cleaning program and this is done according to the desire of our customers and includes cleaning the glass or stone facades and cleaning the two villas villas and restore the home shine internally and externally and is done by experts with a high degree of efficiency and good training to do all the cleaning. The best materials and tools cleaning company in Riyadh A house cleaning company in Riyadh uses the most effective and different materials that comply with the Saudi and international specifications, which proved to be effective for our customers, which proved its quality in  , as for the equipment of a house cleaning company in Riyadh, it enjoys the latest equipment and modern equipments according to the technological and scientific development. At the level you expect, the more that with the house cleaning company in Riyadh, all the solutions that offer you the highest quality service in washing the upholstery and curtains as part of the overall cleaning of your home, the cleanliness of our address is civilization as it Amal is important to feel comfortable and enjoy the atmosphere of a healthy and clean اسعار تنظيف المنازل بالرياض Here are some tips for cleaning houses in Riyadh There are a lot of wrong habits used by many people in the cleaning of household purposes, which result in the results are not satisfactory at all. Here are some tips: Firstly, when cleaning carpets and furnishings there are mistakes that some women do by spraying carpets with water when cleaning can damage the tissues with moisture, all you have to do is wash my lady with a wet cloth and the cleaner and the stains are removed and then rinsed with another piece wet with water and then leave To dry (شركة تنظيف موكيت بالرياض). Second: As for the dishes and glassware and metal should not be placed in the dishwasher randomly because it makes not be cleaned as required and must be placed pots are very dirty at the bottom of the washing machine and must be placed thorns and spoons in the right way to reach the water and soap. شركة تنظيف سجاد بالرياض Third: cleaning the windows are cleaned with a brush suitable for cleaning the windows and also can be using the head to clean the dust with a vacuum cleaner also recommends that the company tops not to use paper napkins or newspapers to clean and replace with a piece of wet cloth. For more excellence and cleanliness, contact us and join our list of distinguished customers to enjoy all the services provided by a cleaning company in Riyadh peace of mind Our goal, quality and excellence is our motto

Playgame123
Not applicable

tanks

Playgame123
Not applicable

You guys get the online best proces to craete the folder easily in computer must be have the find this file explorer windows 10 so install this and secure that version forever in system.

CaitlinStorey
Not applicable

A swagger is a kind of walk. The curtain, active, somewhat bullish kind of man has this walk, solid and mighty, so it's progressed toward becoming named after the walk.

 

Regards:  cheap assignment writing service

JamesBaker
Not applicable
Check this blog for the best narrative essay examples. There are a lot of them!
TeganBaker
Not applicable

Swagger (2.0) basically is an Open Source API determination , you can consider it Wsdl for Rest APIs where you characterize the structure of the Rest APIs (endpoints urls, input/yield models, auth construction and so forth.). The determination document depends on json composition and the record augmentation is either json or yml.

 

Regards: essay help UK

Emma_Nora
Not applicable

If anyone want law help related to any field, we are here as a Law Assignment Writers to provide assisstance in the field of law. 

Filmstarlook
Not applicable

I am becoming a huge fan of yours because you have uploaded the awesome articles, but I would say one thing that you should write more article thank you for sharing. Women Fashion Black Coat

JulOz
Not applicable
Are you considering to become a professional at some area? this post will help you to figure out what to do.
JulOz
Not applicable
You will get a desire job position with a help of this resume writing service. You should choose the best service only!
serentka
Not applicable

What is the best alternative to Klout for Twitter? How can I measure the traffic and impression for my snake dream account?

emmarobet
Not applicable

Nice and interesting post, I appreciate your hard work, keep uploading more, Thank you for sharing valuable information.

Natalie Portman Black Leather Jacket

mrstom
Not applicable
Crysta - Startup Agency and SasS Business WP Theme. Crocal - Responsive Multi-Purpose WordPress Theme. Adios. Avada - Responsive Multipurpose WordPress Theme (for 2020) Jupiter - Fast-Loading Responsive Theme for WordPress. Flatsome - Versatile Responsive WooCommerce Theme uDesign - User-Friendly Responsive WordPress .
mrstom
Not applicable
Famous_jackets
Not applicable

Well known information provide by the author for who'm which can passes this article and blogs, The 11 Best Celebrity Outfits of Winter 2019 a creativity shown by the person who make's this relevant material for us thanks to stay with us with your best skills.

Bailey23
Not applicable

Check out our MASSIVE guide on the best acoustic guitars for beginners. how to play acoustic guitar for beginners