JSON API

Summarized using AI

AMS, API, Rails and a developer, a Love Story

João Moura • May 12, 2015 • Atlanta, GA

In the video titled 'AMS, API, Rails and a developer, a Love Story', João Moura discusses the importance and challenges of building high-quality APIs using Rails and Active Model Serializers (AMS). Moura emphasizes that APIs are essential for web functionality and shares his experiences as the Chief Technology Officer at a startup named Fato, where they encountered significant technical challenges in API performance during high-traffic events like the World Cup.

Key points discussed include:

- Importance of APIs: APIs are crucial for enhancing communication between applications and have become fundamental for the internet's functionality.

- Active Model Serializers (AMS): AMS simplifies the JSON generation process, promoting 'convention over configuration', which enhances API performance and usability. Moura expresses his affection for AMS and its integral role in API development.

- Key Principles for Good APIs: Effective APIs should prioritize performance, scalability, reusability, evolvability, and comprehensive documentation.

- Rails and Rails API: Rails API optimizes API development by removing unnecessary components, introducing functionalities tailored for APIs while enhancing speed and compatibility.

- New Version of AMS: Moura highlights significant new caching functionalities and flexibility improvements in the latest versions of AMS, including the ability to work with different data formats and enhanced performance metrics.

- Community Collaboration: He stresses the importance of collaboration within the developer community and expresses excitement about integrating AMS directly with Rails to enhance overall usability.

The talk concludes with Moura announcing the release of the latest AMS version, inviting the developer community to take advantage of the new features. Overall, the presentation underscores the role of AMS in improving API performance and encourages developers to focus on creating robust and efficient APIs.

AMS, API, Rails and a developer, a Love Story
João Moura • May 12, 2015 • Atlanta, GA

By, João Moura
A lot of people have being using Rails to develop both their internal or external API, but building a high quality API can be hard, and performance is a key point to achieve it.

I'll share my stories with APIs, and tell you how Active Model Serializer, component of Rails-API, helped me. AMS have being used across thousands of applications bringing convention over configuration to JSON generation.

This talk will give you a sneak peek of a new version of AMS that we have being working on, it's new cache conventions, and how it's being considered to be shipped by default in new Rails 5.

RailsConf 2015

00:00:12.759 API is what makes the web what it is today. We are all using APIs, and they have become crucial for internet functionality. Although APIs are not a new technology, having existed long before the internet, the web has pushed their use further by enhancing how machines communicate with each other. This movement is continually evolving, and we, as developers, have been using frameworks like Rails to create robust APIs that require sacrifices for quality. My name is João Moura, and I'm the co-founder of a startup focused on API fortification. Today, we're going to talk about Active Model Serializers (AMS), Rails, and the stories that connect them.
00:00:39.040 I am excited to share my journey and experiences with APIs, specifically how Active Model Serializer has been instrumental in my work. AMS has been utilized across thousands of applications, promoting convention over configuration in JSON generation. In this talk, I’ll provide a sneak peek into a new version of AMS we have been working on, its new caching conventions, and how this will be included with defaults in new versions of Rails.
00:01:04.520 To give you a bit of context about myself, I traveled quite a distance to be here today. It takes me about ten hours to reach this conference. Interestingly, whenever I attend conferences around the world and mention that I’m from Brazil, people always ask about the lush forests, breathtaking landscapes, and wildlife. But, in reality, I come from one of the largest cities in the Americas, where there’s heavy traffic and dense urban living. It's a common misconception that Brazil is all about nature, but my home city is very much a bustling metropolis.
00:01:51.880 Despite the urban chaos, Brazilians are known for our ability to have fun. Soccer, for example, is a huge cultural phenomenon. Everyone in Brazil loves soccer, and playing it is a rite of passage. Last year, I was invited to join a startup called Fato as their Chief Technology Officer, which was a thrilling experience considering the World Cup was around the corner. However, as the event approached, we were unprepared for the surge of users we expected, leading to numerous technical challenges.
00:02:43.360 We faced an array of problems, including unreliable background jobs, poor database relationships, and a lack of caching, which made our APIs exceptionally slow. It was during this challenging moment that I discovered my love for Active Model Serializers. I realized how valuable AMS could be for creating efficient APIs. To those in the audience who have used Active Model Serializers: you're in for a treat, as it truly enhances the development experience.
00:03:53.720 Now, let's dive deeper into the concept of APIs, which stands for Application Programming Interface. It's important to consider the definition of an interface -- today, there is a lot of focus on user interfaces, as we recognize how crucial user experience is for application success. However, APIs are also a type of interface that developers and users interact with. Therefore, we need to invest the same level of care and technology in crafting APIs as we do with user interfaces.
00:06:33.040 A well-constructed API can be a tremendous asset for a company. For instance, take Facebook's API, which significantly contributed to their growth as the largest social network in history. Today, users expect the ability to sign in through Facebook on various platforms; their API became a significant tool in expanding their reach. Conversely, neglecting to build a robust API can lead to serious liabilities, requiring companies to spend time and resources fixing issues that arise.
00:07:38.000 So, how do we build a good API? There are eight key concepts that define an effective API: performance, scalability, reusability, evolvability, and comprehensive documentation. It must be easy to learn and use while being hard to misuse. These principles are intertwined, which means that adhering to established conventions can lead to increased performance and easier documentation.
00:08:31.560 Rails aligns perfectly with these principles by emphasizing convention over configuration, which results in better performance, usability, and maintainability of APIs. This is why Rails is often considered one of the best frameworks for building APIs. However, we must acknowledge that Rails does have some heavier components that aren’t necessary in all cases.
00:09:33.720 That's where Rails API comes into play. Rails API strips away the unnecessary parts of Rails that aren’t essential for API development, streamlining the process. It introduces new functionalities aimed explicitly at creating APIs, enhancing speed, and ensuring compatibility. One of the remarkable components of Rails API is Active Model Serializers, which simplifies the process of serializing objects into JSON output.
00:10:43.880 For instance, using a serializer allows you to define what attributes you want to include in your JSON response. You can also create virtual attributes that do not directly exist within your model, giving you full control over your output. Once you define your serializer and associate it with your application, generating a JSON output becomes straightforward.
00:12:00.520 Over the years, Active Model Serializers has gone through various iterations, such as the 0.8 version and now the latest 0.10 version. These upgrades come with improvements that enhance both usability and performance. I am excited to share that we are implementing significant features in the upcoming version that will continue to optimize the API development process.
00:12:52.880 Notably, we've incorporated an adapter option that allows for returns in formats other than JSON. This added flexibility means that if developers wish to return data in XML or other formats, they can create an appropriate adapter. Moreover, we’re working on implementing JSON API specifications that will allow seamless, fast integration for developers, which can further enhance API performance.
00:14:39.360 Two additional features that I'm excited about are caching functionalities. We’ve introduced built-in caching capabilities to Active Model Serializers. Simply adding a cache method in your serializer makes it possible to cache responses effectively, increasing the speed and efficiency of your API. Moreover, we’ve implemented fragment caching, allowing developers to cache specific attributes within a serializer. These optimizations together significantly enhance performance, especially for APIs with high traffic and changing data.
00:18:38.560 Today's development environment continually emphasizes the need for faster and more efficient APIs, so we are committed to pushing the boundaries further. Our benchmarks have shown remarkable performance improvements with the new implementations compared to previous versions. It’s essential for us to provide tools that help developers track performance issues as they continue to improve their APIs.
00:20:50.840 Additionally, I'm thrilled to announce that we just released a brand-new version of AMS today, including all the latest features discussed. The team has worked incredibly hard to get this out, and we're eager for you to start using it immediately. Finally, I fiercely believe in collaboration within the developer community, and I'm very excited about the possibility of integrating AMS directly with Rails to enhance usability across all applications. Thank you all for being here, and I'm happy to take any questions you might have.
Explore all talks recorded at RailsConf 2015
+122