Skip to content

About

Command-line tool for 7-ELEVEN MyShip (賣貨便) sellers: stores, orders, payouts, new-store

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

myship.py — command-line tool for the 7-ELEVEN MyShip (賣貨便) seller back office

List your stores, read orders and payout records, and create new stores from the terminal instead of clicking through the website.

MyShip (myship.7-11.com.tw) has no public API. It is a server-rendered ASP.NET MVC site, so this tool borrows the login state of a dedicated Chrome instance that you control — cookies are read over the Chrome DevTools Protocol and reused live, while the tool itself does not print or write cookie or token values to disk — and then sends the same requests the web pages send.

Everyone logs in with their own MyShip / uniopen account. The tool contains no account or personal data.


Requirements

  • Python 3.9+
  • Google Chrome (or Chromium) installed locally
  • Three Python packages:
pip install requests beautifulsoup4 websocket-client

On Windows, run the commands with py -3 instead of python3.


First login

MyShip logs in through 7-ELEVEN's uniopen (phone number + password + captcha, or a QR code scanned with the OPENPOINT app). The tool never types credentials or verification codes for you. You do all of it yourself in the Chrome window.

python3 myship.py login

What it does:

  1. Starts Chrome in the background with a dedicated profile (default ~/.myship-chrome-profile).
  2. Opens a tab on the MyShip home page.
  3. Tells you to log in in that window (scan the QR code or type your credentials).
  4. Polls the login state every 5 seconds and prints {"logged_in": true} when you are in.

It gives up after 300 seconds (exit code 4). Use --timeout 600 to wait longer.

Ticking "keep me logged in" (保持登入狀態) on the uniopen page keeps the uniopen side logged in for 30 days. The MyShip session itself can expire sooner; when that happens, run login again.

Every other subcommand reuses that Chrome's login state. If Chrome is not running or the session has expired, the tool does not start Chrome for you; it tells you to run login.

Security note. While the dedicated Chrome is running, its remote-debugging port is open on your machine, and any local process that can reach that port can read that profile's cookies. When this tool reuses an existing CDP port, it cannot verify which Chrome profile is behind it — please use it only with your own dedicated Chrome instance and on your own machine. Use the dedicated profile only for MyShip, and close that Chrome when you are done.


Subcommands

All output is JSON, so you can pipe it to jq.

status — login probe

python3 myship.py status
{"logged_in": true}

Your name is never printed.

stores — your stores

python3 myship.py stores
python3 myship.py stores --tab active
python3 myship.py stores --tab inactive

--tab is all (default), active or inactive.

[
  {
    "store_id": "GM0000000000000",
    "name": "Test store",
    "kind": "一般",
    "sold": "0",
    "stock": "10",
    "status": "上架中",
    "hidden": false
  }
]

Prints [] when you have no stores. Values such as kind and status are copied from the site, so they stay in Chinese.

orders — seller orders

python3 myship.py orders
python3 myship.py orders --from 2026/10/01 --to 2026/10/22
python3 myship.py orders --tab 3

Dates are YYYY/MM/DD and must be real calendar dates in that form, with --from no later than --to; anything else is rejected with exit code 1 before any request goes out. Without --tab the tool explicitly sends TabStatus=1 (全部); without --from and --to it falls back to the page default (近兩個月, e.g. 2026/08/22–2026/10/22 in the bundled fixture). --tab accepts only the integers 1–11 (any other value is a usage error, exit code 1), which according to the page tabs are:

Tab Meaning
1 全部 (all orders) — also the default this tool sends
2 未付款 (unpaid)
3 訂單處理中 (in progress)
4 待出貨 (waiting to ship)
5 已寄件 (shipped)
6 買家待取件 (buyer pickup pending)
7 已取件 (picked up)
8 異常 (abnormal)
9 取消 (cancelled)
10 已退回 (returned)
11 買家退貨申請 (buyer return request)

The tool first loads the page to collect the form defaults and the anti-forgery token, sends the whole form back, and only overrides the dates and tab you give.

Order date range. The site's front end rejects a date range (--from to --to) longer than 90 days; the tool does not enforce that limit itself, so when you ask for a longer range the result is whatever the site decides to return — treat the site's answer as authoritative rather than assuming the full range came back.

Keys are the table headers exactly as the site shows them (in Chinese):

[
  {
    "訂單編號": "XXXXXXXX",
    "訂單日期": "2026/10/21",
    "商品名稱": "Item A",
    "訂單金額": "380",
    "訂單狀態": "待出貨"
  }
]

Prints [] when the page says there is no matching data (無符合條件之資料).

payouts — payout records

python3 myship.py payouts
python3 myship.py payouts --from 2026/09/01 --to 2026/10/22
python3 myship.py payouts --status 1

--status is one of:

Value Meaning
1 pending (待撥款)
2 failed (撥款失敗)
3 paid (撥款成功)
4 no payout needed (不需撥款)
all every status — this is the default

Without --status and with --status all the tool explicitly sends Status=5 (the tab the page itself labels 「全部」) instead of reusing the page's hidden default of 1 (pending); reusing the page default would silently drop every paid/failed record and report only the pending bucket. One query covers at most 180 days. Without --from and --to the date window falls back to whatever the page itself preselected — in the bundled fixture that is the most recent two months, e.g. FromDate=2026/08/22, ToDate=2026/10/22.

{"upcoming": 0, "rows": []}

upcoming is the "upcoming payout" amount shown at the top of the page.

Add --wallet to read the member wallet ledger instead (cash-on-delivery collections, compensation, return-shipping deductions):

python3 myship.py payouts --wallet --from 2026/10/01
{"rows": []}

new-store — create a regular store

python3 myship.py new-store --spec spec.json --dry-run   # show what would be sent, send nothing
python3 myship.py new-store --spec spec.json             # actually create it

--dry-run prints the payloads of all three steps (tokens shown as <token>) and makes no network request at all. Use it to check your spec first.

On success:

{"store_id": "GM0000000000000", "products": [{"name": "Item A", "cgdd_id": "CGDD0000000000000"}]}

Behind it are three calls: POST /CPF2101/MaintainCgdm creates the store, POST /CPF2101/ML1 uploads each product image (the response body is the stored file name), and POST /CPF2101/MaintainCgdds adds each product. If the site answers with a Status other than true, the tool stops and prints the site's Message. Error code 121 (錯誤代碼:121) means a duplicate submission and is never retried.

A 200 response and a Status of true are not on their own accepted as success for MaintainCgdds. The reply must parse as JSON, carry Status: true, and include a well-formed product identifier (Data.Cgdd_Id). A site revision that returns {"Status": true} and nothing else would otherwise look like the product was saved when it was not, so it is reported as a failure instead. An image upload reply must be a bare stored file name; an HTML error page returned with a 200 is likewise rejected.

If the store master is created successfully but any later step fails — image upload, a product, an HTTP status, a dropped connection, or a timeout — the tool exits with code 5 and prints a partial JSON on stderr:

{
  "partial": true,
  "store_id": "GM0000000000000",
  "failed_step": "ML1",
  "done_products": ["Item A"],
  "hint": "Store may be partially created. Check `myship.py stores --tab all` before running again."
}

failed_step is the step that actually failed — MaintainCgdm (the store master), ML1 (the product image upload), MaintainCgdds (the product) or RequestError (a connection-level failure). A login that expires mid-run is not a separate failed_step: the exit code is 4 and failed_step names the step that was in flight when it happened, so run login and re-run. When the site supplied a reason, an extra detail field carries it. Every string field — including the product names in done_products — is passed through the same secret redaction used for all other output, and each field is redacted separately so the JSON stays parseable rather than being truncated mid-structure.

If the login expires after the master was written, the output is still a partial report, but the exit code is 4 so the failure is not mistaken for a bad request; the hint field reads Store may be partially created. Check `myship.py stores --tab all` before running again.

Before sending the master, the tool verifies the store id captured from the page matches GM plus 13 digits. If it does not (for example because the page value was polluted), nothing is written and the tool exits with code 5.

The store master has already been written at that point; running again with the same spec creates a fresh GM number and a fresh store. Inspect with myship.py stores --tab all before deciding whether to delete or amend.

delete-store — delete a store

python3 myship.py delete-store GM0000000000000 --confirm

Without --confirm it always refuses and exits with code 3. Deleting cannot be undone.


Network safety

Redirects are followed manually, and every hop is checked before it is sent. The tool never lets the HTTP library auto-follow a redirect, because by the time a library hands back the final response the cookie, the VerificationToken header and the POST body have already been delivered to whatever host the site pointed at. Instead each hop is validated first, and a hop that fails validation is never sent:

Situation Result
Scheme is not https Refused, exit code 5
Host is not exactly myship.7-11.com.tw Refused, exit code 5
Port is present and is not 443 Refused, exit code 5
Any userinfo (user@host) in the URL Refused, exit code 5
Location contains a backslash, @, whitespace or a control character Refused, exit code 5
Points at the openpoint login area or at the MyShip home page Treated as an expired session, exit code 4
More than 5 hops Aborted

The host must match exactly. A subdomain such as x.myship.7-11.com.tw is refused: a 307 would otherwise replay the VerificationToken and the POST body to it.

The hop that is validated is the hop that is sent. Each hop is first turned into a PreparedRequest, the prepared URL is what gets validated, and that same object is what gets sent. Checking the raw string instead would be a different URL than the one actually transmitted: https://evil.example\@myship.7-11.com.tw/collect reads as MyShip to a naive string split, while the HTTP library sends it to evil.example. Because the validated URL and the sent URL are one object, that divergence is impossible. A backslash, @, whitespace or control character in the raw Location is rejected before the next request is even prepared, since URL preparation strips trailing control characters and the original evidence would be gone by then.

For 301/302/303 the next hop is downgraded to GET and carries neither the request body nor the VerificationToken header. For 307/308 the method is preserved, but only when the host stays the same.

Cookies are scoped to the MyShip host. Chrome is asked for the cookies of the whole browser context, which also contains cookies for sibling subdomains and for unrelated sites. Only cookies that actually apply to myship.7-11.com.tw are carried into the session, using RFC 6265 domain matching. .7-11.com.tw and myship.7-11.com.tw are kept; sibling.7-11.com.tw, evil7-11.com.tw and 7-11.com.tw.evil.com are dropped.

An HTTP error status is judged before the login prompt. A 500 error page that happens to contain "please log in" is reported as a site error (exit code 5), not as an expired session, because the real cause is the server fault and re-running login would not help.

A row is never quietly dropped. If a result table has data rows, then every data row must parse and line up with the header row. A row that cannot be read makes the whole command exit with code 5 and name the offending row number, instead of quietly dropping that row and printing a plausible-looking but incomplete list — an incomplete payout or order list is worse than an error, because it reads as complete. For store listings, a row must yield a GM code plus its 13 digits and a name, or the command fails the same way. The header row itself is also checked against the columns the command documents, so a redesigned table is reported as a format change (exit code 5) rather than parsed into nonsense keys.

Note the scope of that promise: it means no row is skipped within the pages a command reads, not that every command reads every page. See the pagination note under Known limitations for which commands walk all pages and which read the first page only.

An extra trailing cell on a row is tolerated only when the extra cells are all blank and dropping them makes the cell count match the header exactly; that covers the site's icon-only action column. If a dropped cell still carries text, or the row cannot be aligned with the header after the blanks are removed, the command exits with code 5 rather than guessing which column a value belongs to.

An empty result has to be proven, not assumed. A list is only reported as empty when the result table genuinely has no data rows and the page contains the site's dedicated "no matching data" node. If rows are present but cannot be parsed, or if required table headers are missing, or if there are neither rows nor an empty-result marker, the tool exits with code 5 instead of returning a plausible-looking empty list. This also means a store or product literally named "無符合條件之資料" is still reported as a normal row.

Pagination. orders and payouts --wallet follow the site's pgidx / pgsize form fields and walk pages until a short page comes back; if the site ever ignores pgidx and returns the same page twice, the tool exits with code 5 instead of looping forever. stores and payouts (without --wallet) read the first page only: the stores page has pgidx / pgsize fields that this version does not drive, and the payouts page has no pagination fields at all. When the result count fills the page size (15 for stores, 10 for payouts) the tool prints a stderr hint that there may be more on the next page; the JSON output is still emitted and the exit code stays 0.

Booleans in spec.json. on_shelf and public must be JSON booleans (true / false). The string "false" or the number 0 is rejected before any request goes out — bool("false") in Python is True, and silently treating a string "false" as "user means false" is exactly the kind of guesswork that creates a publicly-listed store the user asked to be hidden.


spec.json

new-store reads a JSON file. A minimal working example:

{
  "name": "My test store",
  "description": "Store description",
  "on_shelf": true,
  "public": true,
  "conveyance": {
    "ShipType": "1",
    "FixFee": "38",
    "FullList": [],
    "Note": ""
  },
  "payment": [
    {"PaymentType": "1", "Description": "取貨付款"}
  ],
  "products": [
    {
      "name": "Item A",
      "description": "Item description",
      "images": ["./photo1.jpg"],
      "condition": "1",
      "max_order": 0,
      "min_order": 0,
      "specs": [
        {"name": "單規格", "stock": 10, "price": 380}
      ]
    }
  ]
}

Store fields:

Field Meaning Default
name Store name required
description Store description required
on_shelf true = listed, false = unlisted true
public true = public, false = hidden true
during Listing window: {"start": "...", "end": "..."}; omit for no end date no end date
meta_keyword / meta_description SEO fields none
conveyance Shipping; ShipType "1" = 7-ELEVEN store pickup, FixFee "38" = NT$38 store pickup, NT$38
payment Payment methods ("取貨付款" = pay on pickup) pay on pickup
products Product array required

Product fields (products[]):

Field Meaning Default
name / description Product name and description required
images Local image paths, uploaded one by one []
condition "1" = new, "2" = used "1"
specs Variants; for a single variant, give one entry (name / stock / price) required
max_order / min_order Per-order maximum / minimum quantity 0

Images are local files, read and uploaded as base64. The site's bulk-import restriction (images only from imgur, Google Drive or Dropbox URLs) does not apply. Before any request goes out, each file is checked by its magic number — it must really be a JPEG, PNG, GIF or WebP, and must be 10 MB or smaller — and the outgoing data URL carries the MIME type of the format actually detected. A text file renamed to .jpg, or anything else that fails the check, is rejected with exit code 1 before a single request is sent, so pointing images at a stray file cannot exfiltrate its contents to the site.

Product descriptions are sent as base64(encodeURIComponent(...)), the same way the site's own front end does it. Write plain text or HTML; the tool encodes it.


Environment variables

Variable Purpose Default
MYSHIP_CDP_PORT CDP port of the dedicated Chrome 9235
MYSHIP_PROFILE Profile directory of the dedicated Chrome ~/.myship-chrome-profile
MYSHIP_CHROME Path to the Chrome executable auto-detected (see below)

Chrome is looked up in this order: MYSHIP_CHROME → macOS /Applications/Google Chrome.app/Contents/MacOS/Google Chrome → google-chrome / google-chrome-stable / chromium / chromium-browser on PATH → Windows %ProgramFiles%\Google\Chrome\Application\chrome.exe.

Examples:

MYSHIP_CDP_PORT=9333 python3 myship.py status
MYSHIP_CHROME="/usr/bin/chromium" python3 myship.py login

The tool itself does not print cookie or token values, and does not write them to files. They stay in the in-memory session only. Your dedicated Chrome profile behaves like a normal browser — it stores its own cookies on disk under the profile directory you pointed it at, the same way any other logged-in browser does.


Exit codes

Code Meaning
0 Success
1 Usage error (bad arguments, etc.)
2 Chrome is not running or the CDP port is unreachable → run login
3 delete-store without --confirm, refused
4 Session expired, or login timed out → run login. Also used when the session expires after a store master was written (the output is still a partial report)
5 The site returned an error, the page layout changed, a request was refused before being sent, or a package is missing

Known limitations

  • It breaks when the site changes. There is no public API; the tool mirrors the current HTML and request formats. After a site redesign, parsing or submitting may stop matching and the code has to be updated against the new pages. When a parser cannot find the fields it expects, it reports that the site may have changed instead of silently returning wrong data.
  • Single-variant products only. The site's two-dimension variant payload is not implemented.
  • No Excel bulk import. The site's /Store/Import Excel route (up to 10 stores at a time, officially Windows Excel only, images only from certain cloud URLs) is not supported. The tool creates stores one by one through the API, which lets you upload local images.
  • Store banners are not supported in this version. spec.json's banner field is rejected before any request goes out, and Cgdm_Pic is always sent as an empty string; upload the banner through the site's own UI.
  • Only some list commands walk every page. orders and payouts --wallet follow the site's pgidx/pgsize fields and keep requesting the next page until a page comes back short (up to 100 pages; if a page repeats the previous one exactly, or the cap is hit, the command fails with exit code 5 rather than reporting a truncated list). stores and payouts without --wallet have no pagination field the tool can drive, so they read the first page only; when the result count fills the page, a warning goes to stderr saying more pages may exist. For those two, narrow the date range or filter in the site's UI.
  • Non-empty tables have not been tested against real data yet. The bundled offline fixtures come from a new account and all tables are empty, so the column mapping for stores and orders with rows was tested only with rows built in the tests from the page's column order. The first time you run it on an account with data, check that the output fields line up. The result-table required headers are stored as alias groups (one matched name is enough) precisely to absorb small column-name changes.
  • Payout queries cover at most 180 days. Split longer ranges into two queries.
  • stores may miss stores that have not been updated recently. The seller listing page pre-fills the search form with 「賣場更新日期 = 一個月 (one month)」 as its default; the tool drives no search form, so when the server respects that default on the first render, stores that have not been touched in more than a month are silently absent from stores --tab all. To see the full list, log into the site, change 「更新日期」 to 「全部」, and re-run, or scroll past the first page on the site itself.
  • Seller features must be enabled first. MyShip requires member details, payout details (bank account and so on) and a store-to-store return address before the seller pages open. Until then those pages silently redirect to the settings page and the tool reports "session expired", even though the real cause is that seller features are not enabled yet.

Disclaimer

This is an unofficial tool, not affiliated with or endorsed by 7-ELEVEN, President Chain Store Corp. or President Information Corp. It only automates what you can already do in your own logged-in browser. Use it with your own account and at your own risk.

About

Command-line tool for 7-ELEVEN MyShip (賣貨便) sellers: stores, orders, payouts, new-store

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages