{"id":2091,"date":"2021-02-15T08:54:23","date_gmt":"2021-02-15T08:54:23","guid":{"rendered":"https:\/\/loadfocus.com\/blog\/?p=2091"},"modified":"2023-09-03T14:09:46","modified_gmt":"2023-09-03T14:09:46","slug":"how-to-load-test-restful-apis-with-loadfocus","status":"publish","type":"post","link":"https:\/\/loadfocus.com\/blog\/2021\/02\/how-to-load-test-restful-apis-with-loadfocus","title":{"rendered":"How to Load Test RESTful APIs with LoadFocus"},"content":{"rendered":"<span class=\"span-reading-time rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\"><\/span> <span class=\"rt-time\"> 3<\/span> <span class=\"rt-label rt-postfix\">minutes read<\/span><\/span><!-- pn-tldr --><h2>Key takeaways<\/h2><ul><li>Load test the endpoints your clients actually call, weighted the way they call them.<\/li><li>Send realistic payloads and headers, since size and content change server behaviour.<\/li><li>Assert on the response body as well as the status code.<\/li><\/ul><!-- \/pn-tldr -->\n<p class=\"lead\">In order to learn how to test your APIs, especially how to load test your APIs, let&#8217;s first find out some essential info on APIs and RESTful APIs.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is an API? (Application Programming Interface)<\/h2>\n\n\n\n<p>API stands for Application Programming Interface, which is a set of functions that allows two applications to talk to each other. Also, APIs allow interaction between various software components, microservices by exchanging responses between users and systems.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is RESTful API?<\/h2>\n\n\n\n<p>REST stands for <strong>Representational state transfer<\/strong>, and&nbsp;is an architecture standard for designing networked applications, interactive applications that  use multiple Web Services. More details about REST and RESTful APIs can be found <a href=\"https:\/\/en.wikipedia.org\/wiki\/Representational_state_transfer\" rel=\"nofollow\">here<\/a>.<\/p>\n\n\n\n<p>An API is considered RESTful if it ticks all criteria below:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>A <strong>client-server architecture<\/strong> with requests made through <strong>HTTP<\/strong> (Hypertext Transfer Protocol).<\/li><li><strong>Stateless<\/strong> communication which translates that each request is executed like it&#8217;s made from scratch, no information is stored about the client, or about the past transactions. <\/li><li><strong>Cacheable data<\/strong> between client and server.<\/li><li><strong>Uniform interface<\/strong>&nbsp;which tells that resources should be uniquely identifiable through a single URL to identify and manipulate resources.<\/li><li><strong>Layered system<\/strong> which allows for an architecture composed of multiple layers of servers, hierarchies which are invisible&nbsp;to&nbsp;the client.<\/li><\/ul>\n\n\n\n<p>Overall, REST APIs are simpler to implement comparing to SOAP (Simple Object Access Protocol) APIs, which requires additional requirements when starting a transaction, relies heavily on XML and uses WSDL \u2013 Web Service Description language.<\/p>\n\n\n\n<p>REST uses methods GET, PUT, POST, DELETE to link resources to actions within a client-server relationship, its main purpose is to offer simplicity and end-user satisfaction for a wide audience.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Which response formats are used in REST APIs?<\/h3>\n\n\n\n<p>REST uses <strong>HTML, XML, plain text, and JSON<\/strong> as potential responses, however, the most popular one is JSON (JavaScript object notation) because is easily readable by humans and easily to integrate with other frameworks and tools since it&#8217;s widely accepted.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/loadfocus.com\/blog\/wp-content\/uploads\/network-1024x576.jpg\" alt=\"api client server\" class=\"wp-image-2101\" srcset=\"https:\/\/loadfocus.com\/blog\/wp-content\/uploads\/network-1024x576.jpg 1024w, https:\/\/loadfocus.com\/blog\/wp-content\/uploads\/network-600x338.jpg 600w, https:\/\/loadfocus.com\/blog\/wp-content\/uploads\/network-400x225.jpg 400w, https:\/\/loadfocus.com\/blog\/wp-content\/uploads\/network-768x432.jpg 768w, https:\/\/loadfocus.com\/blog\/wp-content\/uploads\/network-1536x864.jpg 1536w, https:\/\/loadfocus.com\/blog\/wp-content\/uploads\/network.jpg 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>Now that we have a basic understanding of REST APIs and what a RESTful API stands for, we can continue and have a look at load testing, and <a href=\"https:\/\/loadfocus.com\/blog\/2020\/11\/what-is-the-purpose-of-load-testing\/\" title=\"What is the Purpose of Load Testing?\">what is the purpose of load testing<\/a> or check <a href=\"https:\/\/loadfocus.com\/blog\/2021\/01\/what-is-a-good-example-of-load-testing\/\" title=\"What is a Good Example of Load Testing?\">what is a good example of load testing<\/a>, this can apply to your website and APIs as well.<\/p>\n\n\n\n<p>We can follow the steps to start API load testing by following some of the previous posts that include <a href=\"https:\/\/loadfocus.com\/blog\/2018\/04\/how-to-design-your-load-testing-scenarios\/\">load testing scenarios<\/a>, <a href=\"https:\/\/loadfocus.com\/blog\/2017\/01\/performance-testing-vs-load-testing\/\" title=\"Performance Testing vs. Load Testing\">performance testing vs. load testing<\/a>, and an example of <a href=\"https:\/\/loadfocus.com\/blog\/2014\/08\/load-testing-for-restful-apis-in-the-cloud\/\" title=\"Load Testing for RESTful APIs in the Cloud\">APIs to be tested in the cloud<\/a>.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><em>Written by&nbsp;<a href=\"https:\/\/coursinator.com\/instructor\/bogdan-vazzolla\" target=\"_blank\" rel=\"noreferrer noopener\" class=\"broken_link\">Bogdan&nbsp;Vazzolla<\/a>.<\/em><\/p>\n\n\n\n<p><em><a href=\"https:\/\/loadfocus.com\/\">LoadFocus<\/a>&nbsp;is a cloud testing platform,&nbsp;a <a href=\"https:\/\/loadfocus.com\/load-testing\" target=\"_blank\" rel=\"noreferrer noopener\">load and stress testing tool<\/a>&nbsp;which provides the infrastructure to run tests with thousands of concurrent users, from&nbsp;<a href=\"https:\/\/loadfocus.com\/locations\">multiple cloud locations<\/a>, in less than a few minutes, keep history of the results, compare different runs to inspect performance improvements or performance degradation.<\/em>&nbsp;<em>It also supports running&nbsp;<a href=\"https:\/\/loadfocus.com\/jmeter-load-testing\" target=\"_blank\" rel=\"noreferrer noopener\">JMeter load tests from the cloud<\/a><\/em> and <a href=\"https:\/\/loadfocus.com\/page-speed-monitoring\">monitoring and audit web and mobile performance<\/a>.<\/p>\n<!-- pn-faq --><h2>Frequently Asked Questions<\/h2><h3>Which endpoints should I load test?<\/h3><p>The ones your clients actually call, in roughly the proportion they call them. An even spread across every endpoint tests a traffic pattern nobody produces.<\/p><h3>Does the payload matter?<\/h3><p>Yes. Size and content change parsing, validation and database work, so a minimal body understates the cost of a real request.<\/p><h3>Is a 200 status enough to call it a pass?<\/h3><p>No. Assert on the response body too. An endpoint can return 200 with an error object or an empty list, which is a failure everywhere except in your results.<\/p><!-- \/pn-faq --><!-- pn-related-reading --><h2>Related reading<\/h2><ul><li><a href=\"https:\/\/loadfocus.com\/blog\/2025\/04\/rest-api-interview-questions\">10 Critical REST API Interview Questions for 2026, Answered<\/a><\/li><li><a href=\"https:\/\/loadfocus.com\/blog\/2014\/02\/what-is-http\">What is HTTP?<\/a><\/li><li><a href=\"https:\/\/loadfocus.com\/blog\/2014\/08\/load-testing-for-restful-apis-in-the-cloud\">Load Testing RESTful APIs in the Cloud<\/a><\/li><\/ul>","protected":false},"excerpt":{"rendered":"<p><span class=\"span-reading-time rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\"><\/span> <span class=\"rt-time\"> 3<\/span> <span class=\"rt-label rt-postfix\">minutes read<\/span><\/span>Key takeaways Load test the endpoints your clients actually call, weighted the way they call them. Send realistic payloads and headers, since size and content change server behaviour. Assert on the response body as well as the status code. In order to learn how to test your APIs, especially how to load test your APIs,&#8230;  <a href=\"https:\/\/loadfocus.com\/blog\/2021\/02\/how-to-load-test-restful-apis-with-loadfocus\" class=\"more-link\" title=\"Read How to Load Test RESTful APIs with LoadFocus\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":2100,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,9],"tags":[340,338,339],"class_list":["post-2091","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-apache-jmeter","category-load-testing","tag-load-testing-apis-in-the-cloud","tag-load-testing-rest-apis","tag-restful-apis-load-testing-tool"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/loadfocus.com\/blog\/wp-json\/wp\/v2\/posts\/2091","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/loadfocus.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/loadfocus.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/loadfocus.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/loadfocus.com\/blog\/wp-json\/wp\/v2\/comments?post=2091"}],"version-history":[{"count":1,"href":"https:\/\/loadfocus.com\/blog\/wp-json\/wp\/v2\/posts\/2091\/revisions"}],"predecessor-version":[{"id":2748,"href":"https:\/\/loadfocus.com\/blog\/wp-json\/wp\/v2\/posts\/2091\/revisions\/2748"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/loadfocus.com\/blog\/wp-json\/wp\/v2\/media\/2100"}],"wp:attachment":[{"href":"https:\/\/loadfocus.com\/blog\/wp-json\/wp\/v2\/media?parent=2091"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/loadfocus.com\/blog\/wp-json\/wp\/v2\/categories?post=2091"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/loadfocus.com\/blog\/wp-json\/wp\/v2\/tags?post=2091"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}