Devcli - A CLI for Dev.to!
Tags: cli, devapp, api, showdev
Published: 2024-02-16 22:40:22

## Introduction

I made a CLI app for Dev.to! I personally really like terminals, so I decided to make a CLI app so that I can read and reply to Dev articles.

This article was written because of [this comment](https://dev.to/michaeltharrington/comment/2d19b). Thanks @michaeltharrington! :smile:

<sub>Unfortunately, at the time of this article, the "write an article" feature didn't work, so I had to handwrite this.</sub>

## What it does

So far, you can use devcli (very unoriginal name, I know) to...

* read articles (and read the comments, too!)
* view a list of your followers
* view the 30 latest articles
* display information about a user
* see the tags that you follow
* view your [reading list](https://dev.to/readinglist)

If you have any new feature ideas, you can comment on this article or [open an issue](https://github.com/Kaamkiya/devcli/issues/new/choose) in the [repo](https://github.com/Kaamkiya/devcli) :grinning:

## Using devcli

You can install it by following the instructions for your platform in the [install guide](https://codeberg.org/Kaamkiya/devcli), or just type the command below:

```bash
go install github.com/Kaamkiya/devcli
```

Beware that the command above requires [Go](https://go.dev/dl). If you only want the binary for your platform, follow the [instructions](https://codeberg.org/Kaamkiya/devcli#readme).

Make sure the binary is in your `$PATH` variable. 

You can add it like this:

```bash
export PATH="$PATH:$(go env GOPATH)" # if you used Go to install
export PATH="$PATH:/path/to/download" # if you installed the platform-specific binary
```

Now, if you really want, you can read this article from the terminal :smile:

```bash
devcli read kaamkiya/devcli-a-cli-for-devto-5gcb
```

Otherwise, keep going!

## API Keys and user-specific commands

Some commands require an API key. Here's how to get one:

Go to the [extensions page](https://dev.to/settings/extensions) of dev.to.

Scroll until you see this:

![API Keys](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2bjrwqo7ytuvcguw2rjc.png)

It should be somewhere near the bottom.

Enter a name for your API key. I recommend using `devcli auth`, because that way you know what the key is used for.

Press the big blue "Generate API key" button.

Scroll all the way back down, and click on the dropdown that says the name of your API key.

![API key dropdown](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1ik683dosrnecp6ldu7l.png)

Copy the key. It will be a long string of random characters.

Go to your terminal and type the following:

```bash
export DEV_API_KEY="whatever_you_copy_pasted"
```

**NOTE: Never share your API keys!**

Now you can run all of the commands. To check if it worked, try `devcli readinglist`. 

If it worked, your reading list has now been printed!

## Cheat sheet

Here's a quick cheat sheet of the currently available commands:

```bash
devcli read $article_id # read an article by ID
devcli read $author/$article_slug # read an article by author/slug

devcli user $username # display info about a user

devcli following-tags # requires an API key

devcli followers # requires an API key

devcli readinglist # requires an API key

devcli latest # print a list of the 30 most recent articles

devcli help # print a help message

# examples:
devcli read 1690174
devcli read 1690174 --show-comments # display the top-level comments as well
devcli user ben # show stuff about @ben
```

Feel free to contribute or try it out :smile:

Let me know what you think!

Any new feature ideas? Feedback? I'd love to see what you think!

EDIT: Moved to Codeberg.