<rss version="2.0">
  <channel>
    <title>Meet Gor - Tag: curl</title>
    <link>https://www.meetgor.com</link>
    <description>Posts tagged with curl</description>
    <language>en-us</language>
    <pubDate>Sat, 10 Oct 2026 09:08:39 UTC</pubDate>
    <item>
      <title>LibSQL: Query a remote Turso database with cURL</title>
      <link>https://www.meetgor.com/til/libsql-query-remote-db</link>
      <description>Querying a libsql database hosted on turso with cURL. Using a remote sqlite-like db with turso api to query data.</description>
      <pubDate>Wed, 15 Nov 2023 00:00:00 UTC</pubDate>
      <content>If you are using a local [libsql](https://turso.tech/libsql) database, it is quite easy to query the database, but for a remote or a database on a hosted cloud platform like [turso](https://turso.tech/), we can use other clients or the api itself to query the data.&#xA;&#xA;We can use the turso cli to get the authentication token for the database and then query the database.&#xA;&#xA;## Turso CLI&#xA;&#xA;Using the [turso-cli](https://docs.turso.tech/reference/turso-cli) to access the turso platform. We will use turso cli to create a libsql database, create authentication tokens, and query the db.&#xA;&#xA;### Create a database (it&#39;s optional, you might already have a database)&#xA;&#xA;```bash&#xA;turso db create&#xA;```&#xA;&#xA;You will get a database on the turso cloud platform with some random interesting name like a passphrase.&#xA;&#xA;Use the command `turso db list` and copy the URL&#xA;&#xA;```graphql&#xA;DB_URL=dbname-orgname.turso.io&#xA;```&#xA;&#xA;### Create an authentication token for a particular database&#xA;&#xA;```bash&#xA;turso db tokens create db_name&#xA;```&#xA;&#xA;Copy the JWT token and this will be used as a authentication token when accessing the remote database in the turso cloud.&#xA;&#xA;```bash&#xA;TOKEN=abcdef.12345.wxyz&#xA;DB_URL=dbname-orgname.turso.io&#xA;```&#xA;&#xA;* Querying the database using curl or other [api clients](https://docs.turso.tech/libsql/client-access)&#xA;    &#xA;&#xA;```bash&#xA;curl -s -H &#34;Authorization: bearer $TOKEN&#34; \&#xA;     -d &#39;{&#34;statements&#34;: [&#34;SELECT name FROM sqlite_master WHERE type=\&#34;table\&#34;;&#34;]}&#39; \&#xA;     $DB_URL&#xA;```&#xA;&#xA;We can use `curl` or any api client tools to send queries to the database hosted on the turso platform. We need to provide the JWT token in the `Authorization` header to connect to that particular database. The request&#39;s body is a JSON string with a list of statements to query the database.&#xA;&#xA;```graphql&#xA;[&#xA;    {&#xA;        &#34;results&#34;:&#xA;            {&#xA;                &#34;columns&#34;: [&#34;name&#34;],&#xA;                &#34;rows&#34;:[&#xA;                    [&#34;libsql_wasm_func_table&#34;], [&#34;_litestream_seq&#34;], [&#34;_litestream_lock&#34;], [&#34;sqlite_sequence&#34;], [&#34;user&#34;]&#xA;                ]&#xA;            }&#xA;     }&#xA;]&#xA;```&#xA;&#xA;The result is a list of key-value pairs as `columns` and `rows` for each of the statements in the body. The columns are a list of column names requested in the query, and the rows are a list of rows where each row is a list of field values from the query.</content>
      <type>til</type>
    </item>
    <item>
      <title>Basics of curl command</title>
      <link>https://www.meetgor.com/posts/curl-basics</link>
      <description>Introduction We all might have used the curl command but might be unaware of it. It&#39;s super old and still serves a great purpose. It has been available since 19</description>
      <pubDate>Fri, 05 Nov 2021 00:00:00 UTC</pubDate>
      <content>## Introduction&#xA;&#xA;We all might have used the curl command but might be unaware of it. It&#39;s super old&#xA;and still serves a great purpose. It has been available since 1996 and still is&#xA;widely used in many embedded technologies, web API testing, CLI applications,&#xA;etc. In this article, we&#39;ll see some basics of using the curl command along with&#xA;its applications.&#xA;&#xA;## What is the curl command?&#xA;&#xA;Curl or cURL command is the utility or tool to access the internet from the command&#xA;line interface using various protocols. This looks trivial but it can blow up&#xA;your mind! Most people use this tool for fetching and processing the&#xA;data from the servers/internet from their terminal without the browser but&#xA;there is a lot more to it. It is used in various embedded devices for accessing&#xA;the network in a lightweight and accessible way. Let&#39;s see how you can use the curl&#xA;command from the very basics.&#xA;&#xA;&#xA;## Why do we need it?&#xA;&#xA;Before we talk about how to use the curl command let&#39;s talk about why might we need&#xA;that? There are a lot of reasons and it even depends on the application you are&#xA;using.  You can use curl to test your API, well there are other tools like&#xA;POSTMAN, Insomnia, etc but for keeping things simple you can quickly get in&#xA;with curl and test some endpoints.  You might require curl for creating some&#xA;CLI applications that require fetching/posting to an URL over the internet.&#xA;If you are using the terminal, curl integrates really very well with the shell&#xA;programming languages like BASH, ZSH, etc So, after making WHY out of the way,&#xA;let&#39;s start with the actual content. &#xA;&#xA;&#xA;## Structure of curl command&#xA;&#xA;**curl or Client URL is a command-line utility that helps in accessing/posting&#xA;data with various protocols over the internet.** It basically serves as a&#xA;bare-bones browser URL search bar.  You can&#39;t render those pages like the&#xA;actual GUI, and all but you can get is the HTML source code, JSON response,&#xA;etc.  That&#39;s still quite powerful and used in tons of applications. &#xA;&#xA;```&#xA;curl URL arguments &#xA;```&#xA;&#xA;The above is a basic structure of the curl command. We see the argument&#xA;structure in-depth in the next section. Firstly, let&#39;s take a simple curl command with just the URL is given.&#xA;&#xA;```bash&#xA;curl &#34;https://github.com&#34;   &#xA;```&#xA;From this query to `github.com`, you are literally going to `GitHub.com` and getting a response as the entire HTML source code of the page.&#xA;If you don&#39;t want to spam the output in the terminal, you can redirect the output to a file.&#xA;&#xA;```bash&#xA;curl &#34;https://github.com&#34; &gt;temp.html&#xA;```&#xA;With this command, we store the output of the command in the file temp.html, it can be any other file you like. &#xA;&#xA;### Arguments &#xA;&#xA;It turns out that you can even parse in certain arguments to the `curl` command to get some desired and modified results. Let&#39;s take a look at some of them.&#xA;The [entire list of arguments](https://curl.se/docs/manpage.html) is quite huge&#xA;and baffling, but this shows how customizable the command is. &#xA;&#xA;- `-s` (silent the progress bar)&#xA;- `-X` (web requests `POST, GET, etc` to the URL)&#xA;- `-o` (output to a file)&#xA;- `-H` ( provide Header to the request)&#xA;- `-d` (providing the data e.g. in POST request)&#xA;&#xA;```bash&#xA;curl -s -o &#34;https://github.com&#34; temp.html&#xA;```&#xA;&#xA;This command doesn&#39;t load the progress bar and simply outputs the response in a&#xA;file, making the execution process in the terminal clean.&#xA;&#xA;### Integration with other commands &#xA;&#xA;As said, the `curl` command can be well integrated with the other commands using piping in shell, assigning to variables, and so on.&#xA;&#xA;Let&#39;s see how we can convert the `JSON` response to a BASH variable.&#xA;&#xA;```bash&#xA;resp=$(curl -H &#34;api-key: N2vDzMyEeYGTxjUTePhC8bYd&#34; https://dev.to/api/users/me)&#xA;&#xA;echo $resp&#xA;```   &#xA;Here, we are fetching the `JSON` response from the `dev.to` [API](https://developers.forem.com/api/),The wired string `N2vDzMyEeYGTxjUTePhC8bYd` is my [dev.to API token](https://dev.to/settings/account)(don&#39;t worry I have revoked it:) ) we have provided an argument `-H` that is a Header for accepting a `Json` response. &#xA;We can store the contents of the curl command by using the `$( )` and assigning that to the variable name of your choice.&#xA;&#xA;```bash&#xA;username=$(curl -H &#34;api-key: N2vDzMyEeYGTxjUTePhC8bYd&#34; https://dev.to/api/users/me | grep -o -P &#39;(?&lt;=username&#34;:&#34;).*(?=&#34;,&#34;name)&#39;)&#xA;```&#xA;Here, we have stored the username from a `JSON` response to the variable username. We have piped the curl command so that we can work with that `JSON` response and modify the contents and then store the final results in a variable.&#xA;In this case, we are using `grep` to filter out the content between the key `username` and `name`, thus we get the value we desired. To see the value you can always run the echo command as below:&#xA;```bash&#xA;echo $username&#xA;```   &#xA;So, that&#39;s how the `curl` command integrates flawlessly with BASH and other shell programming languages. &#xA;&#xA;## Where is it used?&#xA;&#xA;`curl` is actually used in API testing, CLI applications, Web Scrapping, etc. It&#39;s a great tool for terminal lovers. Let&#39;s see where we can use the curl command actually to make some good projects.&#xA;&#xA;### API Testing&#xA;&#xA;We can use, `curl` to test an API, it might be API you would have made or to simply test and play with other API available publicly. You can get an in-depth guide about [Testing a REST API with curl](https://www.codepedia.org/ama/how-to-test-a-rest-api-from-command-line-with-curl/).&#xA;Actually, curl can do more than just testing, I have made a [bash script](https://gist.github.com/Mr-Destructive/80860664b1014ef0b94092d68ead1044) that actually posts some data over a database through the API so that I don&#39;t have to do that manually. That is the kind of automation I love to do and curl! Just did that.&#xA;&#xA;### Web Scrapping&#xA;&#xA;Web-scrapping is usually trending with Python, but I have done that with BASH.&#xA;That might be an outdated idea but is a good task to learn the basics of&#xA;Web-scrapping with BASH ;). I must say that sed, awk, grep are the tools are&#xA;powerful like heck in doing these tricks. I have made this&#xA;[crypto-currency](https://mr-destructive.github.io/techstructive-blog/bash/2021/07/15/BASH-Crypto-Coingecko.html)&#xA;and&#xA;[dictionary](https://mr-destructive.github.io/techstructive-blog/bash/2021/07/27/BASH-script-dictionary-scrap.html)&#xA;scrapper with BASH. Web-scrapping can be done with the curl command by fetching to&#xA;an API if any or any website. We need to search and find the particular fields,&#xA;classes, or ids the elements the required data might be into and then extract&#xA;and filter using the tools like grep, sed or awk.&#xA;&#xA;&#xA;### CLI Applications&#xA;&#xA;We can make CLI applications like creating a terminal view of existing&#xA;applications using their APIs or website. I recently made a CLI for&#xA;[cross-posting articles](https://github.com/Mr-Destructive/crossposter) to&#xA;dev. to, hashnode and medium. That is a project still in progress(tons of bugs)&#xA;but still serving a decent job. Definitely `curl` might not be the only command&#xA;that works here, but the project might look so incomplete without `curl`.&#xA;&#xA;**There might be other applications as well, who knows there is a lot to do with this command.** If you know one, please let everyone know in the comments.&#xA;&#xA;### References:&#xA;&#xA;Special Thanks to the creator of the curl command - [Magnus Daniel Stenberg](https://github.com/bagder) and the developers who are still contributing and maintaining the great project.&#xA; &#xA;### Conclusion&#xA;&#xA;So, from this article, we were able to understand the basics of the `curl` command and understand its applications in actual programming stuff. Hope you liked it. Thanks for reading and until then Happy Coding :)&#xA;</content>
      <type>posts</type>
    </item>
  </channel>
</rss>