Blog
  • AI Gateway
  • AI Security
  • AIOps
  • API Security
  • API Gateway
|
    • API Management
    • API Development
    • API Design
    • Automation
    • Service Mesh
    • Insomnia
    • View All Blogs
  1. Home
  2. Blog
  3. Learning Center
  4. RESTful API Best Practices
Learning Center
March 10, 2022
6 min read

RESTful API Best Practices

Kong

If youre involved in API design these days it can feel like someone is proclaiming the benefits of RESTful API design everywhere you turn. However, that advice often comes without an explanation of exactly what is meant by RESTful APIs or is mixed in with advice that isnt so much about API design as it is about the implementation in the code of a specific framework or language.

In this article, were going to walk through a brief origin of RESTful APIs and then take a good look at what to consider when building your own APIs with RESTful design.

What is a RESTful API?

REpresentational State Transfer or REST is an architectural pattern designed by Roy Fielding, in a chapter of the dissertation he wrote in 2000. Fielding had been involved in the development of a number of standards for the early internet.

He saw that patterns were arising in the design of communication protocols between different applications that would have significant performance and usability issues as the fledgling internet began to take off. In particular, he came up with six architectural constraints for building an API that would be well suited to the internet age.

Shortly after the publication of Fieldings dissertation, developers began making intentional use of these principles that hed definedin ways that would make their systems easier to use and implement. Since not all of Fieldings constraints were seen as necessary for a particular application, people began referring to RESTful APIs as a way to distinguish between the theory and implementation of the pattern.

Over time, various web frameworks began to bake the principles of RESTful API design into their tooling and made it more straightforward for API developers to build well-designed application interfaces.

Good Design Matters

While some development frameworks are oriented toward RESTful design, RESTful API development requires planning for how your application will be built. An API designed according to the principles of REST can be built on any platform. These days, RESTful design revolves around four major design ideas. Let's take a look at each of them.

1. Use native HTTP methods.

Possibly the most universal aspect of any RESTful API is the decision to make use of HTTP methods for their defined purposes. If you need to retrieve information from an API, use GET. If you need to create a new resource, POST the representation of your resource to the API.

PUT and PATCH should be used to update existing resources either in their entirety or in part. DELETE is the right method, as you may guess, to delete a resource.

2. Make your endpoints descriptive.

Another important piece of RESTful design is to make the URL endpoints of your API descriptive of the things they work with. The /accounts endpoint should provide information about accounts whose records are stored in the application when sent a GET request, and a new account should be created when a valid representation of an account is POSTed to it.

This isn't to say that every API designed with RESTful principles needs an account system, but rather that it should be easily intuited what a developer might experience when interacting with a particular endpoint.

3. Provide parameters and good defaults.

While not essential to Fielding's conception of REST, a very commonand often expectedaspect of RESTful APIs today is the ability to filter, paginate, sort, or otherwise manipulate the data returned from an API. This is done with query parameters or custom headers. This sort of design decision helps with the adoption of your APIs, as it clarifies and simplifies the work of any developer hoping to consume your API.

4. Prioritize readable responses.

Another item that makes RESTful APIs a joy to use is an emphasis on readable responses and request bodies. While RESTful design doesn't require the use of a particular markup language or notation, the overwhelming majority of cases today use JSON. In fact, RESTful design is often seen as synonymous with the use of JSON.

Of course, you could continue to use XML or any other text-based communication method. However, if you advertise a RESTful API, it's important to make sure the data is easily accessibleboth for the systems ingesting it and the humans building those systems. The lightweight syntax of JSON makes this particularly easy, which is why it's often preferred.

Discoverability and Documentation

Following these principles of API design can certainly help with creating a usable API. However, alone they aren't enough to make sure your API is well adopted by developers interacting with it. Even though readability and intuitive navigation of your system is implied with RESTful design, it's important to make sure you provide great documentation as well.

The use of standard definitions such as OpenAPI can make your application much easier for developers to learn. Following good design practices also makes it easier to adopt readily available tools for writing your documentation. Be sure to lean into the virtuous cycle created by these tools and design principles.

Manage Change with API Versions

Even though delivering constant updates to your applications is likely, it's important to be careful about the changes you make to the design of your API. How one might indicate versions is a matter of debate, but what's not in question is that an API should have an indicator of what version a developer is using.

Whether developers access different versions of your API via the URL route, custom headers, or some other method, you should make sure your documentation is also versioned to match what they'll experience with each version of the API.

  • There's also no canonical method of determining version numbers, but Semantic Versioning (SemVer) is a frequently used numbering style that can be applied to API design just as much as to packaged software. SemVer dictates a version number of the format MAJOR.MINOR.PATCH. Here:The MAJOR number indicates versions that have breaking changes between them.
  • A MINOR number indicates new functionality added in a backward-compatible format as numbers increment.
  • Lastly, a PATCH number indicates bug fixes that add no new functionality.

Whether you use SemVer or just include a path to your v1 or v2 APIs, don't forget to version your API. It'll save people a lot of headaches as you improve and change your application.

Build with Security in Mind

Many aspects of API security are what you'd expect for any web application. Make sure to encrypt any traffic to your application with SSL/TLS. Require both API authentication and authorization to scope the data you're sharing with your clients so they only see or change what they're supposed to.

However, there are some aspects of API security that you might not think of when designing a standard web application. For example, a common mistake is to send authentication information as a URL query parameter or, even worse, in the actual URL path. The more secure alternative is to include authentication information in HTTP headers, which are unlikely to be logged, stored in browser history, or intercepted by middlemen (whether by accident or on purpose).

That said, it's still important to make sure you don't expose more information than you want to reveal in your headers or error messages. It can present a security risk to expose the language, framework, or web server that you're serving your application through. Some systems include these details by default in their responses, so make sure the things you're exposing in responses make sense for the environment in which they're being sent.

Practice Graceful Error handling

Just like with HTTP request methods, it's important to make sure you use HTTP response codes properly. Any developer consuming your API will expector at least hopeto see more than just a plain 200, 400, or 500 response.

Make sure the responses your application provides are enough for developers to know how to proceed as they build out great client applications for interacting with your system. This means including other information that may be helpful for troubleshooting any errors they run into as their applications interact with yours.

Conclusion

Remember, building a great RESTful API depends much more on the thought you put into the application design rather than on the implementation details. If you make sure your API is easy to discover and understand, that it uses standard HTTP methods and responses, and is well documented, then you will improve your chances of gaining wide adoption by developers hoping to build cool things based on your systems.

In case you're interested in learning more about RESTful APIs, be sure to check back later for an upcoming RESTful API tutorial!

API GatewayREST APIAPI DesignAPI Development

More on this topic

Videos

End-to-End Tracing with OpenTelemetry and Kong

Videos

Insomnia Overview: Collaborative API Development

See Kong in action

Accelerate deployments, reduce vulnerabilities, and gain real-time visibility. 

Get a Demo
Topics
API GatewayREST APIAPI DesignAPI Development
Share on Social
Kong

Recommended posts

GraphQL vs REST: Key Similarities and Differences Explained

Kong Logo
Learning CenterFebruary 28, 2025

Choosing the right API architecture is crucial for building efficient and scalable applications and the two prominent contenders in this arena are GraphQL and REST, each with its unique set of characteristics and benefits. Understanding the similari

Kong

What is GraphQL?

Kong Logo
Learning CenterMarch 1, 2023

Have you ever worked on app development projects before? If so, then chances are that you have come across the term “GraphQL.” However, what exactly does it entail? Is it utilized in server or client-side configuration? Furthermore, when would Integ

Kong

Building and Securing API Gateway Architecture

Kong Logo
Learning CenterMarch 10, 2022

As with all content accessed over the internet, APIs and API gateways are vulnerable to myriad threats if not properly secured. Without appropriate authentication and authorization in place, your application can be accessed by anyone who cares to lo

Kong

Configuring API Gateways for High Availability (HA) Clusters

Kong Logo
Learning CenterMarch 10, 2022

While an API gateway provides a single point of access for your applications APIs, that doesnt mean it should be a single point of failure. Just as the microservices that make up your application can be scaled according to demand, your API gateway n

Kong

What is Apache Kafka? Guide for Beginners

Kong Logo
Learning CenterDecember 8, 2025

Apache Kafka is a distributed, fault-tolerant, high-throughput event-streaming platform. LinkedIn originally developed it to handle massive data pipelines. The Apache Software Foundation now maintains this open-source project. The Commit Log Mental

Kong

API Gateway vs. AI Gateway

Kong Logo
Learning CenterNovember 3, 2025

The Gateway Evolution An unoptimized AI inference endpoint can burn through thousands of dollars in minutes. This isn't hyperbole. It's the new reality of artificial intelligence operations. When GPT-4 processes thousands of tokens per request, tradi

Kong

6 Reasons Why Kong Insomnia Is Developers' Preferred API Client

Kong Logo
EngineeringAugust 8, 2025

So, what exactly is Kong Insomnia? Kong Insomnia is your all-in-one platform for designing, testing, debugging, and shipping APIs at speed. Built for developers who need power without bloat, Insomnia helps you move fast whether you’re working solo,

Juhi Singh

Ready to see Kong in action?

Get a personalized walkthrough of Kong's platform tailored to your architecture, use cases, and scale requirements.

Get a Demo
Powering the API world

Increase developer productivity, security, and performance at scale with the unified platform for API management, AI gateways, service mesh, and ingress controller.

Sign up for Kong newsletter

    • Platform
    • Kong Konnect
    • Kong Gateway
    • Kong AI Gateway
    • Kong Insomnia
    • Developer Portal
    • Gateway Manager
    • Cloud Gateway
    • Get a Demo
    • Explore More
    • Open Banking API Solutions
    • API Governance Solutions
    • Istio API Gateway Integration
    • Kubernetes API Management
    • API Gateway: Build vs Buy
    • Kong vs Postman
    • Kong vs MuleSoft
    • Kong vs Apigee
    • Documentation
    • Kong Konnect Docs
    • Kong Gateway Docs
    • Kong Mesh Docs
    • Kong AI Gateway
    • Kong Insomnia Docs
    • Kong Plugin Hub
    • Open Source
    • Kong Gateway
    • Kuma
    • Insomnia
    • Kong Community
    • Company
    • About Kong
    • Customers
    • Careers
    • Press
    • Events
    • Contact
    • Pricing
  • Terms
  • Privacy
  • Trust and Compliance
  • © Kong Inc. 2025