Skip to content

Commit ea113a6

Browse files
vkop007jackwener
andauthored
feat(devto): add devto adapter (#234)
* feat(devto): add devto adapter * refactor(devto): improve adapters to match project conventions - Make tag/username args positional for natural CLI usage: opencli devto tag javascript (instead of --tag javascript) opencli devto user ben (instead of --username ben) - Add rank field (index + 1) matching hackernews/lobsters pattern - Add tags field from tag_list for richer output - Remove redundant author column from user command (already filtering by user) - Use type: str (project convention) instead of type: string - Increase default limit from 10 to 20 (matching other adapters) - Update docs with positional arg examples --------- Co-authored-by: jackwener <jakevingoo@gmail.com>
1 parent a439286 commit ea113a6

File tree

8 files changed

+135
-0
lines changed

8 files changed

+135
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ Run `opencli list` for the live registry.
141141
| **bbc** | `news` | Public |
142142
| **bloomberg** | `main` `markets` `economics` `industries` `tech` `politics` `businessweek` `opinions` `feeds` `news` | Public / Browser |
143143
| **ctrip** | `search` | Browser |
144+
| **devto** | `top` `tag` `user` | Public |
144145
| **arxiv** | `search` `paper` | Public |
145146
| **wikipedia** | `search` `summary` | Public |
146147
| **hackernews** | `top` | Public |

README.zh-CN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ npm install -g @jackwener/opencli@latest
142142
| **bbc** | `news` | 公共 API |
143143
| **bloomberg** | `main` `markets` `economics` `industries` `tech` `politics` `businessweek` `opinions` `feeds` `news` | 公共 API / 浏览器 |
144144
| **ctrip** | `search` | 浏览器 |
145+
| **devto** | `top` `tag` `user` | 公开 |
145146
| **arxiv** | `search` `paper` | 公开 |
146147
| **wikipedia** | `search` `summary` | 公开 |
147148
| **hackernews** | `top` | 公共 API |

docs/.vitepress/config.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export default defineConfig({
7878
collapsed: false,
7979
items: [
8080
{ text: 'HackerNews', link: '/adapters/browser/hackernews' },
81+
{ text: 'Dev.to', link: '/adapters/browser/devto' },
8182
{ text: 'BBC', link: '/adapters/browser/bbc' },
8283
{ text: 'Apple Podcasts', link: '/adapters/browser/apple-podcasts' },
8384
{ text: 'Xiaoyuzhou', link: '/adapters/browser/xiaoyuzhou' },

docs/adapters/browser/devto.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Dev.to
2+
3+
**Mode**: 🌐 Public · **Domain**: `dev.to`
4+
5+
Fetch the latest and greatest developer articles from the DEV community without needing an API key.
6+
7+
## Commands
8+
9+
| Command | Description |
10+
|---------|-------------|
11+
| `opencli devto top` | Top DEV.to articles of the day |
12+
| `opencli devto tag` | Latest articles for a specific tag |
13+
| `opencli devto user` | Recent articles from a specific user |
14+
15+
## Usage Examples
16+
17+
```bash
18+
# Top articles today
19+
opencli devto top --limit 5
20+
21+
# Articles by tag (positional argument)
22+
opencli devto tag javascript
23+
opencli devto tag python --limit 20
24+
25+
# Articles by a specific author
26+
opencli devto user ben
27+
opencli devto user thepracticaldev --limit 5
28+
29+
# JSON output
30+
opencli devto top -f json
31+
```
32+
33+
## Prerequisites
34+
35+
- No browser required — uses the public DEV.to API

docs/adapters/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Run `opencli list` for the live registry.
3535
|------|----------|------|
3636
| **[hackernews](/adapters/browser/hackernews)** | `top` | 🌐 Public |
3737
| **[bbc](/adapters/browser/bbc)** | `news` | 🌐 Public |
38+
| **[devto](/adapters/browser/devto)** | `top` `tag` `user` | 🌐 Public |
3839
| **[apple-podcasts](/adapters/browser/apple-podcasts)** | `search` `episodes` `top` | 🌐 Public |
3940
| **[xiaoyuzhou](/adapters/browser/xiaoyuzhou)** | `podcast` `podcast-episodes` `episode` | 🌐 Public |
4041
| **[yahoo-finance](/adapters/browser/yahoo-finance)** | `quote` | 🌐 Public |

src/clis/devto/tag.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
site: devto
2+
name: tag
3+
description: Latest DEV.to articles for a specific tag
4+
domain: dev.to
5+
strategy: public
6+
browser: false
7+
8+
args:
9+
tag:
10+
type: str
11+
required: true
12+
positional: true
13+
description: "Tag name (e.g. javascript, python, webdev)"
14+
limit:
15+
type: int
16+
default: 20
17+
description: Number of articles
18+
19+
pipeline:
20+
- fetch:
21+
url: https://dev.to/api/articles?tag=${{ args.tag }}&per_page=${{ args.limit }}
22+
23+
- map:
24+
rank: ${{ index + 1 }}
25+
title: ${{ item.title }}
26+
author: ${{ item.user.username }}
27+
reactions: ${{ item.public_reactions_count }}
28+
comments: ${{ item.comments_count }}
29+
tags: ${{ item.tag_list | join(', ') }}
30+
url: ${{ item.url }}
31+
32+
- limit: ${{ args.limit }}
33+
34+
columns: [rank, title, author, reactions, comments, tags]

src/clis/devto/top.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
site: devto
2+
name: top
3+
description: Top DEV.to articles of the day
4+
domain: dev.to
5+
strategy: public
6+
browser: false
7+
8+
args:
9+
limit:
10+
type: int
11+
default: 20
12+
description: Number of articles
13+
14+
pipeline:
15+
- fetch:
16+
url: https://dev.to/api/articles?top=1&per_page=${{ args.limit }}
17+
18+
- map:
19+
rank: ${{ index + 1 }}
20+
title: ${{ item.title }}
21+
author: ${{ item.user.username }}
22+
reactions: ${{ item.public_reactions_count }}
23+
comments: ${{ item.comments_count }}
24+
tags: ${{ item.tag_list | join(', ') }}
25+
url: ${{ item.url }}
26+
27+
- limit: ${{ args.limit }}
28+
29+
columns: [rank, title, author, reactions, comments, tags]

src/clis/devto/user.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
site: devto
2+
name: user
3+
description: Recent DEV.to articles from a specific user
4+
domain: dev.to
5+
strategy: public
6+
browser: false
7+
8+
args:
9+
username:
10+
type: str
11+
required: true
12+
positional: true
13+
description: "DEV.to username (e.g. ben, thepracticaldev)"
14+
limit:
15+
type: int
16+
default: 20
17+
description: Number of articles
18+
19+
pipeline:
20+
- fetch:
21+
url: https://dev.to/api/articles?username=${{ args.username }}&per_page=${{ args.limit }}
22+
23+
- map:
24+
rank: ${{ index + 1 }}
25+
title: ${{ item.title }}
26+
reactions: ${{ item.public_reactions_count }}
27+
comments: ${{ item.comments_count }}
28+
tags: ${{ item.tag_list | join(', ') }}
29+
url: ${{ item.url }}
30+
31+
- limit: ${{ args.limit }}
32+
33+
columns: [rank, title, reactions, comments, tags]

0 commit comments

Comments
 (0)