これは Google に保存されている https://qiita.com/7mpy/items/960bd24f3f77a4d7cef4 のキャッシュです。 このページは 2024年2月28日 16:07:31 GMT に取得されたものです。 そのため、このページの最新版でない場合があります。 詳細.
フルバージョンテキストのみのバージョンソースを表示
ヒント: このページで検索キーワードをすばやく見つけるには、Ctrl+F または ⌘-F(Mac)を押して検索バーを使用します。

Why don't you show your feelings by liking the articles you like? 💚

1

ダイソーの在庫検索APIを叩く

Last updated at Posted at 2024-02-28

転売するのにスマホ使うの大変なので自動化してみた!複数店舗や複数商品同時に検索できます!

const md5 = text => fetch('https://md5sum.deno.dev/' + text).then(r=>r.text())

// 店舗コード
const str_cd = '002870'
// yyyyMMdd:hhmmss sources\com\locationvalue\ma2\extensions\ScreenExtensionsKt.java:78
const request_datetime = new Date().toLocaleString('sv').replaceAll(/-|:/g, '').replace(' ', ':')
// ジャン
const sku_cd = ['4549131971149']
await fetch('https://zaikoapp.plat.daisojapan.com/api_get_store_zaiko', {
    method: 'POST',
    body: JSON.stringify({
        access_key: await md5(`${request_datetime}daiso_zaiko_api${str_cd}`),
        crp_cd: 'daiso',
        request_datetime,
        detail: [
            { sku_cd , str_cd }
        ]
    })
}).then(r=>r.json())

crp_cdをstandardproductsとかthreeppyにして他ブランドも在庫検索できるようになるかもね!

image.png

店舗コード
https://www.daiso-sangyo.co.jp/shop/detail/002870

ジャン
Screenshot_20240229-000039.png

在庫状況APIとアプリの内容が一致してるか確認しよう!
Screenshot_20240229-000034.png

Deino版ダイソー在庫検索API

curl https://daiso.deno.dev/002870/4549131971149,4549131910193,4902820101119.json

image.png

import { Md5 } from "https://deno.land/std@0.119.0/hash/md5.ts"

const headers = { 'Access-Control-Allow-Origin': '*' }
Deno.serve(async (req: Request) => {
    const [str_cd, skus] = req.url.slice(23).split('/')
    if (!str_cd || !skus) return new Response('Bad request', { headers, status: 400 })
    const sku_cd = skus.match(/[\d,]+/)[0].split(',')
    const request_datetime = new Date().toLocaleString('sv').replaceAll(/-|:/g, '').replace(' ', ':')
    const access_key = new Md5().update(`${request_datetime}daiso_zaiko_api${str_cd}`).toString()
    const response = await fetch('https://zaikoapp.plat.daisojapan.com/api_get_store_zaiko', {
        method: 'POST',
        body: JSON.stringify({
            access_key,
            crp_cd: 'daiso',
            request_datetime,
            detail: [
                { sku_cd , str_cd }
            ]
        })
    }).then(r=>r.json())
    headers['Content-Type'] = 'application/json'
    return new Response(JSON.stringify(response, null, 2), { headers })
});

今回はアンドロイドのコードを解析した

参考にしたソースコード

sources\com\locationvalue\ma2\app\AccessKeyUtils.java

sources\com\locationvalue\ma2\view\fragment\searchResult\SearchResultViewModel.java

sources\com\locationvalue\ma2\datasource\api\model\DaisoStoreZaikoParams.java

sources\com\locationvalue\ma2\datasource\api\RetrofitAPI.java

sources\com\locationvalue\ma2\view\adapter\SearchResultListAdapter.java

sources\com\locationvalue\ma2\datasource\api\RetrofitConstants.java

sources\com\locationvalue\ma2\view\fragment\searchResult\SearchResultNearbyStoreFragmentregisterObservers1$3.java

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up

Comments

No comments

Let's comment your feelings that are more than good

1

Why not register and get more from Qiita?

You need to log in to use this function. Qiita can be used more conveniently after logging in. You can also use this function by logging in.

  1. We will deliver articles that match you with function that follow users and tags
  2. you can read useful information later efficiently with stock function

Login or Sign up with social account

Login or Sign up with your email address