Rapid Profile picture
Feb 28, 2023 10 tweets 3 min read Read on X
How to use cURL with APIs.

Thread 🧵
cURL is a command line tool for transferring data specified with URL syntax.

cURL supports a wide variety of protocols, including HTTP, HTTPS, FTP, FTPS, SFTP, SMB, TELNET, DICT, LDAP, LDAPS, FILE, IMAP, SMTP, POP3, RTSP, and RTMP.
cURL also supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading, Kerberos, HTTP form-based upload, proxies, and cookies.

Curl offers a wide range of options (over 200) to customize your commands.
It's always good to set the verbose mode on when testing.

We can set verbose "on" with "-v" command.

The command provides vital information such as:

- the resolved IP address
- the port we're trying to connect to
- headers
cURL's default behavior is to output the response body to standard output.

However, the output can be redirected to a file using the output option.

For this, we'll use the "-o" command.

What we can see here is the classic GET request.
If we want to perform a POST request, we must specify the data we want to send to the API.

This can be done with the "-d" command.

For this purpose, we're using variable name/value pairs concatenated with "&."
If you prefer to define your payload in the file, you can do so by using the example below.

As you can see, we're specifying the header with the "-H" command so the server can understand the payload is in JSON format.
Below you can see how to perform a PUT request.

We're using the "-X" command that allows specifying the method. In our case, it's "PUT."
For DELETE, we're using the "-X" command again with the "DELETE" specified for the method.
That’s all for now!

Follow @Rapid_API for more exclusive content. 🐙

• • •

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

Keep Current with Rapid

Rapid 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

Apr 24, 2023
Common REST API challenges.

A thread 🧵
REST APIs adhere to REST(Representational State Transfer) architecture, which comprises several rules that define scalable and lightweight API design.

Here are the biggest challenges faced when working with them 👇
1️⃣ Security

APIs are integral to businesses on today’s web and require protection from attackers.

Security methods include encryption, API Keys, OAuth, input validation, error handling, and more.

Security is a deep topic. Check out the OWASP API security guides to know more.
Read 7 tweets
Apr 24, 2023
HTTP headers for CORS explained.

A thread 🧵👇
Let's start with HTTP request headers:

📌 Origin

The browser adds this header to CORS requests to indicate the origin domain.
📌 Access-Control-Request-Method

Specific CORS requests that affect user data will initiate with a preflight request. This header is added to the preflight to indicate the method used in the main request. For example:

Access-Control-Request-Method: PUT
Read 10 tweets
Apr 24, 2023
10 HTTP headers that developers should be aware of.

Thread🧵👇
1️⃣ Accept

A client-side header that defines the type of data the client expects from the server.

This means the server won’t waste time returning a data type the client cannot use.
2️⃣ Authorization

A client-side header that passes the credentials to the server.

This is not the same as authentication. The server can only authenticate the user after it checks the authorization credentials.
Read 12 tweets
Apr 21, 2023
API. What is it?

- What is an API
- Usage of APIs
- Types of APIs
- Benefits of APIs

Thread 🧵👇
📌 Application Programming Interface (API)

APIs are a set of protocols, routines, and tools that enable software to communicate with each other.

They allow developers to access and use the functionality of another system without having to understand its inner workings.
For example, when you use a weather app on your phone, it likely relies on an API to retrieve data from a weather service.

The app developers don't need to know how the weather service works internally. They just need to use its API to get the data they need.
Read 8 tweets
Apr 21, 2023
What is the difference between URI, URL, and URN?

A Thread 🧵👇
📌 URI

URL (Uniform Resource Identifier) is a unique string of characters used to identify resources on the web.

Typical URIs contain various elements such as a path, authority, query, and fragment. They are structured like this:

scheme:[//authority]path[?query][# fragment]
URIs are only able to identify resources on the internet and not locate them.

Because of this, they are not seen very frequently on the web.
Read 10 tweets
Apr 21, 2023
What is an API?

Thread 🧵👇

{ 1 / 5 } What is an API?
{ 2 / 5 } The API call is initiated. ...
{ 3 / 5 } Our worker ant acts like an...
Read 6 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!

:(