Skip to content

Instantly share code, notes, and snippets.

@baseinc
Last active December 23, 2020 05:24
Show Gist options
  • Star 30 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baseinc/9634675 to your computer and use it in GitHub Desktop.
Save baseinc/9634675 to your computer and use it in GitHub Desktop.

BASE API v1 ドキュメント (β版)

BASEのAPIの開発者向けのドキュメントです。

概要

このAPIを使うと、あなたのアプリケーションとBASEを連携させることができます。

例えば

  • BASEのアカウントでログインする
  • BASEのショップの商品情報を取得する
  • BASEのショップの商品情報を更新する
  • BASEのショップの注文情報を取得する

※ APIは順次公開していく予定です。

仕様

エンドポイント

https://api.thebase.in/ 配下に各種APIが用意されています。 (httpsのみ)

認証

OAuth2.0に対応

Authorizationヘッダーでアクセストークンを送信して認証します。

Authorization: Bearer {Access_Token}

リフレッシュトークンも発行しています。

OAuth2.0の仕様については、下記の外部サイトを参照ください。

scope

  • read_users - ユーザー情報を取得 (デフォルトで付与)
  • read_users_mail - ユーザーのメールアドレスを取得
  • read_items - 商品情報を取得
  • read_orders - 注文情報を取得
  • read_savings - 振込申請情報を取得
  • write_items - 商品情報を更新
  • write_orders - 注文情報を更新

レスポンス

JSON形式でレスポンスを返します。

正常な場合はHTTPステータスコード 200 OKを返します。

エラーの場合はHTTPステータスコード 400 Bad Requestを返します。

エラーレスポンスの例

{
  "error":"invalid_request",
  "error_description":"アクセストークンが無効です。"
}

API

OAuth

Users

Items

Categories

ItemCategories

Orders

Savings

Search

APIの利用制限

現在はユーザーの1時間の利用上限を5000回、1日の利用上限を100000回に設定しています。

上限を超えるとエラーレスポンスを返します。00分になると利用回数がリセットされます。

{
  "error":"hour_api_limit",
  "error_description":"1時間のAPIの利用上限を超えました。時間が変わってからもう一度アクセスしてください。"
}
{
  "error":"day_api_limit",
  "error_description":"1日のAPIの利用上限を超えました。日付が変わってからもう一度アクセスしてください。"
}

注意点

BASE APIは現在β版のため仕様が変更される場合があります。

API利用規約

http://thebase.in/pages/api_term

お問い合わせ

developers[at]thebase.in

BASE Developers https://developers.thebase.in

<?php
// アクセストークンを取得するサンプルコード
$params = array(
'client_id' => '2aacd57f14ffe6edafd402934593a0ce',
'client_secret' => '2e3389dc5fe7c9607115541e409dd2c3',
'code' => '182e28b20f138dd0def9e76f623531f7',
'grant_type' => 'authorization_code',
'redirect_uri' => 'http://hogehoge.com/callback',
);
$headers = array(
'Content-Type: application/x-www-form-urlencoded',
);
$request_options = array(
'http' => array(
'method' => 'POST',
'content' => http_build_query($params),
'header' => implode("\r\n", $headers),
),
);
$context = stream_context_create($request_options);
$response_body = file_get_contents('https://api.thebase.in/1/oauth/token', false, $context);
// 注文情報を取得するサンプルコード
$headers = array(
'Authorization: Bearer 9f20168eeff6355716e99cc7d46f1d26',
);
$request_options = array(
'http' => array(
'method' => 'GET',
'header' => implode("\r\n", $headers),
),
);
$context = stream_context_create($request_options);
$response_body = file_get_contents('https://api.thebase.in/1/orders?limit=10&offset=0', false, $context);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment