RapidAPI Profile picture
Mar 2 β€’ 21 tweets β€’ 6 min read
Building an API is not difficult as it sounds.

Let's create a quick number API using which we can fetch even, odd, and prime numbers.

Thread πŸ§΅πŸ‘‡πŸ»
Prerequisite:

We are assuming you have Node.js installed on your machine. If you haven't installed it, click on the following link and install it simply.

nodejs.org/en/
Let's start with creating an empty directory and initializing the project by running the following command. Creating an empty directory...
The next step is to create an empty JavaScript file (File name could be anything, in this case, it's index.js) and install Express.

πŸ”— npmjs.com/package/express

Express is a minimal and easy-to-learn framework for Node. Install express package.
Now that everything is ready, let's require express to initialize the app and start the local server at port 3000. Require express to initiali...
For more context, the listen() function establishes the connection on a specified host or port.

It takes two params:

- The first is the port number or host.

- The second (optional) is a callback function that runs after listening to a specified host or value.
It's not recommended that you use the browser to build or debug APIs due to security reasons.

We prefer Paw, a full-featured HTTP client.

Go ahead and download it.

πŸ”— Paw.cloud
Let's create the first endpoint for even numbers.

We will be making a GET request to a particular route and it should return all the even numbers present in the database.
For demo purposes, we have a hard-coded array instead of any database.

But you can fetch data dynamically from any DB.
The `get` method allows us to create HTTP GET requests.

It accepts two params:

- The first is path/route.

- The second is a callback function that handles the request to the specified route. `get` method takes two para...
The callback function itself accepts two arguments:

- The first is the request which is the data to the server.

- The second is the response which is the data to the client. The callback function takes...
We want the server to return all the even numbers when the client access the "/evens" endpoint.

Here's how we can do it. πŸ‘‡πŸ» Get even numbers using &quo...
In the above code snippet, `numbers` is nothing but a hard-coded array containing numbers from 1 to 20.

You fetch data from any database as well. Number array.
Perfect!

Let's restart the server by running the `node index.js` command and see what we are getting in the Paw. Accessing "/evens"...
As you can see in the above screenshot we are getting all the even numbers present in the database (numbers array).
Using the same technique, we can create as many endpoints as we want.

Let's quickly create the endpoint for getting odd and prime numbers as well.
Check out the below code snippet for the "/odds" endpoint. Get odd numbers using the &...Response of "/odds&quo...
Similarly, we can create an endpoint for fetching prime numbers. Get odd numbers using the &...Response of "/primes&q...
You can build excellent APIs and publish them on RapidAPI Hub.

rapidapi.com/learn/hub/prov…
RapidAPI makes your API accessible to over 3 million developers and gives you the option to make passive income.
And with that being said, we hope you like this thread.

Follow @Rapid_API to keep up with the great API-related content. πŸ’™πŸ™

β€’ β€’ β€’

Missing some Tweet in this thread? You can try to force a refresh
γ€€

Keep Current with RapidAPI

RapidAPI Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @Rapid_API

Mar 3
A brief introduction to ten widely used HTTP Headers.

A Thread πŸ§΅πŸ‘‡πŸ»
In this thread, we are going to discuss:

β€’ Accept
β€’ Accept-Encoding
β€’ Authorization
β€’ Accept-Language
β€’ Content-Type
β€’ Content-Location
β€’ Content-Encoding
β€’ Content-Length
β€’ Content-Language
β€’ Cache-Control
Client and server can pass the extra bit of information with the request and response using HTTP headers.

HTTP headers are not case-sensitive.
Read 15 tweets
Mar 3
Top ten Food APIs you can use in your next project.

A Thread πŸ§΅πŸ‘‡πŸ»
1️⃣ Recipe-Food-Nutrition

Over 365,000 recipes and 86,000 food products. Analyze food images by uploading a file or by a given URL.

πŸ”— RapidAPI.com/spoonacular/ap…
2️⃣ Tasty

Use the Tasty API to get data about recipes, ingredients, nutrition, and much more. You can also filter recipes according to the time they take.

πŸ”— RapidAPI.com/apidojo/api/ta…
Read 12 tweets
Mar 2
Top ten Facial Recognition APIs.

Thread πŸ§΅πŸ‘‡πŸ»
1️⃣ Mirror-AI

Upload photos and get personalized avatars and emojis for your users.

πŸ”— RapidAPI.com/mirror-dev-tea…
2️⃣ Face Detection

Use Face Detection API to detect the location of human faces in your images with optional extra features like Age and Gender.

πŸ”— RapidAPI.com/inferdo/api/fa…
Read 12 tweets
Mar 1
Everything you need to know about SOAP API.

Thread πŸ§΅πŸ‘‡πŸ»
SOAP is a necessary protocol that helped introduce the widespread use of APIs.

SOAP is the acronym for Simple Object Access Protocol.
SOAP is a standardized protocol that relies on XML to make requests and receive responses.

Even though SOAP is based on XML, the SOAP protocol is still in wide usage.
Read 18 tweets
Mar 1
Anatomy of an API endpoint.

Thread πŸ§΅πŸ‘‡πŸ»
Before breaking the endpoints into multiple parts. Let's first see what exactly is an endpoint.

The endpoint is nothing but the URL to access resources.

Every API must have at least one endpoint.
A typical endpoint or URL starts with the scheme.

Scheme is nothing but the protocol for APIs.

For example, HTTPS, HTTP, FTP, SSL, etc. Anatomy of an endpoint showing scheme.
Read 10 tweets
Mar 1
Bitcoin, Blockchain, and Cryptocurrency cover a large portion of Web 3.0.

Here are the top five APIs that can make Web 3.0 more accessible and manageable. πŸš€

Thread πŸ§΅πŸ‘‡πŸ»
1️⃣ BraveNewCoin

BraveNewCoin API provides the latest and historical cryptocurrency market data. This API has several endpoints which you can choose from.

πŸ”— RapidAPI.com/BraveNewCoin/a…
2️⃣ Blockchain Data

Gives access to more than 20 blockchains: blocks, transactions, transfers, smart contracts, and tokens.

πŸ”— RapidAPI.com/bitquery-bitqu…
Read 7 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(