
Security News
Vite Releases Technical Preview of Rolldown-Vite, a Rust-Based Bundler
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
⚠️Deprecated⚠️
YahooのAPI認証がv1からv2に移行しており、自分自身EC関連の業務から離れているため、メンテナンスができません。
2021年8月3日をもちましてYahoo! ID連携 v1の新規の登録を終了いたしました。 2022年4月27日にYahoo! ID連携 v1の利用を終了いたしますのでv2への移行が必要です。
Yahoo!ショッピング プロフェッショナル出店ストア向けAPIを簡単に叩けるrubyラッパーです。
get_item
)set_item
)upload_item_file
)delete_item
)upload_item_image_pack
)get_stock
)set_stock
)reserve_publish
)Add this line to your application's Gemfile:
gem 'yahoo_store_api'
事前にストア出品アカウントと連携した認証コードが必要になります。
まず、YahooデベロッパーネットワークのYahoo!ショッピングのストア運営をサポートするAPIを利用したアプリケーションにアプリケーションを登録します。
登録が終えたら、次に認可コードを取得する必要があります。ページに表示するかリダイレクトした時のパラメーターにある認証コードを取得します。
※シンプルにページ上に認証コードを表示させる例: https://auth.login.yahoo.co.jp/yconnect/v1/authorization?response_type=code+id_token&client_id=[上で登録したアプリケーションID]&state=foobar&redirect_uri=oob&nonce=hogehoge
stateやnonceなどはAuthorizationエンドポイントに詳細がありますので、適宜変更してください。
ストアアカウント、上で登録したアプリケーションid、シークレット、取得した認証コードでインスタンスを生成します。
redirect_uriにはアプリケーション登録時に設定したフルURL(もしくはカスタムURIスキーム)を指定してください。登録済みの戻り先URLが1つしかない場合は省略可能です。戻り先URLがない場合はoobを指定してください。
client = YahooStoreApi::Client.new(
seller_id: YOUR_STORE_ID, # ストアアカウントid
application_id: YOUR_APPLICATION_ID, # アプリケーションid
application_secret: YOUR_SECRET, # シークレット
redirect_uri: 'oob', # 省略可能
authorization_code: AUTHORIZATION_CODE # 認証コード
)
なお、この認証コードは1回のみ使用可能で、次からはリフレッシュトークンを使用するか、再度認証コードを取得する必要があります。リフレッシュトークンは生成したインスタンスから取得する事ができます。
puts client.refresh_token
client = YahooStoreApi::Client.new(
seller_id: YOUR_STORE_ID, # ストアアカウントid
application_id: YOUR_APPLICATION_ID, # アプリケーションid
application_secret: YOUR_SECRET, # シークレット
refresh_token: YOUR_REFRESH_TOKEN # リフレッシュトークン
)
ストアに登録されている商品情報を取得できます。
item = client.get_item('test123')
# 商品名を取得
item.name
# 通常販売価格を取得
item.price
# 取得したすべての情報をhashで出力
item.all
項目についてはYahoo:商品登録APIを参照してください。
item = client.edit_item({
item_code: 'test1234',
name: 'test_item',
path: 'test_category',
price: 1000,
})
# 送信結果をhashで出力
item.all
csvファイルをアップロードする事で商品情報の一括登録ができます。
item = client.upload_item_file("your/upload/file.csv")
:bangbang: APIの仕様で、更新したいカラムのみ送信して更新が できません :bangbang:
商品を登録・更新する場合、省略した項目はデフォルト値で上書きされるので注意してください。
なので、一度情報を取得し、必要な箇所を書き換えて送信する必要があります。
data = client.get_item(code).all
data["name"] = 'edit item'
data["caption"] = 'edit caption'
client.edit_item(data)
ストアに登録されている商品の在庫情報を取得できます。
stock = client.get_stock('test123')
# 在庫数の取得
stock.quantity
# 取得したすべての情報をhashで出力
stock.all
反映予約をします。
pub = client.reserve_publish
# 結果を取得
pub.status
FAQs
Unknown package
We found that yahoo_store_api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.