Quick Start
Setting up your projectCopied!
Start by creating a folder and initializing an npm package within it with npm init.
mkdir my-rapid-todo-api && cd my-rapid-todo-api
npm init
Then install the @rapid-api/rapid-ts package
npm i @rapid-api/rapid-ts
Create the rapid-apiCopied!
In this example, we create the most minimal API possible. You can explore the other documentation to discover all useful configurations and additional details.
Create the config objectCopied!
First, create a variable to hold the configuration. For the minimal setup, we need to specify a name for the API.
Next, define the endpoints you want to include. We start with a single endpoint named "todo", which automatically provides four functional methods: GET, POST, PUT, and DELETE. Additionally, there are two more methods available—you can learn more about them in the Configuration Documentation.
Finally, define an object reference to enable automatic validation for the API. The types are specified using strings, but there are also other types available, including arrays and objects. For more details, refer to the Types Documentation.
const options = {
name: "todo-api",
endpoints: [
{
name: "todo",
methods: [
"GET",
"POST",
"PUT",
"DELETE"
],
objectReference: {
title: "string",
description: "string",
done: "boolean"
}
}
]
}
Start the rapid serverCopied!
With your config you can now create a RapidServer instance and call the start() function.
import { RapidServer} from '@rapid-api/rapid-ts';
const rapidServer = new RapidServer(options); // Your options variable
rapidServer.start();
Use the APICopied!
Rapid-TS includes a built-in API Specification Generator that locally hosts a Scalar Documentation. This allows you to view all generated API endpoints and make requests directly within your web browser.
How to continue from here?Copied!
You can now explore the following pages to learn more detailed information on specific topics.