<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/how-to-automatically-consume-restful-apis-in-your-frontend-kw0n8jxvw" -->

---
title: How to Automatically Consume RESTful APIs in Your Frontend
description: Automating the consumption of RESTful APIs in the frontend using Swagger and OpenAPI can significantly reduce boilerplate code, improve efficiency, and enhance...
canonical: https://daily.dev/posts/how-to-automatically-consume-restful-apis-in-your-frontend-kw0n8jxvw
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: How to Automatically Consume RESTful APIs in Your Frontend | daily.dev
og:description: Automating the consumption of RESTful APIs in the frontend using Swagger and OpenAPI can significantly reduce boilerplate code, improve efficiency, and enhance...
og:url: https://daily.dev/posts/how-to-automatically-consume-restful-apis-in-your-frontend-kw0n8jxvw
og:image: https://api.daily.dev/og/posts/kw0N8Jxvw.png
og:image:alt: How to Automatically Consume RESTful APIs in Your Frontend
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Automatically Consume RESTful APIs in Your Frontend

**[DEV](https://daily.dev/sources/devto)** · 10 min read · 59 upvotes · 1 comments

## Summary

Automating the consumption of RESTful APIs in the frontend using Swagger and OpenAPI can significantly reduce boilerplate code, improve efficiency, and enhance collaboration between frontend and backend teams.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://dev.to/vorillaz/how-to-automatically-consume-restful-apis-in-your-frontend-48ba>

## Community discussion

Top comments from developers on daily.dev.

**@kkurko** · 0 upvotes

> I work with OpenAPI and my current project, and our frontend setup includes [openapi-typescript](https://www.npmjs.com/package/openapi-typescript) and [openapi-typescript-fetch](https://www.npmjs.com/package/openapi-typescript-fetch). This setup requires more boilerplate, and you have to manually specify which endpoints you want to use:
> ```ts
> const API = {
>   getUsers: fetcherUserManagement
>     .path("/users")
>     .method("get")
>     .create(),
> }
> ```
>
> But this is what we wanted to have: our API is also available as an SDK, and there are many more endpoints available than our frontend needs, so...

---

Tags: [#react](https://daily.dev/tags/react), [#backend](https://daily.dev/tags/backend), [#automation](https://daily.dev/tags/automation), [#vuejs](https://daily.dev/tags/vuejs), [#openapi](https://daily.dev/tags/openapi), [#fastify](https://daily.dev/tags/fastify)

[View this post on daily.dev](https://daily.dev/posts/how-to-automatically-consume-restful-apis-in-your-frontend-kw0n8jxvw)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"How to Automatically Consume RESTful APIs in Your Frontend","url":"https://daily.dev/posts/how-to-automatically-consume-restful-apis-in-your-frontend-kw0n8jxvw","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/how-to-automatically-consume-restful-apis-in-your-frontend-kw0n8jxvw"},"datePublished":"2024-01-28T15:41:24.161Z","dateModified":"2024-05-09T08:58:27.770Z","description":"Automating the consumption of RESTful APIs in the frontend using Swagger and OpenAPI can significantly reduce boilerplate code, improve efficiency, and enhance...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/eb8e9c88559f4d7a630a09c4616a603b?_a=AQAEufR","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/eb8e9c88559f4d7a630a09c4616a603b?_a=AQAEufR","isAccessibleForFree":true,"articleSection":"DEV","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"DEV","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/devto","url":"https://daily.dev/sources/devto"},"commentCount":1,"discussionUrl":"https://daily.dev/posts/how-to-automatically-consume-restful-apis-in-your-frontend-kw0n8jxvw","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":59},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"keywords":"react,backend,automation,vuejs,openapi,fastify","timeRequired":"PT10M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"DEV","item":"https://daily.dev/sources/devto"},{"@type":"ListItem","position":3,"name":"How to Automatically Consume RESTful APIs in Your Frontend"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/how-to-automatically-consume-restful-apis-in-your-frontend-kw0n8jxvw","comment":[{"@type":"Comment","text":"I work with OpenAPI and my current project, and our frontend setup includes openapi-typescript and openapi-typescript-fetch. This setup requires more boilerplate, and you have to manually specify which endpoints you want to use:\nconst API = {\n  getUsers: fetcherUserManagement\n    .path(&quot;/users&quot;)\n    .method(&quot;get&quot;)\n    .create(),\n}\n\nBut this is what we wanted to have: our API is also available as an SDK, and there are many more endpoints available than our frontend needs, so this is how we control what is actually used.\nWhat I learned from this article is that you can generate zod schemas from an OpenAPI definition (and this may be a good reason to finally switch from yup to zod)","datePublished":"2024-01-29T08:52:05.838Z","url":"https://daily.dev/posts/kw0N8Jxvw#c-ROuh2l5n7","author":{"@type":"Person","name":"Kirill Kurko","url":"https://daily.dev/kkurko","image":"https://avatars.githubusercontent.com/u/58859242?v=4"}}]}
```

