@vibelyster/depop-cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +161 -0
- package/dist/cli.js +37 -0
- package/package.json +33 -0
package/README.md
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# @vibelyster/depop-cli
|
|
2
|
+
|
|
3
|
+
Proof-of-concept CLI for Depop's internal API. Uses [`impit`](https://github.com/apify/impit) to mimic Chrome TLS fingerprints and bypass Cloudflare bot detection.
|
|
4
|
+
|
|
5
|
+
Reverse-engineered from browser DevTools network traffic and verified against live API (2026-03-27). See [marketplace API research](../../docs/marketplace-api-research.md) for full technical details.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Quick Start
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# No install needed — run directly
|
|
13
|
+
node tools/depop/cli.js --help
|
|
14
|
+
|
|
15
|
+
# Or link globally
|
|
16
|
+
cd tools/depop && npm link
|
|
17
|
+
depop --help
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Authentication
|
|
23
|
+
|
|
24
|
+
Only the **bearer token** is required. User ID is auto-resolved from the API.
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Option 1: interactive login (saves to ~/.vibelyster/depop.json)
|
|
28
|
+
depop login
|
|
29
|
+
|
|
30
|
+
# Option 2: env var
|
|
31
|
+
export DEPOP_ACCESS_TOKEN="your-access-token"
|
|
32
|
+
|
|
33
|
+
# Option 3: per-command flag
|
|
34
|
+
depop auth --access-token "..."
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**To get your access token:**
|
|
38
|
+
1. Log into depop.com in your browser
|
|
39
|
+
2. Open DevTools → Application → Cookies → depop.com
|
|
40
|
+
3. Copy the `access_token` cookie value
|
|
41
|
+
|
|
42
|
+
> **Note:** Depop uses Cloudflare TLS fingerprinting (JA3/JA4) to block non-browser clients. This CLI uses `impit` (Rust-based Chrome TLS mimic) to bypass this — no real browser required.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Commands
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
depop login # Save your access token
|
|
50
|
+
depop auth # Check login status
|
|
51
|
+
depop logout # Remove saved credentials
|
|
52
|
+
depop listings # List your products
|
|
53
|
+
depop listing <slug> # Get product details
|
|
54
|
+
depop addresses # List shipping addresses
|
|
55
|
+
depop upload <image-path> # Upload a square image → {id, url}
|
|
56
|
+
depop create <json-file> # Create a draft listing
|
|
57
|
+
depop drafts # List draft listings
|
|
58
|
+
depop draft-update <id> <json-file> # Update a draft
|
|
59
|
+
depop draft-delete <id> # Delete a draft
|
|
60
|
+
depop edit <product-id> <json-file> # Edit a live product in-place
|
|
61
|
+
depop delete <product-id> # Delete a live product
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Listing Lifecycle
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
┌──────────────────────────────────────────────────────────────────┐
|
|
70
|
+
│ │
|
|
71
|
+
│ 1. Upload images depop upload ./photo.jpg │
|
|
72
|
+
│ └─ Two-step: POST JSON → presigned S3 URL → PUT image │
|
|
73
|
+
│ └─ Returns {id, url} │
|
|
74
|
+
│ └─ Images MUST be square (Depop rejects non-square) │
|
|
75
|
+
│ │
|
|
76
|
+
│ 2. Create draft depop create draft.json │
|
|
77
|
+
│ └─ POST /api/v2/drafts/ (direct POST to products fails) │
|
|
78
|
+
│ └─ Returns {id} (UUID) │
|
|
79
|
+
│ │
|
|
80
|
+
│ 3. Manage drafts depop drafts / draft-update / draft-del │
|
|
81
|
+
│ └─ GET/PUT /api/v2/drafts/ DELETE /api/v1/drafts/ │
|
|
82
|
+
│ │
|
|
83
|
+
│ 4. Publish Open draft in browser and click Post │
|
|
84
|
+
│ └─ depop.com/sellinghub/drafts/edit/<draft-id>/ │
|
|
85
|
+
│ └─ No API-only publish endpoint found yet │
|
|
86
|
+
│ │
|
|
87
|
+
│ 5. Edit live listing depop edit <id> updates.json │
|
|
88
|
+
│ └─ PUT /api/v2/products/<id>/ │
|
|
89
|
+
│ │
|
|
90
|
+
│ 6. Delete listing depop delete <id> │
|
|
91
|
+
│ └─ DELETE /api/v1/products/<id>/ (v1, not v2) │
|
|
92
|
+
│ │
|
|
93
|
+
└──────────────────────────────────────────────────────────────────┘
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Cloudflare TLS Bypass
|
|
99
|
+
|
|
100
|
+
Depop's API (`webapi.depop.com`) is behind Cloudflare which fingerprints the TLS handshake (JA3/JA4) to distinguish browsers from automated clients. Standard Node.js `fetch()` and `curl` are blocked with 403 regardless of headers or cookies.
|
|
101
|
+
|
|
102
|
+
**Solution:** [`impit`](https://github.com/apify/impit) — a Rust-based (`reqwest` + `napi-rs`) drop-in `fetch()` replacement that uses Chrome's cipher suites and TLS configuration. Zero npm dependencies, prebuilt native binaries, Apache-2.0 license.
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
Node.js fetch() → JA3: Node.js fingerprint → Cloudflare 403
|
|
106
|
+
impit.fetch() → JA3: Chrome fingerprint → Cloudflare 200
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Architecture
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
tools/depop/
|
|
115
|
+
├── cli.js CLI entry point (args, routing, output formatting)
|
|
116
|
+
├── depop-api.js API client (impit fetch, all endpoints)
|
|
117
|
+
├── README.md This file
|
|
118
|
+
├── package.json @vibelyster/depop-cli
|
|
119
|
+
└── examples/ Payload templates (TODO)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### API Auth Flow
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
access_token cookie from browser
|
|
126
|
+
↓
|
|
127
|
+
Authorization: Bearer <token>
|
|
128
|
+
↓
|
|
129
|
+
webapi.depop.com/api/* (via impit for TLS fingerprint)
|
|
130
|
+
↓
|
|
131
|
+
userId auto-resolved from /api/v1/addresses/
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### API Endpoints
|
|
135
|
+
|
|
136
|
+
| Method | Endpoint | Purpose |
|
|
137
|
+
|--------|----------|---------|
|
|
138
|
+
| GET | `/api/v1/sellerOnboarding/sellerStatus/` | Auth check + seller status |
|
|
139
|
+
| GET | `/api/v1/addresses/` | Shipping addresses (also returns userId) |
|
|
140
|
+
| GET | `/api/v3/shop/{userId}/products/` | User's listings |
|
|
141
|
+
| GET | `/api/v1/product/by-slug/{slug}/user/` | Product detail by slug |
|
|
142
|
+
| POST | `/api/v2/pictures/` | Presigned S3 URL for image upload |
|
|
143
|
+
| POST | `/api/v2/drafts/` | Create draft listing |
|
|
144
|
+
| GET | `/api/v2/drafts/` | List drafts |
|
|
145
|
+
| PUT | `/api/v2/drafts/{id}/` | Update draft |
|
|
146
|
+
| DELETE | `/api/v1/drafts/{id}/` | Delete draft (v1, not v2) |
|
|
147
|
+
| PUT | `/api/v2/products/{id}/` | Edit live product |
|
|
148
|
+
| DELETE | `/api/v1/products/{id}/` | Delete live product (v1, not v2) |
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Gotchas & Pitfalls
|
|
153
|
+
|
|
154
|
+
| Gotcha | Detail |
|
|
155
|
+
|--------|--------|
|
|
156
|
+
| **Images must be square** | Depop rejects non-square images. Crop before uploading. |
|
|
157
|
+
| **Product lookup uses slugs, not IDs** | `/api/v2/products/{slug}/` — get slugs from `depop listings` |
|
|
158
|
+
| **Cloudflare blocks Node.js fetch** | Must use `impit` or equivalent Chrome TLS fingerprint tool |
|
|
159
|
+
| **`depop-UserId` header is optional** | Bearer token alone identifies the user |
|
|
160
|
+
| **userId needed in listings URL** | `/api/v3/shop/{userId}/products/` — auto-resolved and cached |
|
|
161
|
+
| **esbuild can't bundle impit** | `impit` uses native binaries (napi-rs) — must be marked as external for bundling |
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{Impit as L}from"impit";var c="https://webapi.depop.com",v=new L({browser:"chrome"});function l(e){return{Accept:"*/*","Content-Type":"application/json",Authorization:`Bearer ${e}`,Origin:"https://www.depop.com",Referer:"https://www.depop.com/"}}async function d(e,t={}){let r=await v.fetch(e,t);if(!r.ok){let o=await r.text(),s;try{s=JSON.parse(o)}catch{s=o}throw new Error(`Depop API error ${r.status}: ${JSON.stringify(s)}`)}return r.status===204?null:r.json()}async function h(e){try{return{loggedIn:!0,user:await d(`${c}/api/v1/sellerOnboarding/sellerStatus/`,{headers:l(e)})}}catch(t){return{loggedIn:!1,error:t.message}}}async function y(e){let t=await d(`${c}/api/v1/addresses/`,{headers:l(e)});if(t?.length>0)return String(t[0].userId);throw new Error("Could not resolve userId \u2014 no addresses found on account")}async function $(e,t){let{readFile:r}=await import("node:fs/promises"),{extname:o}=await import("node:path"),s=o(e).slice(1).toLowerCase()||"jpg",n=s==="png"?"image/png":"image/jpeg",a=await d(`${c}/api/v2/pictures/`,{method:"POST",headers:l(t),body:JSON.stringify({type:"PRODUCT",extension:s})}),i=await r(e),u=await v.fetch(a.url,{method:"PUT",headers:{"Content-Type":n},body:i});if(!u.ok){let g=await u.text();throw new Error(`S3 upload failed ${u.status}: ${g}`)}return{id:a.id,url:a.url.split("?")[0]}}async function b(e,t){return d(`${c}/api/v2/drafts/`,{method:"POST",headers:l(t),body:JSON.stringify(e)})}async function I(e,t,r){return d(`${c}/api/v2/drafts/${e}/`,{method:"PUT",headers:l(r),body:JSON.stringify({id:e,...t})})}async function D(e){return d(`${c}/api/v2/drafts/`,{headers:l(e)})}async function S(e,t){return d(`${c}/api/v1/drafts/${e}/`,{method:"DELETE",headers:l(t)})}async function x(e,t,r){return d(`${c}/api/v2/products/${e}/`,{method:"PUT",headers:{...l(r),Referer:`https://www.depop.com/products/edit/${e}/`},body:JSON.stringify(t)})}async function T(e,t){return d(`${c}/api/v1/products/${e}/`,{method:"DELETE",headers:l(t)})}async function O(e,t){return d(`${c}/api/v1/product/by-slug/${e}/user/?camel_case=true`,{headers:l(t)})}async function C(e,t){return d(`${c}/api/v3/shop/${t}/products/?limit=200&force_fee_calculation=false`,{headers:l(e)})}async function E(e){return d(`${c}/api/v1/addresses/`,{headers:l(e)})}import{readFile as m,writeFile as _,mkdir as F,unlink as J}from"node:fs/promises";import{createInterface as R}from"node:readline";import{homedir as q}from"node:os";import{join as U}from"node:path";var w="https://www.depop.com",N=U(q(),".vibelyster"),f=U(N,"depop.json");function B(e){let t=R({input:process.stdin,output:process.stdout});return new Promise(r=>{t.question(e,o=>{t.close(),r(o.trim())})})}async function k(){try{let e=JSON.parse(await m(f,"utf-8"));if(e.accessToken)return e}catch{}return null}async function A(e){await F(N,{recursive:!0}),await _(f,JSON.stringify(e,null,2))}async function G(){try{await J(f)}catch{}}async function p(e){let t=K(e,"--access-token")||process.env.DEPOP_ACCESS_TOKEN;if(t)return t;let r=await k();if(r)return r.accessToken;console.error("Error: Not logged in. Run `depop login` or set DEPOP_ACCESS_TOKEN env var."),process.exit(1)}async function P(e){let t=await k();if(t?.userId)return t.userId;let r=await p(e),o=await y(r);return t&&(t.userId=o,await A(t)),o}function K(e,t){let r=e.indexOf(t);return r!==-1&&r+1<e.length?e[r+1]:null}function V(e){let t=[],r=["--access-token","--status"],o=0;for(;o<e.length;)r.includes(e[o])?o+=2:(t.push(e[o]),o++);return t}async function z(){let e=process.argv.slice(2),t=V(e),r=t[0];if(!r||r==="--help"||r==="-h"){console.log(`Depop CLI \u2014 VibeLyster
|
|
3
|
+
|
|
4
|
+
Commands:
|
|
5
|
+
login Save your access token
|
|
6
|
+
auth Check login status
|
|
7
|
+
logout Remove saved credentials
|
|
8
|
+
listings List your products
|
|
9
|
+
listing <slug> Get product details
|
|
10
|
+
addresses List shipping addresses
|
|
11
|
+
upload <image-path> Upload a square image, returns {id, url}
|
|
12
|
+
create <json-file> Create a draft listing
|
|
13
|
+
drafts List draft listings
|
|
14
|
+
draft-update <id> <json-file> Update a draft
|
|
15
|
+
draft-delete <id> Delete a draft
|
|
16
|
+
edit <product-id> <json-file> Edit a live product in-place
|
|
17
|
+
delete <product-id> Delete a live product
|
|
18
|
+
|
|
19
|
+
Auth:
|
|
20
|
+
Run "depop login" and paste your access_token from browser cookies.
|
|
21
|
+
Token saved to ~/.vibelyster/depop.json. userId auto-resolved.
|
|
22
|
+
Or set DEPOP_ACCESS_TOKEN env var.
|
|
23
|
+
|
|
24
|
+
Note: Images must be square. Crop before uploading.
|
|
25
|
+
`);return}try{switch(r){case"login":{console.log(`Depop Login
|
|
26
|
+
`),console.log("To get your access token:"),console.log(" 1. Log in to depop.com in your browser"),console.log(" 2. Open DevTools \u2192 Application \u2192 Cookies \u2192 depop.com"),console.log(` 3. Copy the 'access_token' cookie value
|
|
27
|
+
`);let o=await B("access_token: ");o||(console.error("access_token is required."),process.exit(1)),console.log(`
|
|
28
|
+
Verifying...`);let s=await h(o);s.loggedIn||(console.error("Login failed:",s.error),process.exit(1)),console.log("Resolving user ID...");let n=await y(o);await A({accessToken:o,userId:n,savedAt:new Date().toISOString()}),console.log(`
|
|
29
|
+
Logged in! canSell: ${s.user.canSell}`),console.log(`User ID: ${n}`),console.log(`Credentials saved to ${f}`);break}case"auth":{let o=await p(e),s=await h(o);if(s.loggedIn){let n=await P(e);console.log("Logged in. User ID:",n),console.log("canSell:",s.user.canSell),console.log("stripe:",s.user.stripe?.isConnected?"connected":"not connected");let a=await k();a?(console.log(`Credentials: ${f}`),a.savedAt&&console.log("Saved at:",a.savedAt)):console.log("Credentials: environment variables")}else console.error("Not logged in:",s.error),process.exit(1);break}case"logout":{await G(),console.log("Logged out. Credentials removed from",f);break}case"listings":{let o=await p(e),s=await P(e),n=await C(o,s),a=n.products||n.objects||[];if(!a.length){console.log("No listings found.");break}for(let i of a){let u=(i.description||"(no title)").split(`
|
|
30
|
+
`)[0].slice(0,60),g=i.slug||i.id;console.log(`[${g}] ${u} \u2014 ${i.status}`),console.log(` ${w}/products/${g}/`)}console.log(`
|
|
31
|
+
Total: ${a.length} listings`);break}case"listing":{let o=t[1];o||(console.error("Usage: depop listing <slug>"),process.exit(1));let s=await p(e),n=await O(o,s);console.log(JSON.stringify(n,null,2));break}case"addresses":{let o=await p(e),s=await E(o);console.log(JSON.stringify(s,null,2));break}case"upload":{let o=t[1];o||(console.error("Usage: depop upload <image-path>"),console.error(`
|
|
32
|
+
Image must be square. Depop will reject non-square images.`),process.exit(1));let s=await p(e),n=await $(o,s);console.log("Uploaded:"),console.log(" ID:",n.id),console.log(" URL:",n.url||n.imageUrl||JSON.stringify(n));break}case"create":{let o=t[1];o||(console.error("Usage: depop create <json-file>"),console.error(`
|
|
33
|
+
See examples/draft.json for the payload format.`),process.exit(1));let s=await p(e),n=JSON.parse(await m(o,"utf-8"));console.log("Creating draft...");let a=await b(n,s);console.log("Draft created:",a.id),console.log(`
|
|
34
|
+
To publish, open the draft in your browser:`),console.log(` ${w}/sellinghub/drafts/edit/${a.id}/`),console.log(`
|
|
35
|
+
Or update it via: depop draft-update <draft-id> <json-file>`);break}case"drafts":{let o=await p(e),n=(await D(o)).drafts||[];if(!n.length){console.log("No drafts found.");break}for(let a of n){let i=(a.description||"(no description)").split(`
|
|
36
|
+
`)[0].slice(0,60),u=a.priceAmount?`$${a.priceAmount}`:"?",g=a.missingFields?.length?` [missing: ${a.missingFields.join(", ")}]`:" [ready]";console.log(`[${a.id}] ${i} \u2014 ${u}${g}`)}console.log(`
|
|
37
|
+
Total: ${n.length} drafts`);break}case"draft-update":{let o=t[1],s=t[2];(!o||!s)&&(console.error("Usage: depop draft-update <draft-id> <json-file>"),process.exit(1));let n=await p(e),a=JSON.parse(await m(s,"utf-8"));await I(o,a,n),console.log("Draft updated:",o),console.log(` ${w}/sellinghub/drafts/edit/${o}/`);break}case"draft-delete":{let o=t[1];o||(console.error("Usage: depop draft-delete <draft-id>"),process.exit(1));let s=await p(e);await S(o,s),console.log("Draft deleted:",o);break}case"edit":{let o=t[1],s=t[2];(!o||!s)&&(console.error("Usage: depop edit <product-id> <json-file>"),process.exit(1));let n=await p(e),a=JSON.parse(await m(s,"utf-8")),i=await x(o,a,n);console.log("Updated listing:"),console.log(" ID:",i.id),console.log(" URL:",`${w}/products/${i.slug||i.id}/`);break}case"delete":{let o=t[1];o||(console.error("Usage: depop delete <product-id>"),process.exit(1));let s=await p(e);await T(o,s),console.log(`Deleted product ${o}`);break}default:console.error(`Unknown command: ${r}`),console.error('Run "depop --help" for usage.'),process.exit(1)}}catch(o){console.error("Error:",o.message),process.exit(1)}}z();
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vibelyster/depop-cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CLI for Depop's internal API — list, create, edit, and manage product listings",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"depop": "./dist/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist/"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "esbuild cli.js --bundle --platform=node --format=esm --minify --external:impit --outfile=dist/cli.js",
|
|
14
|
+
"prepublishOnly": "npm run build"
|
|
15
|
+
},
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=18"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"esbuild": "^0.25.0"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"depop",
|
|
24
|
+
"reselling",
|
|
25
|
+
"cli",
|
|
26
|
+
"listing"
|
|
27
|
+
],
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"private": false,
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"impit": "^0.13.0"
|
|
32
|
+
}
|
|
33
|
+
}
|