USE THE tRPC APIs by clicking on Routes
FetchBox

tRPC

tRPC (Type-safe Remote Procedure Call) is a modern framework for building APIs that prioritizes type safety and ease of use. It ensures that the communication between server and client is type-safe, meaning that the data structures and functions used are explicitly defined and enforced, reducing the risk of runtime errors. tRPC simplifies the development process by generating TypeScript types on the client side based on the server-defined API, enabling seamless and error-resistant communication. With a focus on developer ergonomics, tRPC aims to make API development robust and efficient, allowing developers to work confidently and effectively across different parts of the application.

Base Address

BA https://web-api-azure.vercel.app Base

Demo Page for tRPC : /trpc/example

CRUD

Your can perform the basic CRUD operations on this route. It operates on the tables present on our mongoDB server.

Schema

As stored in MongoDB. Here "_id" and "__v" are the fields which are filled by mongoDB itself

ID : Number

Name : String

Github : String

_id : String

__v : String

Routes

GET
1 2 const { data: crudReadData, error: crudReadError } = trpc.crudRead.useQuery();
POST
1 2 3 4 5 6 const createMutation = trpc.crudCreate.useMutation(); createMutation.mutate({ id: 1, name: "New Item", github: "new-item", })
PUT
1 2 3 4 5 6 const updateMutation = trpc.crudUpdate.useMutation(); updateMutation.mutate({ id: crudReadData?.data.slice(-1)[0]._id, name: "Updated Item", github: "updated-item", })
DELETE
1 2 3 4 const deleteMutation = trpc.crudDelete.useMutation(); deleteMutation.mutate({ id: crudReadData?.data.slice(-1)[0]._id, })

NEWS

You can get 2 types of news on the same route using query params used in REST APIs

Unfiltered News

You can get high amount of NEWS, which are not filtered based on the fields related

GET
1 2 const { data: newsData, error: newsError } = trpc.news.useQuery({ type: 'all' });

Filtered News

You can get hundred of NEWS, which are filtered based on the fields related

GET
1 2 const { data: sportsNewsData, error: sportsNewsError } = trpc.news.useQuery({ type: "sports" });
Parameters given to "type" query :

1. all

2. general

3. entertainment

4. business

5. health

6. science

7. sports

8. technology

Movie

You can get movie data for your movie projects!

Route

You can get high quality data for Movies.

GET
1 2 const { data: movieData, error: movieError } = trpc.movie.useQuery();

Anime

You can get Anime data for your Anime realted projects!

Route

You can get high quality data for Animes.

GET
1 2 const { data: animeData, error: animeError } = trpc.anime.useQuery();

Manga

You can get Manga data for your Manga realted projects!

Route

You can get high quality data for Manga.

GET
1 2 const { data: mangaData, error: mangaError } = trpc.manga.useQuery();

Advantages

of tRPC

Type Safety: : Ensures type safety in communication between server and client, reducing the likelihood of runtime errors.

Automatic TypeScript Generation : Automatically generates TypeScript types on the client side based on the server-defined API, enhancing development efficiency.

Developer-Friendly : Prioritizes developer ergonomics, making it easy to work with and understand, leading to faster development cycles.

Simplified Communication : Simplifies API development by eliminating the need for manual type mappings and reducing boilerplate code.

Robustness : Enhances robustness by enforcing a strict contract between the server and client, reducing the chances of miscommunications.

Disadvantages

of tRPC

Learning Curve: As with any new technology, there might be a learning curve for developers unfamiliar with tRPC.

Limited Ecosystem: Depending on the adoption rate, there might be a limited ecosystem and community support compared to more established frameworks.

Flexibility Trade-off: While type safety is a significant advantage, it might limit the flexibility in certain scenarios where dynamic typing is preferred.

Potential Overhead: Depending on the use case, the automatic generation of TypeScript types might introduce some overhead in terms of file size.

Potential Overhead: As tRPC heavily relies on TypeScript, projects not using TypeScript might find it less suitable.