# 注文

> LocalSERP Proxy API：プランと料金、残高からのプラン購入、注文履歴。パラメーター、レスポンス例、curl、Python、Node.jsのコード。

- URL: https://localserpproxy.com/ja/docs/api/orders/
- 最終更新日: 2026-10-15
- Publisher: LocalSERP Proxy (https://localserpproxy.com)

プランと料金の一覧を確認し、残高でプランを購入（新規サービス、トラフィックの追加、ポートの延長）して、過去の注文を確認できます。

**このページのエンドポイント**

- `GET /v1/catalog/products`：商品、プラン、料金
- `POST /v1/orders`：残高からプランを購入（新規サービス、トラフィック追加、またはポート延長）
- `GET /v1/orders`：注文一覧を取得
- `GET /v1/orders/{orderId}`：注文情報を取得

ベースURL `https://localserpproxy.com/api/v1`。認証、エラー、制限については[API概要](https://localserpproxy.com/ja/docs/api/)をご覧ください。

## 商品、プラン、料金

`GET /v1/catalog/products`

注文時に請求される料金を含む、すべての商品とプラン。

公開情報：APIキーは不要です。

**レスポンス** `200 OK`

```json
{
  "data": [
    {
      "id": "residential",
      "name": "Residential proxies",
      "description": "Residential traffic for manual local search, advertising, price and application checks in US cities. State, city and ZIP selection, subject to available exits; no promise of GPS position or rankings.",
      "unit": "GB",
      "plans": [
        {
          "id": "res-10",
          "productId": "residential",
          "name": "Local team",
          "quantity": 10,
          "unit": "GB",
          "durationDays": null,
          "price": "7.50",
          "pricePerUnit": "0.75",
          "popular": false,
          "features": [
            "US city selection, subject to availability",
            "Traffic stays until used",
            "Rotating or sticky sessions"
          ],
          "available": true,
          "countries": null
        }
      ]
    }
  ]
}
```

*curl*

```bash
curl -s "https://localserpproxy.com/api/v1/catalog/products"
```

*Python*

```python
import os
import requests

API = "https://localserpproxy.com/api/v1"

r = requests.get(f"{API}/catalog/products", timeout=30)
r.raise_for_status()
print(r.json())
```

*Node.js*

```javascript
// Node.js 18+ (built-in fetch), ES module
const API = 'https://localserpproxy.com/api/v1';

const res = await fetch(`${API}/catalog/products`);
if (!res.ok) throw new Error((await res.json()).error?.message ?? `HTTP ${res.status}`);
console.log(await res.json());
```

## 残高からプランを購入（新規サービス、トラフィック追加、またはポート期間の延長）

`POST /v1/orders`

常にプリペイド残高から支払われます。価格はAPIによって計算され（カタログ価格 × `quantity`）、残高から差し引かれた後、サービスが作成または延長され、注文は`fulfillment`を含む`completed`として返されます。プロキシの認証情報はすぐに利用できます。

- **新規レジデンシャルトラフィック**: `{ "planId": "res-10" }`。
- **新規ローテーション4G/5Gトラフィック（GB単位）**: `{ "planId": "mgb-10" }`（`productId: "mobile-gb"`付きのトラフィックサブスクリプション。`fulfillment.residentialSubscriptionId`で提供）。
- **既存のサブスクリプションにトラフィックを追加**: `{ "planId": "res-10", "options": { "subscriptionId": "res_9x2m4k" } }`。プランはサブスクリプションと同じ商品に属している必要があります。
- **新規モバイルポート**: `{ "planId": "mob-us-30d", "quantity": 1, "options": { "country": "US" } }`。必要に応じて`carrier`も指定できます（国ごとのキャリアは[モバイルポート](https://localserpproxy.com/ja/docs/api/mobile/)を参照）。ゾーンプランの対象は、そのゾーンに含まれる国のみです（それ以外の場合は`options.country`で`422`）。
- **モバイルポートの期間を延長**: `{ "planId": "mob-us-7d", "options": { "portId": "mob_2v8k1q" } }`を指定すると、プランの期間が`expiresAt`に加算されます。

**残高不足 → `402 insufficient_balance`**。不足額と推奨チャージ額が`error.details`に表示されます（`missing`、`suggestedTopUp`）。エラーが発生した場合、残高から差し引かれることはありません。不足分を支払うには、`purchase`で同じリクエストを含むチャージを開始してください（`POST /v1/topups`）。チャージが反映されると、プランが購入されます。

認証：`Authorization: Bearer API_KEY`ヘッダーにAPIキーを指定します。

**パラメーター**

| 名前 | 場所 | 型 | 必須 | 説明 |
| --- | --- | --- | --- | --- |
| `Idempotency-Key` | header | string | いいえ | POSTを安全に再試行するための一意のキー（例：UUID）。24 h保持。— 最大128文字 |

**リクエストボディ**

| フィールド | 型 | 必須 | 説明 |
| --- | --- | --- | --- |
| `planId` | string | はい | — |
| `quantity` | integer | いいえ | 1～100、デフォルトは`1` |
| `options` | object | いいえ | — |

*例: レジデンシャル*

```json
{
  "planId": "res-10"
}
```

*例: モバイルポート*

```json
{
  "planId": "mob-us-30d",
  "quantity": 1,
  "options": {
    "country": "US",
    "carrier": "verizon",
    "autoRenew": true
  }
}
```

*例: ポート期間を延長*

```json
{
  "planId": "mob-us-7d",
  "options": {
    "portId": "mob_2v8k1q"
  }
}
```

*例: モバイルトラフィック*

```json
{
  "planId": "mgb-10"
}
```

*例: ゾーンポート*

```json
{
  "planId": "mob-us-30d",
  "options": {
    "country": "US",
    "carrier": "verizon"
  }
}
```

**レスポンス** `201 Created`

```json
{
  "id": "ord_4f8k2m9q",
  "status": "completed",
  "productId": "residential",
  "planId": "res-10",
  "planName": "Local team",
  "quantity": 1,
  "unitPrice": "7.50",
  "subtotal": "7.50",
  "discount": "0.00",
  "total": "7.50",
  "promoCode": null,
  "currency": "USD",
  "topUpId": null,
  "options": {},
  "fulfillment": {
    "residentialSubscriptionId": "res_9x2m4k",
    "mobilePortIds": []
  },
  "createdAt": "2026-10-05T14:03:11Z",
  "paidAt": "2026-10-05T14:03:11Z"
}
```

*curl*

```bash
curl -s -X POST "https://localserpproxy.com/api/v1/orders" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"planId":"res-10"}'
```

*Python*

```python
import os, uuid
import requests

API = "https://localserpproxy.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['API_KEY']}", "Idempotency-Key": str(uuid.uuid4())}

r = requests.post(f"{API}/orders", headers=HEADERS, json={"planId": "res-10"}, timeout=30)
r.raise_for_status()
print(r.json())
```

*Node.js*

```javascript
// Node.js 18+ (built-in fetch), ES module
import { randomUUID } from 'node:crypto';

const API = 'https://localserpproxy.com/api/v1';

const res = await fetch(`${API}/orders`, {
  method: 'POST',
  headers: { Authorization: `Bearer ${process.env.API_KEY}`, 'Idempotency-Key': randomUUID(), 'Content-Type': 'application/json' },
  body: JSON.stringify({ planId: 'res-10' }),
});
if (!res.ok) throw new Error((await res.json()).error?.message ?? `HTTP ${res.status}`);
console.log(await res.json());
```

## 注文一覧

`GET /v1/orders`

認証：`Authorization: Bearer API_KEY`ヘッダーにAPIキーを指定します。

**パラメーター**

| 名前 | 場所 | 型 | 必須 | 説明 |
| --- | --- | --- | --- | --- |
| `page` | query | integer | いいえ | 1以上、デフォルトは`1` |
| `perPage` | query | integer | いいえ | 1～100、デフォルトは`20` |
| `status` | query | `completed` · `cancelled` | いいえ | 注文は支払い済み（残高から差し引き済み）の状態で作成されます。`completed` — 支払い済みで提供済み（認証情報はすぐに利用可能）。 |
| `productId` | query | string | いいえ | カタログの商品ID。LocalSERP Proxyの値: `residential`（GB）、`mobile`（専用4G/5Gポート）、`mobile-gb`（GB単位のローテーション4G/5Gトラフィック）。クライアントは未知の値にも対応する必要があります。 |

**レスポンス** `200 OK`

```json
{
  "data": [
    {
      "id": "ord_4f8k2m9q",
      "status": "completed",
      "productId": "residential",
      "planId": "res-10",
      "planName": "Local team",
      "quantity": 1,
      "unitPrice": "7.50",
      "subtotal": "7.50",
      "discount": "0.00",
      "total": "7.50",
      "promoCode": null,
      "currency": "USD",
      "topUpId": null,
      "options": {},
      "fulfillment": {
        "residentialSubscriptionId": "res_9x2m4k",
        "mobilePortIds": []
      },
      "createdAt": "2026-10-05T14:03:11Z",
      "paidAt": "2026-10-05T14:03:11Z"
    }
  ],
  "pagination": {
    "page": 1,
    "perPage": 20,
    "total": 1,
    "totalPages": 1
  }
}
```

*curl*

```bash
curl -s "https://localserpproxy.com/api/v1/orders" \
  -H "Authorization: Bearer $API_KEY"
```

*Python*

```python
import os
import requests

API = "https://localserpproxy.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['API_KEY']}"}

r = requests.get(f"{API}/orders", headers=HEADERS, timeout=30)
r.raise_for_status()
print(r.json())
```

*Node.js*

```javascript
// Node.js 18+ (built-in fetch), ES module
const API = 'https://localserpproxy.com/api/v1';

const res = await fetch(`${API}/orders`, {
  headers: { Authorization: `Bearer ${process.env.API_KEY}` },
});
if (!res.ok) throw new Error((await res.json()).error?.message ?? `HTTP ${res.status}`);
console.log(await res.json());
```

## 注文を取得

`GET /v1/orders/{orderId}`

認証：`Authorization: Bearer API_KEY`ヘッダーにAPIキーを指定します。

**パラメーター**

| 名前 | 場所 | 型 | 必須 | 説明 |
| --- | --- | --- | --- | --- |
| `orderId` | path | string | はい | — |

**レスポンス** `200 OK`

```json
{
  "id": "ord_4f8k2m9q",
  "status": "completed",
  "productId": "residential",
  "planId": "res-10",
  "planName": "Local team",
  "quantity": 1,
  "unitPrice": "7.50",
  "subtotal": "7.50",
  "discount": "0.00",
  "total": "7.50",
  "promoCode": null,
  "currency": "USD",
  "topUpId": null,
  "options": {},
  "fulfillment": {
    "residentialSubscriptionId": "res_9x2m4k",
    "mobilePortIds": []
  },
  "createdAt": "2026-10-05T14:03:11Z",
  "paidAt": "2026-10-05T14:03:11Z"
}
```

*curl*

```bash
curl -s "https://localserpproxy.com/api/v1/orders/ord_4f8k2m9q" \
  -H "Authorization: Bearer $API_KEY"
```

*Python*

```python
import os
import requests

API = "https://localserpproxy.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['API_KEY']}"}

r = requests.get(f"{API}/orders/ord_4f8k2m9q", headers=HEADERS, timeout=30)
r.raise_for_status()
print(r.json())
```

*Node.js*

```javascript
// Node.js 18+ (built-in fetch), ES module
const API = 'https://localserpproxy.com/api/v1';

const res = await fetch(`${API}/orders/ord_4f8k2m9q`, {
  headers: { Authorization: `Bearer ${process.env.API_KEY}` },
});
if (!res.ok) throw new Error((await res.json()).error?.message ?? `HTTP ${res.status}`);
console.log(await res.json());
```

---

LocalSERP Proxy: LocalSERP Proxyは、都市ごとにローカル検索結果、広告、価格を確認するための米国のレジデンシャルプロキシサービスで、暗号資産で支払い、身分証明書のアップロードは不要です。
